From bb254145ed0bb56d0482f6ba34e05cb728a7c8cc Mon Sep 17 00:00:00 2001 From: tylermurphy534 Date: Wed, 2 Nov 2022 07:18:00 -0400 Subject: 1.7.0 beta 2 --- .../java/net/tylermurphy/hideAndSeek/Main.java | 74 ++++++----- .../net/tylermurphy/hideAndSeek/command/About.java | 54 -------- .../net/tylermurphy/hideAndSeek/command/Debug.java | 130 ------------------- .../tylermurphy/hideAndSeek/command/Reload.java | 21 ++-- .../net/tylermurphy/hideAndSeek/command/Send.java | 67 ++++++++++ .../hideAndSeek/command/SetExitLocation.java | 61 +++++++++ .../net/tylermurphy/hideAndSeek/command/Start.java | 4 +- .../net/tylermurphy/hideAndSeek/command/Stop.java | 2 +- .../net/tylermurphy/hideAndSeek/command/Top.java | 2 +- .../command/location/LocationUtils.java | 53 ++++++++ .../hideAndSeek/command/location/Locations.java | 26 ++++ .../command/location/SetExitLocation.java | 61 --------- .../command/location/SetLobbyLocation.java | 58 --------- .../command/location/SetSeekerLobbyLocation.java | 47 ------- .../command/location/SetSpawnLocation.java | 79 ------------ .../command/location/util/LocationUtils.java | 53 -------- .../command/location/util/Locations.java | 26 ---- .../tylermurphy/hideAndSeek/command/map/Add.java | 54 ++++++++ .../hideAndSeek/command/map/AddMap.java | 54 -------- .../tylermurphy/hideAndSeek/command/map/Debug.java | 130 +++++++++++++++++++ .../tylermurphy/hideAndSeek/command/map/GoTo.java | 63 ++++++++++ .../tylermurphy/hideAndSeek/command/map/List.java | 46 +++++++ .../hideAndSeek/command/map/ListMaps.java | 47 ------- .../hideAndSeek/command/map/Remove.java | 53 ++++++++ .../hideAndSeek/command/map/RemoveMap.java | 53 -------- .../tylermurphy/hideAndSeek/command/map/Save.java | 98 +++++++++++++++ .../hideAndSeek/command/map/SaveMap.java | 97 -------------- .../hideAndSeek/command/map/SetBorder.java | 112 ----------------- .../hideAndSeek/command/map/SetBounds.java | 112 ----------------- .../hideAndSeek/command/map/SetMap.java | 67 ---------- .../tylermurphy/hideAndSeek/command/map/Setup.java | 97 -------------- .../hideAndSeek/command/map/Status.java | 95 ++++++++++++++ .../hideAndSeek/command/map/blockhunt/Enabled.java | 43 +++++++ .../hideAndSeek/command/map/set/Border.java | 112 +++++++++++++++++ .../hideAndSeek/command/map/set/Bounds.java | 112 +++++++++++++++++ .../hideAndSeek/command/map/set/Lobby.java | 58 +++++++++ .../hideAndSeek/command/map/set/SeekerLobby.java | 47 +++++++ .../hideAndSeek/command/map/set/Spawn.java | 79 ++++++++++++ .../hideAndSeek/command/util/CommandGroup.java | 13 +- .../hideAndSeek/configuration/Config.java | 39 ------ .../hideAndSeek/configuration/ConfigManager.java | 139 ++++++++++++++------- .../hideAndSeek/configuration/Leaderboard.java | 51 ++++++++ .../hideAndSeek/configuration/Localization.java | 2 +- .../net/tylermurphy/hideAndSeek/game/Board.java | 13 +- .../tylermurphy/hideAndSeek/game/Disguiser.java | 3 +- .../hideAndSeek/game/listener/ChatHandler.java | 2 +- .../hideAndSeek/game/listener/DisguiseHandler.java | 3 +- .../game/listener/InventoryHandler.java | 4 +- .../tylermurphy/hideAndSeek/world/WorldLoader.java | 4 +- 49 files changed, 1425 insertions(+), 1295 deletions(-) delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/About.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/Send.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java delete mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/configuration/Leaderboard.java (limited to 'src/main/java') diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java index b22af5b..b1e2a83 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java @@ -20,15 +20,11 @@ package net.tylermurphy.hideAndSeek; import net.tylermurphy.hideAndSeek.command.*; -import net.tylermurphy.hideAndSeek.command.location.*; import net.tylermurphy.hideAndSeek.command.map.*; -import net.tylermurphy.hideAndSeek.configuration.Config; -import net.tylermurphy.hideAndSeek.configuration.Items; -import net.tylermurphy.hideAndSeek.configuration.Localization; -import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.command.map.set.*; +import net.tylermurphy.hideAndSeek.configuration.*; import net.tylermurphy.hideAndSeek.database.Database; import net.tylermurphy.hideAndSeek.game.*; -import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.command.util.CommandGroup; import net.tylermurphy.hideAndSeek.game.listener.*; import net.tylermurphy.hideAndSeek.util.PAPIExpansion; @@ -41,7 +37,6 @@ import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import java.io.File; -import java.util.List; import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -65,10 +60,17 @@ public class Main extends JavaPlugin implements Listener { Main.instance = this; this.updateVersion(); - Config.loadConfig(); - Maps.loadMaps(); - Localization.loadLocalization(); - Items.loadItems(); + try { + Config.loadConfig(); + Maps.loadMaps(); + Localization.loadLocalization(); + Items.loadItems(); + Leaderboard.loadLeaderboard(); + } catch (Exception e) { + getLogger().severe(e.getMessage()); + Bukkit.getPluginManager().disablePlugin(this); + return; + } this.board = new Board(); this.database = new Database(); @@ -77,28 +79,27 @@ public class Main extends JavaPlugin implements Listener { this.registerListeners(); this.commandGroup = new CommandGroup("hs", - new About(), - new Debug(), new Help(), new Reload(), new Join(), new Leave(), + new Send(), new Start(), new Stop(), new CommandGroup("map", new CommandGroup("set", - new SetLobbyLocation(), - new SetSpawnLocation(), - new SetSeekerLobbyLocation(), - new SetBorder(), - new SetBounds() + new Lobby(), + new Spawn(), + new SeekerLobby(), + new Border(), + new Bounds() ), - new AddMap(), - new RemoveMap(), - new ListMaps(), - new SetMap(), - new Setup(), - new SaveMap() + new Add(), + new Remove(), + new List(), + new Status(), + new Save(), + new Debug() ), new SetExitLocation(), new Top(), @@ -120,20 +121,25 @@ public class Main extends JavaPlugin implements Listener { version = 0; - board.getPlayers().forEach(player -> { - board.removeBoard(player); - PlayerLoader.unloadPlayer(player); - if(!Objects.equals(exitWorld, "")) - player.teleport(exitPosition); - }); + if(board != null) { + board.getPlayers().forEach(player -> { + board.removeBoard(player); + PlayerLoader.unloadPlayer(player); + if (!Objects.equals(exitWorld, "")) + player.teleport(exitPosition); + }); + board.cleanup(); + } + + if(disguiser != null) { + disguiser.cleanUp(); + } Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this); - board.cleanup(); - disguiser.cleanUp(); } private void onTick() { - if(game.getStatus() == Status.ENDED) game = new Game(game.getCurrentMap(), board); + if(game.getStatus() == net.tylermurphy.hideAndSeek.game.util.Status.ENDED) game = new Game(game.getCurrentMap(), board); game.onTick(); disguiser.check(); } @@ -168,7 +174,7 @@ public class Main extends JavaPlugin implements Listener { return commandGroup.handleCommand((Player)sender, "", args); } - public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { + public java.util.List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { return commandGroup.handleTabComplete(sender, args); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java deleted file mode 100644 index 119888b..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command; - -import net.tylermurphy.hideAndSeek.command.util.Command; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -import java.util.List; - -public class About extends Command { - - public void execute(Player sender, String[] args) { - sender.sendMessage( - String.format("%s%sHide and Seek %s(%s1.7.0 ALPHA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + - String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) + - String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE) - ); - } - - public String getLabel() { - return "about"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Get information about the plugin"; - } - - public List autoComplete(String parameter) { - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java deleted file mode 100644 index 2eb0eb9..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.tylermurphy.hideAndSeek.command; - -import com.cryptomorin.xseries.XMaterial; -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.PlayerLoader; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class Debug extends Command { - - private static final Map>> debugMenuFunctions = new HashMap<>(); - - public void execute(Player sender, String[] args) { - net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - Inventory debugMenu = createMenu(map, sender); - sender.openInventory(debugMenu); - } - - private Inventory createMenu(net.tylermurphy.hideAndSeek.configuration.Map map, Player sender){ - Map> functions = new HashMap<>(); - Inventory debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu"); - debugMenu.setItem(0, createOption(functions, 0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> { - if(mapSaveEnabled) { - if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); - } - Main.getInstance().getBoard().addHider(player); - PlayerLoader.loadHider(player, map); - if(Main.getInstance().getGame().getStatus() != Status.STARTING) - PlayerLoader.resetPlayer(player, Main.getInstance().getBoard()); - })); - debugMenu.setItem(1, createOption(functions, 1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> { - if(mapSaveEnabled) { - if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); - } - Main.getInstance().getBoard().addSeeker(player); - PlayerLoader.loadSeeker(player, map); - if(Main.getInstance().getGame().getStatus() != Status.STARTING) - PlayerLoader.resetPlayer(player, Main.getInstance().getBoard()); - })); - debugMenu.setItem(2, createOption(functions, 2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> { - if(mapSaveEnabled) { - if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); - } - Main.getInstance().getBoard().addSpectator(player); - PlayerLoader.loadSpectator(player, map); - })); - debugMenu.setItem(3, createOption(functions, 3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> { - Main.getInstance().getBoard().remove(player); - PlayerLoader.unloadPlayer(player); - player.teleport(exitPosition); - })); - debugMenu.setItem(4, createOption(functions, 4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> { - if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){ - player.setHealth(0.1); - } - })); - debugMenu.setItem(6, createOption(functions, 6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> { - if(mapSaveEnabled) { - if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); - } - player.teleport(map.getGameSpawn()); - })); - debugMenu.setItem(7, createOption(functions, 7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> { - player.teleport(map.getLobby()); - })); - debugMenu.setItem(8, createOption(functions, 8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(exitPosition))); - debugMenu.setItem(9, createOption(functions, 9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> { - PlayerLoader.openBlockHuntPicker(player, map); - })); - debugMenu.setItem(10, createOption(functions, 10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player))); - debugMenuFunctions.put(sender, functions); - return debugMenu; - } - - private ItemStack createOption(Map> functions, int slow, Material material, String name, int amount, Consumer callback){ - ItemStack temp = new ItemStack(material, amount); - ItemMeta meta = temp.getItemMeta(); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); - temp.setItemMeta(meta); - functions.put(slow, callback); - return temp; - } - - public static void handleOption(Player player, int slotId){ - Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> { - Consumer callback = debugMenuFunctions.get(player).get(slotId); - if(callback != null) callback.accept(player); - }, 0); - } - - public String getLabel() { - return "debug"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Run debug commands"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java index 51bc509..9f8392f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java @@ -21,10 +21,7 @@ package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Config; -import net.tylermurphy.hideAndSeek.configuration.Items; -import net.tylermurphy.hideAndSeek.configuration.Localization; -import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.configuration.*; import net.tylermurphy.hideAndSeek.game.util.Status; import org.bukkit.entity.Player; @@ -42,10 +39,18 @@ public class Reload extends Command { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; } - Config.loadConfig(); - Maps.loadMaps(); - Localization.loadLocalization(); - Items.loadItems(); + + try { + Config.loadConfig(); + Maps.loadMaps(); + Localization.loadLocalization(); + Items.loadItems(); + Leaderboard.loadLeaderboard(); + } catch (Exception e) { + sender.sendMessage(errorPrefix + message("CONFIG_ERROR")); + return; + } + sender.sendMessage(messagePrefix + message("CONFIG_RELOAD")); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java new file mode 100644 index 0000000..9978c3c --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java @@ -0,0 +1,67 @@ +package net.tylermurphy.hideAndSeek.command; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Send extends Command { + + public void execute(Player sender, String[] args) { + + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + + if(map.isNotSetup()){ + sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP")); + return; + } + + if (!Main.getInstance().getBoard().contains(sender)) { + sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME")); + return; + } + + Main.getInstance().getGame().setCurrentMap(map); + for(Player player : Main.getInstance().getBoard().getPlayers()) { + player.teleport(map.getLobby()); + } + + } + + public String getLabel() { + return "send"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Set the current lobby to another map"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java new file mode 100644 index 0000000..874909b --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java @@ -0,0 +1,61 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; +import org.bukkit.entity.Player; + +import java.util.List; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; + +public class SetExitLocation extends Command { + + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.EXIT, null, map -> { + addToConfig("exit.x", sender.getLocation().getBlockX()); + addToConfig("exit.y", sender.getLocation().getBlockY()); + addToConfig("exit.z", sender.getLocation().getBlockZ()); + addToConfig("exit.world", sender.getLocation().getWorld().getName()); + exitPosition = sender.getLocation(); + exitWorld = sender.getLocation().getWorld().getName(); + saveConfig(); + }); + } + + public String getLabel() { + return "setexit"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Sets hide and seeks exit location to current position and world"; + } + + public List autoComplete(String parameter) { + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java index 54ad4af..674edd6 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java @@ -57,7 +57,7 @@ public class Start extends Command { if (args.length < 1) { Optional rand = Main.getInstance().getBoard().getPlayers().stream().skip(new Random().nextInt(Main.getInstance().getBoard().size())).findFirst(); if (!rand.isPresent()) { - Main.getInstance().getLogger().warning("Failed to select random seeker."); + sender.sendMessage(errorPrefix + message("START_FAILED_SEEKER")); return; } seekerName = rand.get().getName(); @@ -82,7 +82,7 @@ public class Start extends Command { } public String getUsage() { - return ""; + return "<*player>"; } public String getDescription() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java index 1582be9..7c8cabf 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java @@ -34,7 +34,7 @@ public class Stop extends Command { public void execute(Player sender, String[] args) { if (Main.getInstance().getGame().checkCurrentMap()) { - sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do"); + sender.sendMessage(errorPrefix + message("GAME_SETUP")); return; } if (Main.getInstance().getGame().getStatus() == Status.STARTING || Main.getInstance().getGame().getStatus() == Status.PLAYING) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java index 8116eaf..0a5358d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java @@ -76,7 +76,7 @@ public class Top extends Command { } public String getUsage() { - return ""; + return "<*page>"; } public String getDescription() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java new file mode 100644 index 0000000..5e4afb5 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java @@ -0,0 +1,53 @@ +package net.tylermurphy.hideAndSeek.command.location; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +/** + * @author bobby29831 + */ +public class LocationUtils { + + public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer consumer) { + + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + player.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + + if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){ + player.sendMessage(errorPrefix + message("NOT_AT_ZERO")); + return; + } + + Map map = null; + if(mapName != null) { + map = Maps.getMap(mapName); + if (map == null) { + player.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + } + + try { + consumer.accept(map); + } catch (Exception e) { + player.sendMessage(errorPrefix + e.getMessage()); + return; + } + + if(map != null) + Maps.setMap(mapName, map); + player.sendMessage(messagePrefix + message(place.message())); + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java new file mode 100644 index 0000000..dd73dac --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java @@ -0,0 +1,26 @@ +package net.tylermurphy.hideAndSeek.command.location; + +/** + * @author bobby29831 + */ +public enum Locations { + + GAME("spawns.game"), + LOBBY("spawns.lobby"), + EXIT("spawns.exit"), + SEEKER("spawns.seeker"); + + private final String path; + Locations(String path) { + this.path = path; + } + + public String message() { + return this + "_SPAWN"; + } + + public String path(String additive) { + return path + "." + additive; + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java deleted file mode 100644 index 01e1512..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.location; - -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; -import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import org.bukkit.entity.Player; - -import java.util.List; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; - -public class SetExitLocation extends Command { - - public void execute(Player sender, String[] args) { - LocationUtils.setLocation(sender, Locations.EXIT, null, map -> { - addToConfig("exit.x", sender.getLocation().getBlockX()); - addToConfig("exit.y", sender.getLocation().getBlockY()); - addToConfig("exit.z", sender.getLocation().getBlockZ()); - addToConfig("exit.world", sender.getLocation().getWorld().getName()); - exitPosition = sender.getLocation(); - exitWorld = sender.getLocation().getWorld().getName(); - saveConfig(); - }); - } - - public String getLabel() { - return "setexit"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Sets hide and seeks exit location to current position and world"; - } - - public List autoComplete(String parameter) { - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java deleted file mode 100644 index da41d91..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.location; - -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; -import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.stream.Collectors; - -public class SetLobbyLocation extends Command { - - public void execute(Player sender, String[] args) { - LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> { - map.setLobby(sender.getLocation()); - }); - } - - public String getLabel() { - return "lobby"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Sets hide and seeks lobby location to current position"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java deleted file mode 100644 index 8a5ebd1..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.location; - -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; -import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class SetSeekerLobbyLocation extends Command { - - public void execute(Player sender, String[] args) { - LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> { - if(map.isSpawnNotSetup()) { - throw new RuntimeException(message("GAME_SPAWN_NEEDED").toString()); - } - if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) { - throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString()); - } - map.setSeekerLobby(sender.getLocation()); - }); - } - - public String getLabel() { - return "seekerlobby"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Sets hide and seeks seeker lobby location to current position"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java deleted file mode 100644 index 82f71d1..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.location; - -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; -import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class SetSpawnLocation extends Command { - - public void execute(Player sender, String[] args) { - LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> { - - if (map.isWorldBorderEnabled() && - new Vector(sender.getLocation().getX(), 0, sender.getLocation().getZ()).distance(map.getWorldBorderPos()) > 100) { - sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION")); - throw new RuntimeException("World border not enabled or not in valid position!"); - } - - map.setSpawn(sender.getLocation()); - - if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().getName().equals(sender.getLocation().getWorld().getName())) { - sender.sendMessage(message("SEEKER_LOBBY_SPAWN_RESET").toString()); - map.setSeekerLobby(new Location(null, 0, 0, 0)); - } - - if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) { - map.getWorldLoader().unloadMap(); - } - }); - } - - public String getLabel() { - return "spawn"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Sets hide and seeks spawn location to current position"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java deleted file mode 100644 index 69d7c26..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.location.util; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -/** - * @author bobby29831 - */ -public class LocationUtils { - - public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer consumer) { - - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - player.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - - if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){ - player.sendMessage(errorPrefix + message("NOT_AT_ZERO")); - return; - } - - Map map = null; - if(mapName != null) { - map = Maps.getMap(mapName); - if (map == null) { - player.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - } - - try { - consumer.accept(map); - } catch (Exception e) { - player.sendMessage(errorPrefix + e.getMessage()); - return; - } - - if(map != null) - Maps.setMap(mapName, map); - player.sendMessage(messagePrefix + message(place.message())); - } - -} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java deleted file mode 100644 index 35f74ea..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.location.util; - -/** - * @author bobby29831 - */ -public enum Locations { - - GAME("spawns.game"), - LOBBY("spawns.lobby"), - EXIT("spawns.exit"), - SEEKER("spawns.seeker"); - - private final String path; - Locations(String path) { - this.path = path; - } - - public String message() { - return this + "_SPAWN"; - } - - public String path(String additive) { - return path + "." + additive; - } - -} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java new file mode 100644 index 0000000..03c2a95 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java @@ -0,0 +1,54 @@ +package net.tylermurphy.hideAndSeek.command.map; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.entity.Player; + +import java.util.Collections; +import java.util.List; + +import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; +import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Add extends Command { + + public void execute(Player sender, String[] args) { + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + Map map = Maps.getMap(args[0]); + if(map != null) { + sender.sendMessage(errorPrefix + message("MAP_ALREADY_EXISTS")); + } else if(!args[0].matches("[a-zA-Z0-9]*") || args[0].length() < 1) { + sender.sendMessage(errorPrefix + message("INVALID_MAP_NAME")); + } else { + Maps.setMap(args[0], new Map(args[0])); + sender.sendMessage(messagePrefix + message("MAP_CREATED").addAmount(args[0])); + } + } + + public String getLabel() { + return "add"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Add a map to the plugin!"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("name")) { + return Collections.singletonList("name"); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java deleted file mode 100644 index 55b4267..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; -import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class AddMap extends Command { - - public void execute(Player sender, String[] args) { - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - Map map = Maps.getMap(args[0]); - if(map != null) { - sender.sendMessage(errorPrefix + message("MAP_ALREADY_EXISTS")); - } else if(!args[0].matches("[a-zA-Z0-9]*") || args[0].length() < 1) { - sender.sendMessage(errorPrefix + message("INVALID_MAP_NAME")); - } else { - Maps.setMap(args[0], new Map(args[0])); - sender.sendMessage(messagePrefix + message("MAP_CREATED").addAmount(args[0])); - } - } - - public String getLabel() { - return "add"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Add a map to the plugin!"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("name")) { - return Collections.singletonList("name"); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java new file mode 100644 index 0000000..2ec0525 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java @@ -0,0 +1,130 @@ +package net.tylermurphy.hideAndSeek.command.map; + +import com.cryptomorin.xseries.XMaterial; +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.PlayerLoader; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Debug extends Command { + + private static final Map>> debugMenuFunctions = new HashMap<>(); + + public void execute(Player sender, String[] args) { + net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + Inventory debugMenu = createMenu(map, sender); + sender.openInventory(debugMenu); + } + + private Inventory createMenu(net.tylermurphy.hideAndSeek.configuration.Map map, Player sender){ + Map> functions = new HashMap<>(); + Inventory debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu"); + debugMenu.setItem(0, createOption(functions, 0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> { + if(mapSaveEnabled) { + if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); + } + Main.getInstance().getBoard().addHider(player); + PlayerLoader.loadHider(player, map); + if(Main.getInstance().getGame().getStatus() != Status.STARTING) + PlayerLoader.resetPlayer(player, Main.getInstance().getBoard()); + })); + debugMenu.setItem(1, createOption(functions, 1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> { + if(mapSaveEnabled) { + if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); + } + Main.getInstance().getBoard().addSeeker(player); + PlayerLoader.loadSeeker(player, map); + if(Main.getInstance().getGame().getStatus() != Status.STARTING) + PlayerLoader.resetPlayer(player, Main.getInstance().getBoard()); + })); + debugMenu.setItem(2, createOption(functions, 2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> { + if(mapSaveEnabled) { + if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); + } + Main.getInstance().getBoard().addSpectator(player); + PlayerLoader.loadSpectator(player, map); + })); + debugMenu.setItem(3, createOption(functions, 3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> { + Main.getInstance().getBoard().remove(player); + PlayerLoader.unloadPlayer(player); + player.teleport(exitPosition); + })); + debugMenu.setItem(4, createOption(functions, 4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> { + if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){ + player.setHealth(0.1); + } + })); + debugMenu.setItem(6, createOption(functions, 6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> { + if(mapSaveEnabled) { + if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap(); + } + player.teleport(map.getGameSpawn()); + })); + debugMenu.setItem(7, createOption(functions, 7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> { + player.teleport(map.getLobby()); + })); + debugMenu.setItem(8, createOption(functions, 8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(exitPosition))); + debugMenu.setItem(9, createOption(functions, 9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> { + PlayerLoader.openBlockHuntPicker(player, map); + })); + debugMenu.setItem(10, createOption(functions, 10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player))); + debugMenuFunctions.put(sender, functions); + return debugMenu; + } + + private ItemStack createOption(Map> functions, int slow, Material material, String name, int amount, Consumer callback){ + ItemStack temp = new ItemStack(material, amount); + ItemMeta meta = temp.getItemMeta(); + meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); + temp.setItemMeta(meta); + functions.put(slow, callback); + return temp; + } + + public static void handleOption(Player player, int slotId){ + Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> { + Consumer callback = debugMenuFunctions.get(player).get(slotId); + if(callback != null) callback.accept(player); + }, 0); + } + + public String getLabel() { + return "debug"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Run debug commands"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java new file mode 100644 index 0000000..8e74922 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java @@ -0,0 +1,63 @@ +package net.tylermurphy.hideAndSeek.command.map; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; +import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class GoTo extends Command { + + public void execute(Player sender, String[] args) { + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + if (map.isNotSetup()) { + sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP").addAmount(map.getName())); + return; + } + switch (args[1].toLowerCase()) { + case "spawn": + sender.teleport(map.getSpawn()); break; + case "lobby": + sender.teleport(map.getLobby()); break; + case "seekerlobby": + sender.teleport(map.getSeekerLobby()); break; + case "exit": + sender.teleport(exitPosition); break; + default: + sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase())); + } + } + + public String getLabel() { + return "goto"; + } + + public String getUsage() { + return " "; + } + + public String getDescription() { + return "Get the commands for the plugin"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } else if(parameter != null && parameter.equals("spawn")) { + return Arrays.asList("spawn","lobby","seekerlobby","exit"); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java new file mode 100644 index 0000000..635c011 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java @@ -0,0 +1,46 @@ +package net.tylermurphy.hideAndSeek.command.map; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.util.Collection; + +import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; +import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class List extends Command { + + public void execute(Player sender, String[] args) { + Collection maps = Maps.getAllMaps(); + if(maps.size() < 1) { + sender.sendMessage(errorPrefix + message("NO_MAPS")); + return; + } + StringBuilder response = new StringBuilder(messagePrefix + message("LIST_MAPS")); + for(Map map : maps) { + response.append("\n ").append(map.getName()).append(": ").append(map.isNotSetup() ? ChatColor.RED + "NOT SETUP" : ChatColor.GREEN + "SETUP").append(ChatColor.WHITE); + } + sender.sendMessage(response.toString()); + } + + public String getLabel() { + return "list"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "List all maps in the plugin"; + } + + public java.util.List autoComplete(String parameter) { + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java deleted file mode 100644 index 79490a7..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -import java.util.Collection; -import java.util.List; - -import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; -import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class ListMaps extends Command { - - public void execute(Player sender, String[] args) { - Collection maps = Maps.getAllMaps(); - if(maps.size() < 1) { - sender.sendMessage(errorPrefix + message("NO_MAPS")); - return; - } - StringBuilder response = new StringBuilder(messagePrefix + message("LIST_MAPS")); - for(Map map : maps) { - response.append("\n ").append(map.getName()).append(": ").append(map.isNotSetup() ? ChatColor.RED + "NOT SETUP" : ChatColor.GREEN + "SETUP").append(ChatColor.WHITE); - } - sender.sendMessage(response.toString()); - } - - public String getLabel() { - return "list"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "List all maps in the plugin"; - } - - public List autoComplete(String parameter) { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java new file mode 100644 index 0000000..45dec99 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java @@ -0,0 +1,53 @@ +package net.tylermurphy.hideAndSeek.command.map; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; +import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Remove extends Command { + + public void execute(Player sender, String[] args) { + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + } else if(!Maps.removeMap(args[0])){ + sender.sendMessage(errorPrefix + message("MAP_FAIL_DELETE").addAmount(args[0])); + } else { + sender.sendMessage(messagePrefix + message("MAP_DELETED").addAmount(args[0])); + } + } + + public String getLabel() { + return "remove"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Remove a map from the plugin!"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java deleted file mode 100644 index 216cca9..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; -import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class RemoveMap extends Command { - - public void execute(Player sender, String[] args) { - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - } else if(!Maps.removeMap(args[0])){ - sender.sendMessage(errorPrefix + message("MAP_FAIL_DELETE").addAmount(args[0])); - } else { - sender.sendMessage(messagePrefix + message("MAP_DELETED").addAmount(args[0])); - } - } - - public String getLabel() { - return "remove"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Remove a map from the plugin!"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java new file mode 100644 index 0000000..b93250f --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java @@ -0,0 +1,98 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command.map; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Save extends Command { + + public static boolean runningBackup = false; + + public void execute(Player sender, String[] args) { + if (!mapSaveEnabled) { + sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED")); + return; + } + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + if (map.isSpawnNotSetup()) { + sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); + return; + } + sender.sendMessage(messagePrefix + message("MAPSAVE_START")); + sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING")); + World world = map.getSpawn().getWorld(); + if (world == null) { + sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD")); + return; + } + world.save(); + BukkitRunnable runnable = new BukkitRunnable() { + public void run() { + sender.sendMessage( + map.getWorldLoader().save() + ); + runningBackup = false; + } + }; + runnable.runTaskAsynchronously(Main.getInstance()); + runningBackup = true; + } + + public String getLabel() { + return "save"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Saves current map for the game. May lag server."; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java deleted file mode 100644 index f3eb4d7..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class SaveMap extends Command { - - public static boolean runningBackup = false; - - public void execute(Player sender, String[] args) { - if (!mapSaveEnabled) { - sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED")); - return; - } - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - if (map.isSpawnNotSetup()) { - sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); - return; - } - sender.sendMessage(messagePrefix + message("MAPSAVE_START")); - sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING")); - World world = map.getSpawn().getWorld(); - if (world == null) { - throw new RuntimeException("Unable to get spawn world"); - } - world.save(); - BukkitRunnable runnable = new BukkitRunnable() { - public void run() { - sender.sendMessage( - map.getWorldLoader().save() - ); - runningBackup = false; - } - }; - runnable.runTaskAsynchronously(Main.getInstance()); - runningBackup = true; - } - - public String getLabel() { - return "save"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Saves current map for the game. May lag server."; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java deleted file mode 100644 index 8362e02..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class SetBorder extends Command { - - public void execute(Player sender, String[] args) { - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - if (map.isSpawnNotSetup()) { - sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); - return; - } - if (args.length < 4) { - map.setWorldBorderData(0, 0, 0, 0, 0); - addToConfig("worldBorder.enabled",false); - saveConfig(); - sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE")); - Main.getInstance().getGame().getCurrentMap().getWorldBorder().resetWorldBorder(); - return; - } - int num,delay,change; - try { num = Integer.parseInt(args[1]); } catch (Exception e) { - sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0])); - return; - } - try { delay = Integer.parseInt(args[2]); } catch (Exception e) { - sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[1])); - return; - } - try { change = Integer.parseInt(args[3]); } catch (Exception e) { - sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[2])); - return; - } - if (num < 100) { - sender.sendMessage(errorPrefix + message("WORLDBORDER_MIN_SIZE")); - return; - } - if (change < 1) { - sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE")); - return; - } - map.setWorldBorderData( - sender.getLocation().getBlockX(), - sender.getLocation().getBlockZ(), - num, - delay, - change - ); - Maps.setMap(map.getName(), map); - sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay)); - map.getWorldBorder().resetWorldBorder(); - } - - public String getLabel() { - return "border"; - } - - public String getUsage() { - return " <*size> <*delay> <*move>"; - } - - public String getDescription() { - return "Sets worldboarder's center location, size in blocks, and delay in minutes per shrink. Add no arguments to disable."; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return Collections.singletonList(parameter); - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java deleted file mode 100644 index 92bf5a4..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class SetBounds extends Command { - - public void execute(Player sender, String[] args) { - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - if (map.isSpawnNotSetup()) { - sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); - return; - } - if (!sender.getWorld().getName().equals(map.getSpawnName())) { - sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD")); - return; - } - if (sender.getLocation().getBlockX() == 0 || sender.getLocation().getBlockZ() == 0) { - sender.sendMessage(errorPrefix + message("NOT_AT_ZERO")); - return; - } - boolean first = true; - int bxs = map.getBoundsMin().getBlockX(); - int bzs = map.getBoundsMin().getBlockZ(); - int bxl = map.getBoundsMax().getBlockX(); - int bzl = map.getBoundsMax().getBlockZ(); - if (bxs != 0 && bzs != 0 && bxl != 0 && bzl != 0) { - bxs = bzs = bxl = bzl = 0; - } - if (bxl == 0) { - bxl = sender.getLocation().getBlockX(); - } else if (map.getBoundsMax().getX() < sender.getLocation().getBlockX()) { - first = false; - bxs = bxl; - bxl = sender.getLocation().getBlockX(); - } else { - first = false; - bxs = sender.getLocation().getBlockX(); - } - if (bzl == 0) { - bzl = sender.getLocation().getBlockZ(); - } else if (map.getBoundsMax().getZ() < sender.getLocation().getBlockZ()) { - first = false; - bzs = bzl; - bzl = sender.getLocation().getBlockZ(); - } else { - first = false; - bzs = sender.getLocation().getBlockZ(); - } - map.setBoundMin(bxs, bzs); - map.setBoundMax(bxl, bzl); - Maps.setMap(map.getName(), map); - sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2)); - } - - public String getLabel() { - return "bounds"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Sets the map bounds for the game."; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java deleted file mode 100644 index 2df5824..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import net.tylermurphy.hideAndSeek.game.util.Status; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class SetMap extends Command { - - public void execute(Player sender, String[] args) { - - if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { - sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); - return; - } - - Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - - if(map.isNotSetup()){ - sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP")); - return; - } - - if (!Main.getInstance().getBoard().contains(sender)) { - sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME")); - return; - } - - Main.getInstance().getGame().setCurrentMap(map); - for(Player player : Main.getInstance().getBoard().getPlayers()) { - player.teleport(map.getLobby()); - } - - } - - public String getLabel() { - return "goto"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Set the current lobby to another map"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java deleted file mode 100644 index 46b41f7..0000000 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package net.tylermurphy.hideAndSeek.command.map; - -import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.util.Command; -import net.tylermurphy.hideAndSeek.configuration.Map; -import net.tylermurphy.hideAndSeek.configuration.Maps; -import org.bukkit.entity.Player; - -import java.io.File; -import java.util.List; -import java.util.stream.Collectors; - -import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import static net.tylermurphy.hideAndSeek.configuration.Localization.message; - -public class Setup extends Command { - - public void execute(Player sender, String[] args) { - - String msg = message("SETUP").toString(); - int count = 0; - Map map = Maps.getMap(args[0]); - if(map == null) { - sender.sendMessage(errorPrefix + message("INVALID_MAP")); - return; - } - if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) { - msg = msg + "\n" + message("SETUP_GAME"); - count++; - } - if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) { - msg = msg + "\n" + message("SETUP_LOBBY"); - count++; - } - if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !Map.worldExists(map.getSeekerLobbyName())) { - msg = msg + "\n" + message("SETUP_SEEKER_LOBBY"); - count++; - } - if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !Map.worldExists(exitWorld)) { - msg = msg + "\n" + message("SETUP_EXIT"); - count++; - } - if (map.getBoundsMin().getBlockX() == 0 || map.getBoundsMin().getBlockZ() == 0 || - map.getBoundsMax().getBlockX() == 0 || map.getBoundsMax().getBlockX() == 0) { - msg = msg + "\n" + message("SETUP_BOUNDS"); - count++; - } - if (mapSaveEnabled && !Map.worldExists(map.getGameSpawnName())) { - msg = msg + "\n" + message("SETUP_SAVEMAP"); - count++; - } - if (count < 1) { - sender.sendMessage(messagePrefix + message("SETUP_COMPLETE")); - } else { - sender.sendMessage(msg); - } - } - - public String getLabel() { - return "setup"; - } - - public String getUsage() { - return ""; - } - - public String getDescription() { - return "Shows what needs to be setup"; - } - - public List autoComplete(String parameter) { - if(parameter != null && parameter.equals("map")) { - return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); - } - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java new file mode 100644 index 0000000..29442c1 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java @@ -0,0 +1,95 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command.map; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Status extends Command { + + public void execute(Player sender, String[] args) { + + String msg = message("SETUP").toString(); + int count = 0; + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) { + msg = msg + "\n" + message("SETUP_GAME"); + count++; + } + if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) { + msg = msg + "\n" + message("SETUP_LOBBY"); + count++; + } + if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !Map.worldExists(map.getSeekerLobbyName())) { + msg = msg + "\n" + message("SETUP_SEEKER_LOBBY"); + count++; + } + if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !Map.worldExists(exitWorld)) { + msg = msg + "\n" + message("SETUP_EXIT"); + count++; + } + if (map.getBoundsMin().getBlockX() == 0 || map.getBoundsMin().getBlockZ() == 0 || + map.getBoundsMax().getBlockX() == 0 || map.getBoundsMax().getBlockX() == 0) { + msg = msg + "\n" + message("SETUP_BOUNDS"); + count++; + } + if (mapSaveEnabled && !Map.worldExists(map.getGameSpawnName())) { + msg = msg + "\n" + message("SETUP_SAVEMAP"); + count++; + } + if (count < 1) { + sender.sendMessage(messagePrefix + message("SETUP_COMPLETE")); + } else { + sender.sendMessage(msg); + } + } + + public String getLabel() { + return "status"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Shows what needs to be setup"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java new file mode 100644 index 0000000..9d47390 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java @@ -0,0 +1,43 @@ +package net.tylermurphy.hideAndSeek.command.map.blockhunt; + +import net.tylermurphy.hideAndSeek.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class Enabled extends Command { + + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> { + map.setLobby(sender.getLocation()); + }); + } + + public String getLabel() { + return "enabled"; + } + + public String getUsage() { + return " "; + } + + public String getDescription() { + return "Sets hide and seeks lobby location to current position"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + if(parameter != null && parameter.equals("bool")) { + return Arrays.asList("true", "false"); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java new file mode 100644 index 0000000..92339b4 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java @@ -0,0 +1,112 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command.map.set; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.entity.Player; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Border extends Command { + + public void execute(Player sender, String[] args) { + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + if (map.isSpawnNotSetup()) { + sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); + return; + } + if (args.length < 4) { + map.setWorldBorderData(0, 0, 0, 0, 0); + addToConfig("worldBorder.enabled",false); + saveConfig(); + sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE")); + Main.getInstance().getGame().getCurrentMap().getWorldBorder().resetWorldBorder(); + return; + } + int num,delay,change; + try { num = Integer.parseInt(args[1]); } catch (Exception e) { + sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0])); + return; + } + try { delay = Integer.parseInt(args[2]); } catch (Exception e) { + sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[1])); + return; + } + try { change = Integer.parseInt(args[3]); } catch (Exception e) { + sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[2])); + return; + } + if (num < 100) { + sender.sendMessage(errorPrefix + message("WORLDBORDER_MIN_SIZE")); + return; + } + if (change < 1) { + sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE")); + return; + } + map.setWorldBorderData( + sender.getLocation().getBlockX(), + sender.getLocation().getBlockZ(), + num, + delay, + change + ); + Maps.setMap(map.getName(), map); + sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay).addAmount(change)); + map.getWorldBorder().resetWorldBorder(); + } + + public String getLabel() { + return "border"; + } + + public String getUsage() { + return " <*size> <*delay> <*move>"; + } + + public String getDescription() { + return "Sets worldboarder's center location, size in blocks, and delay in minutes per shrink. Add no arguments to disable."; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return Collections.singletonList(parameter); + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java new file mode 100644 index 0000000..9896389 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java @@ -0,0 +1,112 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command.map.set; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.configuration.Map; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import net.tylermurphy.hideAndSeek.game.util.Status; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Bounds extends Command { + + public void execute(Player sender, String[] args) { + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); + return; + } + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(errorPrefix + message("INVALID_MAP")); + return; + } + if (map.isSpawnNotSetup()) { + sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); + return; + } + if (!sender.getWorld().getName().equals(map.getSpawnName())) { + sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD")); + return; + } + if (sender.getLocation().getBlockX() == 0 || sender.getLocation().getBlockZ() == 0) { + sender.sendMessage(errorPrefix + message("NOT_AT_ZERO")); + return; + } + boolean first = true; + int bxs = map.getBoundsMin().getBlockX(); + int bzs = map.getBoundsMin().getBlockZ(); + int bxl = map.getBoundsMax().getBlockX(); + int bzl = map.getBoundsMax().getBlockZ(); + if (bxs != 0 && bzs != 0 && bxl != 0 && bzl != 0) { + bxs = bzs = bxl = bzl = 0; + } + if (bxl == 0) { + bxl = sender.getLocation().getBlockX(); + } else if (map.getBoundsMax().getX() < sender.getLocation().getBlockX()) { + first = false; + bxs = bxl; + bxl = sender.getLocation().getBlockX(); + } else { + first = false; + bxs = sender.getLocation().getBlockX(); + } + if (bzl == 0) { + bzl = sender.getLocation().getBlockZ(); + } else if (map.getBoundsMax().getZ() < sender.getLocation().getBlockZ()) { + first = false; + bzs = bzl; + bzl = sender.getLocation().getBlockZ(); + } else { + first = false; + bzs = sender.getLocation().getBlockZ(); + } + map.setBoundMin(bxs, bzs); + map.setBoundMax(bxl, bzl); + Maps.setMap(map.getName(), map); + sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2)); + } + + public String getLabel() { + return "bounds"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Sets the map bounds for the game."; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java new file mode 100644 index 0000000..c691787 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java @@ -0,0 +1,58 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command.map.set; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +public class Lobby extends Command { + + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> { + map.setLobby(sender.getLocation()); + }); + } + + public String getLabel() { + return "lobby"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Sets hide and seeks lobby location to current position"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java new file mode 100644 index 0000000..2521f19 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java @@ -0,0 +1,47 @@ +package net.tylermurphy.hideAndSeek.command.map.set; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class SeekerLobby extends Command { + + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> { + if(map.isSpawnNotSetup()) { + throw new RuntimeException(message("GAME_SPAWN_NEEDED").toString()); + } + if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) { + throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString()); + } + map.setSeekerLobby(sender.getLocation()); + }); + } + + public String getLabel() { + return "seekerlobby"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Sets hide and seeks seeker lobby location to current position"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java new file mode 100644 index 0000000..3e8f77e --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java @@ -0,0 +1,79 @@ +/* + * This file is part of Kenshins Hide and Seek + * + * Copyright (c) 2021 Tyler Murphy. + * + * Kenshins Hide and Seek free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * he Free Software Foundation version 3. + * + * Kenshins Hide and Seek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.tylermurphy.hideAndSeek.command.map.set; + +import net.tylermurphy.hideAndSeek.command.util.Command; +import net.tylermurphy.hideAndSeek.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; +import net.tylermurphy.hideAndSeek.configuration.Maps; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import java.util.List; +import java.util.stream.Collectors; + +import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; + +public class Spawn extends Command { + + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> { + + if (map.isWorldBorderEnabled() && + new Vector(sender.getLocation().getX(), 0, sender.getLocation().getZ()).distance(map.getWorldBorderPos()) > 100) { + sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION")); + throw new RuntimeException("World border not enabled or not in valid position!"); + } + + map.setSpawn(sender.getLocation()); + + if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().getName().equals(sender.getLocation().getWorld().getName())) { + sender.sendMessage(message("SEEKER_LOBBY_SPAWN_RESET").toString()); + map.setSeekerLobby(new Location(null, 0, 0, 0)); + } + + if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) { + map.getWorldLoader().unloadMap(); + } + }); + } + + public String getLabel() { + return "spawn"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Sets hide and seeks spawn location to current position"; + } + + public List autoComplete(String parameter) { + if(parameter != null && parameter.equals("map")) { + return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList()); + } + return null; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java index 9079ccc..e7f43eb 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java @@ -20,7 +20,8 @@ package net.tylermurphy.hideAndSeek.command.util; import net.tylermurphy.hideAndSeek.command.*; -import net.tylermurphy.hideAndSeek.command.map.SaveMap; +import net.tylermurphy.hideAndSeek.command.map.Save; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -38,7 +39,7 @@ public class CommandGroup { public CommandGroup(String label, Object... data) { this.label = label; - this.commandRegister = new HashMap<>(); + this.commandRegister = new LinkedHashMap<>(); for(Object o : data) registerCommand(o); } @@ -65,11 +66,15 @@ public class CommandGroup { if (permissionsRequired && !player.hasPermission("hs.about")) { player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED")); } else { - new About().execute(player, null); + player.sendMessage( + String.format("%s%sHide and Seek %s(%s1.7.0 ALPHA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + + String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) + + String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE) + ); } } else { String invoke = args[0].toLowerCase(); - if (!invoke.equals("about") && !invoke.equals("help") && SaveMap.runningBackup) { + if (!invoke.equals("about") && !invoke.equals("help") && Save.runningBackup) { player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS")); } else if (permissionsRequired && !player.hasPermission(permission+"."+invoke)) { player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED")); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java index 3a43e15..0000c30 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java @@ -101,7 +101,6 @@ public class Config { lobbyItemStartPosition, flightToggleItemPosition, teleportItemPosition, - solidifyTime, delayedRespawnDelay; public static float @@ -113,24 +112,6 @@ public class Config { blockedCommands, blockedInteracts; - public static String - LOBBY_TITLE, - GAME_TITLE, - COUNTDOWN_WAITING, - COUNTDOWN_COUNTING, - COUNTDOWN_ADMINSTART, - TAUNT_COUNTING, - TAUNT_ACTIVE, - TAUNT_EXPIRED, - GLOW_ACTIVE, - GLOW_INACTIVE, - BORDER_COUNTING, - BORDER_DECREASING; - - public static List - LOBBY_CONTENTS, - GAME_CONTENTS; - public static ItemStack lobbyLeaveItem, lobbyStartItem, @@ -152,7 +133,6 @@ public class Config { config = ConfigManager.create("config.yml"); config.saveConfig(); - ConfigManager leaderboard = ConfigManager.create("leaderboard.yml"); announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers"); @@ -247,25 +227,6 @@ public class Config { } bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy"); leaveServer = config.getString("leaveServer"); - solidifyTime = Math.max(20,config.getInt("blockhunt.solidifyTime")); - - //Leaderboard - LOBBY_TITLE = leaderboard.getString("lobby.title"); - GAME_TITLE = leaderboard.getString("game.title"); - LOBBY_CONTENTS = leaderboard.getStringList("lobby.content"); - Collections.reverse(LOBBY_CONTENTS); - GAME_CONTENTS = leaderboard.getStringList("game.content"); - Collections.reverse(GAME_CONTENTS); - COUNTDOWN_WAITING = leaderboard.getString("countdown.waiting"); - COUNTDOWN_COUNTING = leaderboard.getString("countdown.counting"); - COUNTDOWN_ADMINSTART = leaderboard.getString("countdown.adminStart"); - TAUNT_COUNTING = leaderboard.getString("taunt.counting"); - TAUNT_ACTIVE = leaderboard.getString("taunt.active"); - TAUNT_EXPIRED = leaderboard.getString("taunt.expired"); - GLOW_ACTIVE = leaderboard.getString("glow.active"); - GLOW_INACTIVE = leaderboard.getString("glow.inactive"); - BORDER_COUNTING = leaderboard.getString("border.counting"); - BORDER_DECREASING = leaderboard.getString("border.decreasing"); //Lobby Items if (config.getBoolean("lobbyItems.leave.enabled")) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java index e09001e..b7671c2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java @@ -93,6 +93,7 @@ public class ConfigManager { try { this.config.load(reader); } catch(InvalidConfigurationException e) { + Main.getInstance().getLogger().severe(e.getMessage()); throw new RuntimeException("Invalid configuration in config file: "+file.getPath()); } catch(IOException e) { throw new RuntimeException("Could not access file: "+file.getPath()); @@ -107,9 +108,10 @@ public class ConfigManager { try { this.defaultConfig.load(default_reader); } catch(InvalidConfigurationException e) { - throw new RuntimeException("Invalid configuration in config file: "+file.getPath()); + Main.getInstance().getLogger().severe(e.getMessage()); + throw new RuntimeException("Invalid configuration in internal config file: "+defaultFilename); } catch(IOException e) { - throw new RuntimeException("Could not access file: "+file.getPath()); + throw new RuntimeException("Could not access internal file: "+defaultFilename); } try{ @@ -240,69 +242,110 @@ public class ConfigManager { public void saveConfig() { try { + // open config file InputStream is = Main.getInstance().getResource(defaultFilename); + // if failed error if (is == null) { throw new RuntimeException("Could not create input stream for "+defaultFilename); } + // manually read in each character to preserve string data StringBuilder textBuilder = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8)); Reader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); int c; - while((c = reader.read()) != -1) { + while((c = reader.read()) != -1) textBuilder.append((char) c); - } - String yamlString = new String(textBuilder.toString().getBytes(), StandardCharsets.UTF_8); - Map temp = config.getValues(true); - for(Map.Entry entry: temp.entrySet()) { - if (entry.getValue() instanceof Integer || entry.getValue() instanceof Double || entry.getValue() instanceof String || entry.getValue() instanceof Boolean || entry.getValue() instanceof List) { - String[] parts = entry.getKey().split("\\."); - int index = 0; - int i = 0; - for(String part : parts) { - if (i == 0) { - index = yamlString.indexOf(part+":", index); - } else { - index = yamlString.indexOf(" " + part+":", index); - index++; - } - i++; - if (index == -1) break; - } - if (index < 10) continue; - int start = yamlString.indexOf(' ', index); - int end = yamlString.indexOf('\n', index); - if (end == -1) end = yamlString.length(); - StringBuilder replace = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8)); - if (entry.getValue() instanceof List) { - if (((List) entry.getValue()).isEmpty()) { - replace.append("[]"); - } else { - replace.append("["); - for (Object o : (List) entry.getValue()) { - replace.append(o.toString()).append(", "); - } - replace = new StringBuilder(replace.substring(0, replace.length() - 2)); - replace.append("]"); - } + // store yaml file into a string + String yaml = new String(textBuilder.toString().getBytes(), StandardCharsets.UTF_8); + // get config values + Map data = config.getValues(true); + // write each stored config value into the yaml string + for(Map.Entry entry: data.entrySet()) { + // if type isn't supported, skip + if(!isSupported(entry.getValue())) continue; + // get index of key in yaml string + int index = getIndex(yaml, entry.getKey()); + // if index not found, skip + if (index < 10) continue; + // get start and end of the value + int start = yaml.indexOf(' ', index) + 1; + int end = yaml.indexOf('\n', index); + // if end not found, set it to the end of the file + if (end == -1) end = yaml.length(); + // create new replace sting + StringBuilder replace = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8)); + // get value + Object value = entry.getValue(); + // if the value is a list, + if (value instanceof List) { + end = yaml.indexOf(']', start) + 1; + List list = (List) entry.getValue(); + if (list.isEmpty()) { + // if list is empty, put an empty list + replace.append("[]"); } else { - replace.append(entry.getValue()); - } - if (entry.getValue() instanceof String) { - replace.append("\""); - replace.reverse(); - replace.append("\""); - replace.reverse(); + // if list has values, populate values into the string + // get gap before key + int gap = whitespaceBefore(yaml, index); + String space = new String(new char[gap]).replace('\0', ' '); + replace.append("[\n"); + for (int i = 0; i < list.size(); i++) { + replace.append(space).append(" ").append(convert(list.get(i))); + if(i != list.size() -1) replace.append(",\n"); + } + replace.append('\n').append(space).append("]"); } - StringBuilder builder = new StringBuilder(yamlString); - builder.replace(start+1, end, replace.toString()); - yamlString = builder.toString(); + // otherwise just put the value directly + } else { + replace.append(convert(value)); } + // replace the new value in the yaml string + StringBuilder builder = new StringBuilder(yaml); + builder.replace(start, end, replace.toString()); + yaml = builder.toString(); } + + // write yaml string to file Writer fileWriter = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8)); - fileWriter.write(yamlString); + fileWriter.write(yaml); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } } + private int getIndex(String yaml, String key) { + String[] parts = key.split("\\."); + int index = 0; + for(String part : parts) { + if (index == 0) { + index = yaml.indexOf(part + ":", index); + } else { + index = yaml.indexOf(" " + part + ":", index) + 1; + } + if (index == -1) break; + } + return index; + } + + public boolean isSupported(Object o) { + return o instanceof Integer || + o instanceof Double || + o instanceof String || + o instanceof Boolean || + o instanceof List; + } + + public int whitespaceBefore(String yaml, int index) { + int count = 0; + for(int i = index - 1; yaml.charAt(i) == ' '; i--) count++; + return count; + } + + private String convert(Object o) { + if(o instanceof String) { + return "\"" + o + "\""; + } + return o.toString(); + } + } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Leaderboard.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Leaderboard.java new file mode 100644 index 0000000..63dc850 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Leaderboard.java @@ -0,0 +1,51 @@ +package net.tylermurphy.hideAndSeek.configuration; + +import java.util.Collections; +import java.util.List; + +public class Leaderboard { + + public static String + LOBBY_TITLE, + GAME_TITLE, + COUNTDOWN_WAITING, + COUNTDOWN_COUNTING, + COUNTDOWN_ADMINSTART, + TAUNT_COUNTING, + TAUNT_ACTIVE, + TAUNT_EXPIRED, + GLOW_ACTIVE, + GLOW_INACTIVE, + BORDER_COUNTING, + BORDER_DECREASING; + + public static List + LOBBY_CONTENTS, + GAME_CONTENTS; + + public static void loadLeaderboard() { + + ConfigManager leaderboard = ConfigManager.create("leaderboard.yml"); + + LOBBY_TITLE = leaderboard.getString("lobby.title"); + GAME_TITLE = leaderboard.getString("game.title"); + LOBBY_CONTENTS = leaderboard.getStringList("lobby.content"); + Collections.reverse(LOBBY_CONTENTS); + GAME_CONTENTS = leaderboard.getStringList("game.content"); + Collections.reverse(GAME_CONTENTS); + COUNTDOWN_WAITING = leaderboard.getString("countdown.waiting"); + COUNTDOWN_COUNTING = leaderboard.getString("countdown.counting"); + COUNTDOWN_ADMINSTART = leaderboard.getString("countdown.adminStart"); + TAUNT_COUNTING = leaderboard.getString("taunt.counting"); + TAUNT_ACTIVE = leaderboard.getString("taunt.active"); + TAUNT_EXPIRED = leaderboard.getString("taunt.expired"); + GLOW_ACTIVE = leaderboard.getString("glow.active"); + GLOW_INACTIVE = leaderboard.getString("glow.inactive"); + BORDER_COUNTING = leaderboard.getString("border.counting"); + BORDER_DECREASING = leaderboard.getString("border.decreasing"); + + leaderboard.saveConfig(); + + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java index 9418414..72ab366 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java @@ -31,7 +31,7 @@ public class Localization { public static final Map DEFAULT_LOCAL = new HashMap<>(); private static final Map CHANGES = new HashMap() {{ - put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"}}); + put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"},{"GAME_SETUP"}}); put("de-DE", new String[][]{{},{"TAUNTED"}}); }}; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java index 18cad40..83fc2a6 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java @@ -33,6 +33,7 @@ import java.util.*; import java.util.stream.Collectors; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Leaderboard.*; import static net.tylermurphy.hideAndSeek.configuration.Localization.message; public class Board { @@ -218,7 +219,9 @@ public class Board { } else if (line.contains("{SEEKER%}")) { board.setLine(String.valueOf(i), line.replace("{SEEKER%}", getSeekerPercent()+"")); } else if (line.contains("{HIDER%}")) { - board.setLine(String.valueOf(i), line.replace("{HIDER%}", getHiderPercent()+"")); + board.setLine(String.valueOf(i), line.replace("{HIDER%}", getHiderPercent() + "")); + } else if (line.contains("{MAP}")) { + board.setLine(String.valueOf(i), line.replace("{MAP}", getMapName() + "")); } else { board.setLine(String.valueOf(i), line); } @@ -228,6 +231,12 @@ public class Board { customBoards.put(player.getUniqueId().toString(), board); } + public String getMapName() { + net.tylermurphy.hideAndSeek.configuration.Map map = Main.getInstance().getGame().getCurrentMap(); + if(map == null) return "Invalid"; + else return map.getName(); + } + public void createGameBoard(Player player) { createGameBoard(player, true); } @@ -288,6 +297,8 @@ public class Board { board.setLine(String.valueOf(i), line.replace("{#SEEKER}", getSeekers().size()+"")); } else if (line.contains("{#HIDER}")) { board.setLine(String.valueOf(i), line.replace("{#HIDER}", getHiders().size()+"")); + } else if (line.contains("{MAP}")) { + board.setLine(String.valueOf(i), line.replace("{MAP}", getMapName() + "")); } else { board.setLine(String.valueOf(i), line); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java index dabb735..5fce7d3 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java @@ -1,6 +1,7 @@ package net.tylermurphy.hideAndSeek.game; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.game.util.Disguise; @@ -49,7 +50,7 @@ public class Disguiser { public void disguise(Player player, Material material, Map map){ if(!map.isBlockHuntEnabled()){ - player.sendMessage(errorPrefix + "Please enable blockhunt in this map inside maps.yml to enable disguises. Blockhunt does not work on 1.8"); + player.sendMessage(errorPrefix + message("BLOCKHUNT_DISABLED")); return; } if(disguises.containsKey(player)){ diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java index 27a6235..27347c2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java @@ -11,7 +11,7 @@ public class ChatHandler implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onChat(AsyncPlayerChatEvent event) { - if (Main.getInstance().getBoard().isSeeker(event.getPlayer())) { + if (Main.getInstance().getBoard().isSpectator(event.getPlayer())) { event.setCancelled(true); Main.getInstance().getBoard().getSpectators().forEach(spectator -> spectator.sendMessage(ChatColor.GRAY + "[SPECTATOR] " + event.getPlayer().getName() + ": " + event.getMessage())); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java index cb8ad04..c80e83f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java @@ -1,7 +1,6 @@ package net.tylermurphy.hideAndSeek.game.listener; import static com.comphenix.protocol.PacketType.Play.Client.*; -import static net.tylermurphy.hideAndSeek.configuration.Config.solidifyTime; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; @@ -42,7 +41,7 @@ public class DisguiseHandler implements Listener { if(lastLocation.getWorld() != currentLocation.getWorld()) return; double distance = lastLocation.distance(currentLocation); disguise.setSolidify(distance < .1); - }, solidifyTime); + }, 20 * 3); if(event.getFrom().distance(event.getTo()) > .1) disguise.setSolidify(false); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InventoryHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InventoryHandler.java index 2439b2b..af915e2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InventoryHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InventoryHandler.java @@ -19,11 +19,9 @@ package net.tylermurphy.hideAndSeek.game.listener; -import static net.tylermurphy.hideAndSeek.configuration.Config.*; - import com.cryptomorin.xseries.XMaterial; import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.command.Debug; +import net.tylermurphy.hideAndSeek.command.map.Debug; import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.game.util.Status; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java index 322519a..d4deafe 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java @@ -75,7 +75,7 @@ public class WorldLoader { public String save() { World world = Bukkit.getServer().getWorld(map.getSpawnName()); if(world == null){ - return errorPrefix + "Invalid world to save: " + map.getSpawnName(); + return errorPrefix + message("MAPSAVE_INVALID").addAmount(map.getSpawnName()); } File current = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getSpawnName()); if (current.exists()) { @@ -94,7 +94,7 @@ public class WorldLoader { } if (!temp_destination.renameTo(destination)) { - return errorPrefix + "Failed to rename directory: " + temp_destination.getPath(); + return errorPrefix + message("MAPSAVE_FAIL_DIR").addAmount(temp_destination.getPath()); } } catch(IOException e) { e.printStackTrace(); -- cgit v1.2.3-freya