Add functionality to skip polls
This commit is contained in:
parent
6e9d2b3244
commit
34ffc06166
@ -177,9 +177,9 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||
}
|
||||
}
|
||||
player.sendMessage("");
|
||||
player.sendMessage("");
|
||||
player.sendMessage(C.cGray + "Click an answer or type " + F.elem("/poll <answer>"));
|
||||
player.sendMessage(F.elem("") + "Type " + F.elem("/poll exit") + " to leave this poll");
|
||||
player.sendMessage(F.elem("") + "Type " + F.elem("/poll exit") + " to postpone this poll");
|
||||
player.sendMessage(F.elem("") + " or type " + F.elem("/poll skip") + " to skip this question");
|
||||
player.sendMessage(C.cRed + "=======================================");
|
||||
}
|
||||
|
||||
@ -192,11 +192,13 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||
{
|
||||
final String name = player.getName();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final boolean answered = answer != -1;
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
player.sendMessage("");
|
||||
Get(player).addAnswer(poll.getId(), answer);
|
||||
UtilPlayer.message(player, F.main("Poll", "Thanks for your response!"));
|
||||
|
||||
UtilPlayer.message(player, F.main("Poll", answered ? "Thanks for your response!" : "Question skipped"));
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0);
|
||||
|
||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
@ -207,6 +209,9 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||
// First update poll answer
|
||||
if (_repository.addPollAnswer(uuid, poll.getId(), answer))
|
||||
{
|
||||
if (!answered)
|
||||
return;
|
||||
|
||||
// Next add coins
|
||||
_donationManager.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public class PollCommand extends CommandBase<PollManager>
|
||||
{
|
||||
if (currentPoll != null)
|
||||
Plugin.displayPoll(caller, currentPoll);
|
||||
UtilPlayer.message(caller, F.main("Poll", "Invalid arguments. " + F.elem("/poll <answer #> or /poll close")));
|
||||
UtilPlayer.message(caller, F.main("Poll", "Invalid arguments. " + F.elem("/poll #> ") + "or" + F.elem(" /poll exit/skip")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -45,6 +45,13 @@ public class PollCommand extends CommandBase<PollManager>
|
||||
UtilPlayer.message(caller, F.main("Poll", "Poll cancelled!"));
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("skip") && currentPoll != null)
|
||||
{
|
||||
// Tell the plugin to skip this question
|
||||
Plugin.answerPoll(caller, currentPoll, -1);
|
||||
pollData.setCurrentPoll(null);
|
||||
pollData.setLastPollTime(System.currentTimeMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentPoll == null)
|
||||
|
Loading…
Reference in New Issue
Block a user