Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#binary
bin/

#eclipse
.classpath
.project
.settings/
13 changes: 8 additions & 5 deletions src/nl/blaatz0r/Trivia/CommandExecutors/VoteNextExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,26 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
} else if (plugin.voted.contains(player)) {
player.sendMessage(Trivia.PREFIX_TRIVIA + ChatColor.BLUE + "You have already voted!");
} else {
if (plugin.votes == 0 && Trivia.Permissions.has(player, "Trivia.startvote")) {
if (Trivia.Permissions.has(player, "Trivia.startvote")) {
if (plugin.voted.contains(player)) {
player.sendMessage(Trivia.PREFIX_TRIVIA + "You have already voted.");
} else {
plugin.voted.add(player);
plugin.votes++;
double limit = ((double)plugin.triviaUsers.size() / 2.0);
if (plugin.votes > limit) {
if (plugin.voted.size() > limit) {
plugin.nextQuestion();
for (Player p : plugin.triviaUsers) {
p.sendMessage(Trivia.PREFIX_TRIVIA + ChatColor.BLUE + "Vote succeeded!");
}
} else {
for (Player p : plugin.triviaUsers) {
p.sendMessage(Trivia.PREFIX_TRIVIA + ChatColor.BLUE + " voted for the next question. [" + plugin.votes + "/" + (int)(Math.ceil(limit)+1) + ChatColor.BLUE + "]");
if(plugin.votes == 1) {
p.sendMessage(Trivia.PREFIX_TRIVIA + ChatColor.BLUE + " voted for the next question. [" + plugin.voted.size() + "/" + (int)(Math.ceil(limit)+1) + ChatColor.BLUE + "]");
if(plugin.voted.size() == 1 && p != player) {
p.sendMessage(ChatColor.BLUE + "For the next question, use " + ChatColor.BLUE + "/votenext");
}
}
}
}
} else {
player.sendMessage(Trivia.PREFIX_TRIVIA + "You don't have permissions to start a new vote.");
}
Expand Down
4 changes: 0 additions & 4 deletions src/nl/blaatz0r/Trivia/Trivia.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class Trivia extends JavaPlugin {
public int hints;
private String[] questions;
public boolean canAnswer;
public int votes;
public List<Player> voted;
private boolean triviaRunning;

Expand Down Expand Up @@ -145,7 +144,6 @@ public void startTrivia(boolean verbose) {
p.sendMessage(Trivia.PREFIX_TRIVIA + "Trivia has started! \\o/");
}
}
votes = 0;
voted = new ArrayList<Player>();
startTime = new Date().getTime();
hints = 0;
Expand Down Expand Up @@ -185,7 +183,6 @@ public void stopTrivia() {
}

voted = new ArrayList<Player>();
votes = 0;
hints = 0;
canAnswer = false;
triviaRunning = false;
Expand All @@ -204,7 +201,6 @@ public void stopTrivia() {
* Resets the number of hints, reads a question, creates a hint and enables answering.
*/
public void nextQuestion() {
this.votes = 0;
this.voted = new ArrayList<Player>();
this.hints = 0;
this.startTime = new Date().getTime();
Expand Down