Fully rethought the structure of what I'm trying to do

This commit is contained in:
alisolarflare 2016-11-02 16:17:26 -04:00
parent 9e8449e3c9
commit 0d3c83b65f
11 changed files with 96 additions and 59 deletions

View file

@ -1,5 +0,0 @@
package alisolarflare.modules.events.uhc;
public enum MatchState {
SETUP, INTRO, PEACE, TENSION, POWER, END
}

View file

@ -1,16 +0,0 @@
package alisolarflare.modules.events.uhc;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
/**
* Class that contains the data for a single UltraHardcore Match,
* which represents a single game.
* @author Alisolarflare
*/
public class UHCMatch {
public List<String> matchPlayerUsernames = new ArrayList<String>();
}

View file

@ -4,10 +4,11 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.Module; import alisolarflare.modules.Module;
import alisolarflare.modules.events.uhc.commands.AddToUHC; import alisolarflare.modules.events.uhc.commands.AddToUHC;
import alisolarflare.modules.events.uhc.commands.StartMatch;
import alisolarflare.modules.events.uhc.memory.UHCMatch;
public class UHCModule extends Module { public class UHCModule extends Module {
public UHCMatch generalMemory; public UHCMatch match;
public String[] finiteStates = {"SETUP", "INTRO", "PEACE", "TENSION", "POWER", "END"};
public void register(JavaPlugin plugin){ public void register(JavaPlugin plugin){
registerCommands(plugin); registerCommands(plugin);
@ -17,10 +18,10 @@ public class UHCModule extends Module {
private void registerListeners(JavaPlugin plugin) { private void registerListeners(JavaPlugin plugin) {
} }
private void registerCommands(JavaPlugin plugin) { private void registerCommands(JavaPlugin plugin) {
// TODO Auto-generated method stub registerCommand(plugin, "addToUHC", new AddToUHC(this.match));
registerCommand(plugin, "addToUHC", new AddToUHC(this.generalMemory)); registerCommand(plugin, "startMatch", new StartMatch(this.match));
} }
private void registerMemoryUnits(JavaPlugin plugin){ private void registerMemoryUnits(JavaPlugin plugin){
generalMemory = new UHCMatch(); match = new UHCMatch(plugin.getConfig(), plugin.getConfig().getString("UHCMatchState"));
} }
} }

View file

@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.modules.events.uhc.UHCMatch; import alisolarflare.modules.events.uhc.memory.UHCMatch;
/** /**
* This class handles the specific command /addToUHC which, in-game, * This class handles the specific command /addToUHC which, in-game,

View file

@ -0,0 +1,35 @@
package alisolarflare.modules.events.uhc.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.modules.events.uhc.memory.MatchState;
import alisolarflare.modules.events.uhc.memory.UHCMatch;
public class StartMatch implements CommandExecutor {
private UHCMatch match;
public StartMatch(UHCMatch match){
this.match = match;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command! Contact a dev if you think this is wrong");
}
if (match.getMatchState() == MatchState.NULL)
sender.sendMessage("There is no match to begin.");
else if (match.getMatchState() == MatchState.IDLE)
sender.sendMessage("There is currently a match ready... Activating...");
else if (match.getMatchState() == MatchState.WAITING)
sender.sendMessage("There currently a match planned for: TIME:TIME:TIME");
else if (match.getMatchState() == MatchState.END)
sender.sendMessage("The match has ended! Would you like to restart?");
else
sender.sendMessage("You cannot start a match now, one is already in progress!");
return false;
}
}

View file

@ -9,10 +9,10 @@ import org.bukkit.scheduler.BukkitTask;
* ghostie powers if an Ultrahardcore Match is going on, * ghostie powers if an Ultrahardcore Match is going on,
* and it's time for powers to activate * and it's time for powers to activate
*/ */
public class PlayerPowerCyclingListener implements Listener { public class MatchCyclingListener implements Listener {
public BukkitTask PowerCyclingTask; public BukkitTask PowerCyclingTask;
public PlayerPowerCyclingListener(JavaPlugin plugin){ public MatchCyclingListener(JavaPlugin plugin){
PowerCyclingTask = (new PlayerPowerTask(plugin)).runTaskTimer(plugin, 20, 20); PowerCyclingTask = (new MatchMainLoop()).runTaskTimer(plugin, 20, 20);
} }
} }

View file

@ -0,0 +1,12 @@
package alisolarflare.modules.events.uhc.listeners;
import org.bukkit.scheduler.BukkitRunnable;
public class MatchMainLoop extends BukkitRunnable{
@Override
public void run() {
}
}

View file

@ -1,24 +0,0 @@
package alisolarflare.modules.events.uhc.listeners;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
/**
* This is the main class that creates and implemnts Ghostie powers
* When run, it will apply the right potion effects to different players
* based on what colours they identify as in that time.
* @author Alisolarflare
*
*/
public class PlayerPowerTask extends BukkitRunnable{
private JavaPlugin plugin;
public PlayerPowerTask(JavaPlugin plugin){
this.plugin = plugin;
}
@Override
public void run() {
}
}

View file

@ -0,0 +1,5 @@
package alisolarflare.modules.events.uhc.memory;
public enum MatchState {
NULL, IDLE, WAITING, SETUP, INTRO, PEACE, TENSION, POWER, END
}

View file

@ -1,5 +0,0 @@
package alisolarflare.modules.events.uhc.memory;
public class PlayerPowerModule {
}

View file

@ -0,0 +1,34 @@
package alisolarflare.modules.events.uhc.memory;
import java.util.ArrayList;
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> matchPlayerUsernames = new ArrayList<String>();
private MatchState matchState = MatchState.IDLE;
private FileConfiguration fileConfiguration;
/**Class that fucks shit up*/
public UHCMatch(FileConfiguration fileConfiguration, String stateName) {
this.fileConfiguration = fileConfiguration;
this.matchState = MatchState.valueOf(stateName);
}
/**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());
}
}