From 72ea55a7f2116f337d4758509dcc58474cc02d65 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 6 Sep 2019 18:08:58 +0200 Subject: [PATCH] PollSystem --- src/de/steamwar/bungeecore/commands/PollCommand.java | 2 +- .../bungeecore/listeners/ConnectionListener.java | 2 +- src/de/steamwar/bungeecore/listeners/PollSystem.java | 10 +++++----- src/de/steamwar/bungeecore/sql/PollAnswer.java | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PollCommand.java b/src/de/steamwar/bungeecore/commands/PollCommand.java index f6f7b1c..65ea965 100644 --- a/src/de/steamwar/bungeecore/commands/PollCommand.java +++ b/src/de/steamwar/bungeecore/commands/PollCommand.java @@ -33,7 +33,7 @@ public class PollCommand extends BasicCommand { int answer; try { answer = Integer.parseUnsignedInt(args[0]); - if(answer < 1 || answer >= PollSystem.answers()) + if(answer < 1 || answer > PollSystem.answers()) throw new NumberFormatException(); }catch(NumberFormatException e){ BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDas ist keine Antwortmöglichkeit!"); diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 10c281d..9f0368a 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -127,6 +127,6 @@ public class ConnectionListener extends BasicListener { ProxiedPlayer player = e.getPlayer(); Collection players = server.getPlayers(); if(players.isEmpty() || (players.size() == 1 && players.contains(player))) - subserver.stop(); + ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::stop); } } diff --git a/src/de/steamwar/bungeecore/listeners/PollSystem.java b/src/de/steamwar/bungeecore/listeners/PollSystem.java index 0cf5ce3..c3f7c10 100644 --- a/src/de/steamwar/bungeecore/listeners/PollSystem.java +++ b/src/de/steamwar/bungeecore/listeners/PollSystem.java @@ -41,15 +41,15 @@ public class PollSystem extends BasicListener { BungeeCore.send(player, "§7Klicke die Antwort an, die dir gefällt!"); BungeeCore.send(player, "§e" + question); - for(int i = 0; i < answers.size(); i++){ - BungeeCore.send(player, "§7" + answers.get(i), - "§eDiese Antwort wählen", - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/poll " + (i+1))); + for(int i = 1; i <= answers.size(); i++){ + BungeeCore.send(player, "§7" + answers.get(i-1), + "§e" + answers.get(i-1) + " §ewählen", + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/poll " + i)); } } public static boolean noCurrentPoll(){ - return question != null && !question.equals(""); + return question == null || question.equals(""); } public static String getQuestion() { diff --git a/src/de/steamwar/bungeecore/sql/PollAnswer.java b/src/de/steamwar/bungeecore/sql/PollAnswer.java index 56901a7..c8ff434 100644 --- a/src/de/steamwar/bungeecore/sql/PollAnswer.java +++ b/src/de/steamwar/bungeecore/sql/PollAnswer.java @@ -19,6 +19,7 @@ public class PollAnswer { private PollAnswer(int userID, String question){ this.userID = userID; this.question = question; + answer = 0; } public static PollAnswer get(int userID){ @@ -34,7 +35,7 @@ public class PollAnswer { } public boolean hasAnswered(){ - return answer == 0; + return answer != 0; } public void setAnswer(int answer){