From b6ce31e5474b8791dea5779ab0b80c2dc112b67a Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 3 Nov 2016 14:47:00 -0400 Subject: [PATCH] Fixed bug: UHCMatchState not initialized in config. --- config.yml | 1 + src/alisolarflare/events/uhc/UHCModule.java | 7 ++++- .../events/uhc/commands/StartMatch.java | 29 ++++++++++++++----- .../events/uhc/memory/MatchState.java | 2 +- .../events/uhc/memory/UHCMatch.java | 13 ++------- .../minigames/freeforall/StartMinigame.java | 5 ---- 6 files changed, 33 insertions(+), 24 deletions(-) delete mode 100644 src/alisolarflare/minigames/freeforall/StartMinigame.java diff --git a/config.yml b/config.yml index e69de29..30ae627 100644 --- a/config.yml +++ b/config.yml @@ -0,0 +1 @@ +UHCMatchState: "NULL" \ No newline at end of file diff --git a/src/alisolarflare/events/uhc/UHCModule.java b/src/alisolarflare/events/uhc/UHCModule.java index 4e27b57..b470c3d 100644 --- a/src/alisolarflare/events/uhc/UHCModule.java +++ b/src/alisolarflare/events/uhc/UHCModule.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.Module; import alisolarflare.events.uhc.commands.AddToUHC; +import alisolarflare.events.uhc.memory.MatchState; import alisolarflare.events.uhc.memory.UHCMatch; import buttondevteam.lib.chat.TBMCChatAPI; @@ -24,6 +25,10 @@ public class UHCModule extends Module { } private void registerMemoryUnits(JavaPlugin plugin) { - match = new UHCMatch(plugin.getConfig(), plugin.getConfig().getString("UHCMatchState")); + if (plugin.getConfig().contains("UHCMatchState")){ + match = new UHCMatch(plugin.getConfig(), MatchState.valueOf(plugin.getConfig().getString("UHCMatchState"))); + }else{ + match = new UHCMatch(plugin.getConfig(), MatchState.IDLE); + } } } diff --git a/src/alisolarflare/events/uhc/commands/StartMatch.java b/src/alisolarflare/events/uhc/commands/StartMatch.java index 513c23d..bee51bb 100644 --- a/src/alisolarflare/events/uhc/commands/StartMatch.java +++ b/src/alisolarflare/events/uhc/commands/StartMatch.java @@ -15,18 +15,33 @@ public class StartMatch extends TBMCCommandBase { @Override public boolean OnCommand(CommandSender sender, String label, String[] args) { - if (match.getMatchState() == MatchState.NULL) - sender.sendMessage("There is no match to begin."); - else if (match.getMatchState() == MatchState.IDLE) + + if (!sender.hasPermission("moderator") && !(sender.getName() == "")) + sender.sendMessage("You must be a moderator or Arsenalis to use this command! " + + "Contact a TBMC dev if you think this is wrong"); + + //ACTIVATES MATCH + switch(match.getMatchState()){ + case IDLE: sender.sendMessage("There is currently a match ready... Activating..."); - else if (match.getMatchState() == MatchState.WAITING) + break; + + case WAITING: sender.sendMessage("There currently a match planned for: TIME:TIME:TIME"); - else if (match.getMatchState() == MatchState.END) + break; + + case END: sender.sendMessage("The match has ended! Would you like to restart?"); - else + break; + + default: sender.sendMessage("You cannot start a match now, one is already in progress!"); - + + + } + return false; + } diff --git a/src/alisolarflare/events/uhc/memory/MatchState.java b/src/alisolarflare/events/uhc/memory/MatchState.java index 8425f71..0838048 100644 --- a/src/alisolarflare/events/uhc/memory/MatchState.java +++ b/src/alisolarflare/events/uhc/memory/MatchState.java @@ -1,5 +1,5 @@ package alisolarflare.events.uhc.memory; public enum MatchState { - NULL, IDLE, WAITING, SETUP, INTRO, PEACE, TENSION, POWER, END + IDLE, WAITING, SETUP, INTRO, PEACE, TENSION, POWER, END } diff --git a/src/alisolarflare/events/uhc/memory/UHCMatch.java b/src/alisolarflare/events/uhc/memory/UHCMatch.java index de42cf8..0461d3f 100644 --- a/src/alisolarflare/events/uhc/memory/UHCMatch.java +++ b/src/alisolarflare/events/uhc/memory/UHCMatch.java @@ -5,28 +5,21 @@ import java.util.List; import org.bukkit.configuration.file.FileConfiguration; -/** - * Class that contains the data for a single UltraHardcore Match, - * which represents a single game. - * @author Alisolarflare - */ + public class UHCMatch { public List playerList = new ArrayList(); private MatchState matchState = MatchState.IDLE; private FileConfiguration fileConfiguration; - /**Class that fucks shit up*/ - public UHCMatch(FileConfiguration fileConfiguration, String stateName) { + public UHCMatch(FileConfiguration fileConfiguration, MatchState state) { this.fileConfiguration = fileConfiguration; - this.matchState = MatchState.valueOf(stateName); + this.matchState = state; } - /**Other class that doesn't fuck shit up*/ public MatchState getMatchState(){ return matchState; } - /**Other class that REALLY fucks shit up*/ public void setMatchState(MatchState newMS){ matchState = newMS; fileConfiguration.set("UHCMatchState", newMS.toString()); diff --git a/src/alisolarflare/minigames/freeforall/StartMinigame.java b/src/alisolarflare/minigames/freeforall/StartMinigame.java deleted file mode 100644 index 1017cae..0000000 --- a/src/alisolarflare/minigames/freeforall/StartMinigame.java +++ /dev/null @@ -1,5 +0,0 @@ -package alisolarflare.minigames.freeforall; - -public class StartMinigame { - -}