Skip to content
Merged
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>groupId</groupId>
<artifactId>JVote</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
43 changes: 34 additions & 9 deletions src/main/java/com/wkaye/jvote/JVoteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,46 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}
Player player = (Player) sender;

if (voteStarted.get()) {
// vote started, check that the user actually supplied a yes or no vote
if (!("yes".contains(args[0].toLowerCase()) || "no".contains(args[0].toLowerCase()) || "ok".contains(args[0].toLowerCase()))) {
// vote started, check if they're voting yes/no or voting for the same type as current vote
String arg = args[0].toLowerCase();

// Check if they're trying to vote for the same type as the current vote
boolean isVotingForCurrentType = false;
try {
JVoteEnums inputVoteType = JVoteEnums.valueOf(args[0].toUpperCase());
// Check if the input vote type matches the current vote type
if (inputVoteType == currentVoteType ||
(inputVoteType == JVoteEnums.CLEAR && currentVoteType == JVoteEnums.SUN) ||
(inputVoteType == JVoteEnums.SUN && currentVoteType == JVoteEnums.CLEAR)) {
isVotingForCurrentType = true;
}
} catch (IllegalArgumentException e) {
// continue with normal yes & no check
}

if (isVotingForCurrentType) {
// They're voting for the same type as current vote, treat as "yes"
if (checkVote("yes", player)) {
doVote();
return true;
}
} else if ("yes".contains(arg) || "no".contains(arg) || "ok".contains(arg)) {
// Normal yes/no/ok voting
if (checkVote(args[0], player)) {
// vote passed, perform change and reset values
doVote();
return true;
}
} else {
// invalid usage, return false
sender.sendMessage(JVoteUtils.printMessage("A vote is already in progress"));
plugin.logger(Level.WARNING, "Attempted /vote after vote started with improper args");
return true;
}
if (checkVote(args[0], player)) {
// vote passed, perform change and reset values
doVote();
return true;
}

}

if (!voteStarted.get()) {
try {
// this line to trigger exception if not valid
Expand All @@ -96,7 +121,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
"A vote for "
+ JVoteUtils.formatColor(currentVoteType.color())
+ JVoteUtils.formatColor(currentVoteType.toString().toLowerCase())
+ JVoteUtils.formatColor("&7 has started. Vote by doing &a/vote <yes/no>"));
+ JVoteUtils.formatColor("&7 has started. Vote by doing &a/vote <yes/no/" + currentVoteType.toString().toLowerCase() + ">"));
plugin.getServer().broadcastMessage(msg);
if (checkVote("yes", player)) {
doVote();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: JVote
version: 1.0.0
version: 1.0.2
main: com.wkaye.jvote.JVote
authors: [ xXGunner989Xx ]
description: A weather voting plugin for Minecraft Beta 1.7.3 designed for Project Poseidon w/ Fundamentals
Expand Down