Fixed bug: UHCMatchState not initialized in config.

This commit is contained in:
alisolarflare 2016-11-03 14:47:00 -04:00
parent 73bdb7e0bf
commit b6ce31e547
6 changed files with 33 additions and 24 deletions

View file

@ -0,0 +1 @@
UHCMatchState: "NULL"

View file

@ -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);
}
}
}

View file

@ -15,19 +15,34 @@ 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;
}
@Override

View file

@ -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
}

View file

@ -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<String> playerList = new ArrayList<String>();
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());

View file

@ -1,5 +0,0 @@
package alisolarflare.minigames.freeforall;
public class StartMinigame {
}