diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2021-12-25 08:16:03 -0600 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2021-12-25 08:16:03 -0600 |
commit | 6239acb08a43d6bfef51f6abc8b7cc65687c51c7 (patch) | |
tree | 0f8fa7d17f9139f8aa64e72453272674334029df /src/main/java/net/tylermurphy/hideAndSeek/command | |
parent | Merge pull request #16 from tylermurphy534/1.3.2 (diff) | |
download | kenshinshideandseek-6239acb08a43d6bfef51f6abc8b7cc65687c51c7.tar.gz kenshinshideandseek-6239acb08a43d6bfef51f6abc8b7cc65687c51c7.tar.bz2 kenshinshideandseek-6239acb08a43d6bfef51f6abc8b7cc65687c51c7.zip |
1.3.3 beta 2
Diffstat (limited to '')
12 files changed, 25 insertions, 125 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java index e38c19a..0c6b253 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java @@ -3,7 +3,7 @@ package net.tylermurphy.hideAndSeek.command; import org.bukkit.command.CommandSender; import net.md_5.bungee.api.ChatColor; -import net.tylermurphy.hideAndSeek.bukkit.CommandHandler; +import net.tylermurphy.hideAndSeek.util.CommandHandler; public class Help implements ICommand { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java index 17b8f7a..31660b2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java @@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -34,7 +35,7 @@ public class Join implements ICommand { } public static void join(Player player){ - if(Main.plugin.status.equals("Standby")) { + if(Main.plugin.status == Status.STANDBY) { player.getInventory().clear(); Main.plugin.board.addHider(player); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player)); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java index 8809b5d..1568a9b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java @@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.CommandSender; @@ -32,7 +33,7 @@ public class Leave implements ICommand { Main.plugin.board.removeBoard(player); Main.plugin.board.remove(player); player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ())); - if(Main.plugin.status.equals("Standby")) { + if(Main.plugin.status == Status.STANDBY) { Main.plugin.board.reloadLobbyBoards(); } else { Main.plugin.board.reloadGameBoards(); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java index 971cd13..dffbb10 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java @@ -3,6 +3,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; import net.tylermurphy.hideAndSeek.configuration.Items; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.command.CommandSender; import net.tylermurphy.hideAndSeek.Main; @@ -15,7 +16,7 @@ public class Reload implements ICommand { public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java index 2befd73..2e8b4f8 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java @@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; @@ -14,7 +15,7 @@ public class SaveMap implements ICommand { public static boolean runningBackup = false; public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java index 472396c..f7fb8e9 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java @@ -2,9 +2,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import java.util.HashMap; -import java.util.Map; - +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -16,7 +14,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.*; public class SetBorder implements ICommand { public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java index c94a0d1..bbf099d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java @@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,7 +12,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.*; public class SetBounds implements ICommand { public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java index aeaa89b..ea0144d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java @@ -5,6 +5,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*; import java.util.HashMap; import java.util.Map; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -15,7 +16,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.*; public class SetExitLocation implements ICommand { public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java index 2e96a9d..4002bee 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java @@ -5,6 +5,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*; import java.util.HashMap; import java.util.Map; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -15,7 +16,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.*; public class SetLobbyLocation implements ICommand { public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java index bb3de6d..c854b60 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java @@ -5,6 +5,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*; import java.util.HashMap; import java.util.Map; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -17,7 +18,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.*; public class SetSpawnLocation implements ICommand { public void execute(CommandSender sender, String[] args) { - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java index 05565da..31f04d1 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java @@ -1,6 +1,7 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Localization.*; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -36,7 +37,7 @@ public class Start implements ICommand { sender.sendMessage(errorPrefix + message("GAME_SETUP")); return; } - if(!Main.plugin.status.equals("Standby")) { + if(Main.plugin.status != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } @@ -48,11 +49,6 @@ public class Start implements ICommand { sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers)); return; } - if(Bukkit.getServer().getWorld("hideandseek_"+spawnWorld) != null) { - Main.plugin.worldLoader.rollback(); - } else { - Main.plugin.worldLoader.loadMap(); - } String seekerName; if(args.length < 1) { seekerName = Main.plugin.board.getPlayers().stream().skip(new Random().nextInt(Main.plugin.board.size())).findFirst().get().getName(); @@ -64,77 +60,7 @@ public class Start implements ICommand { sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName)); return; } - Main.plugin.board.reload(); - for(Player temp : Main.plugin.board.getPlayers()) { - if(temp.getName().equals(seeker.getName())) - continue; - Main.plugin.board.addHider(temp); - } - Main.plugin.board.addSeeker(seeker); - currentWorldborderSize = worldborderSize; - for(Player player : Main.plugin.board.getPlayers()) { - player.getInventory().clear(); - player.setGameMode(GameMode.ADVENTURE); - player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); - for(PotionEffect effect : player.getActivePotionEffects()){ - player.removePotionEffect(effect.getType()); - } - } - for(Player player : Main.plugin.board.getSeekers()) { - player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false)); - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false)); - player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString(), 10, 70, 20); - } - for(Player player : Main.plugin.board.getHiders()) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false)); - player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + message("HIDERS_SUBTITLE").toString(), 10, 70, 20); - } - Worldborder.resetWorldborder("hideandseek_"+spawnWorld); - for(Player player : Main.plugin.board.getPlayers()){ - Main.plugin.board.createGameBoard(player); - } - Main.plugin.board.reloadGameBoards(); - Main.plugin.status = "Starting"; - int temp = Main.plugin.gameId; - Util.broadcastMessage(messagePrefix + message("START_COUNTDOWN").addAmount(30)); - Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(20), Main.plugin.gameId, 20 * 10); - Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(10), Main.plugin.gameId, 20 * 20); - Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(5), Main.plugin.gameId, 20 * 25); - Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(3), Main.plugin.gameId, 20 * 27); - Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(2), Main.plugin.gameId, 20 * 28); - Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(1), Main.plugin.gameId, 20 * 29); - Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() { - public void run() { - if(temp != Main.plugin.gameId) return; - Util.broadcastMessage(messagePrefix + message("START")); - Main.plugin.status = "Playing"; - for(Player player : Main.plugin.board.getPlayers()) { - Util.resetPlayer(player); - } - Main.plugin.worldborder = null; - Main.plugin.taunt = null; - Main.plugin.glow = null; - - if(worldborderEnabled) { - Main.plugin.worldborder = new Worldborder(Main.plugin.gameId); - Main.plugin.worldborder.schedule(); - } - - if(tauntEnabled) { - Main.plugin.taunt = new Taunt(Main.plugin.gameId); - Main.plugin.taunt.schedule(); - } - - if (glowEnabled) { - Main.plugin.glow = new Glow(Main.plugin.gameId); - } - - if(gameLength > 0) { - Main.plugin.timeLeft = gameLength; - } - } - }, 20 * 30); - + Main.plugin.game.start(seeker); } public String getLabel() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java index e4dd16e..f444f34 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java @@ -2,17 +2,11 @@ package net.tylermurphy.hideAndSeek.command; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import net.tylermurphy.hideAndSeek.game.Status; import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.events.Worldborder; -import net.tylermurphy.hideAndSeek.util.Packet; import net.tylermurphy.hideAndSeek.util.Util; import static net.tylermurphy.hideAndSeek.configuration.Localization.*; @@ -23,14 +17,12 @@ public class Stop implements ICommand { sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do"); return; } - if(Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing")) { + if(Main.plugin.status == Status.STARTING || Main.plugin.status == Status.PLAYING) { if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("STOP")); else Util.broadcastMessage(abortPrefix + message("STOP")); - onStop(); - + Main.plugin.game.stop(); } else { sender.sendMessage(errorPrefix + message("GAME_NOT_INPROGRESS")); - return; } } @@ -38,30 +30,6 @@ public class Stop implements ICommand { return "stop"; } - public static void onStop() { - if(Main.plugin.status.equals("Standby")) return; - Main.plugin.status = "Standby"; - Main.plugin.gameId++; - Main.plugin.timeLeft = 0; - Worldborder.resetWorldborder("hideandseek_"+spawnWorld); - for(Player player : Main.plugin.board.getPlayers()) { - Main.plugin.board.createLobbyBoard(player); - player.setGameMode(GameMode.ADVENTURE); - Main.plugin.board.addHider(player); - player.getInventory().clear(); - player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); - for(PotionEffect effect : player.getActivePotionEffects()){ - player.removePotionEffect(effect.getType()); - } - player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100)); - for(Player temp : Main.plugin.board.getPlayers()) { - Packet.setGlow(player, temp, false); - } - } - Main.plugin.worldLoader.unloadMap(); - Main.plugin.board.reloadLobbyBoards(); - } - public String getUsage() { return ""; } |