diff options
author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-02 07:18:00 -0400 |
---|---|---|
committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-02 07:18:00 -0400 |
commit | bb254145ed0bb56d0482f6ba34e05cb728a7c8cc (patch) | |
tree | 9e2c645f417a1a1d77855e068b213fe4369fd056 /src/main/java | |
parent | 1.7.0 beta 1 (diff) | |
download | kenshinshideandseek-bb254145ed0bb56d0482f6ba34e05cb728a7c8cc.tar.gz kenshinshideandseek-bb254145ed0bb56d0482f6ba34e05cb728a7c8cc.tar.bz2 kenshinshideandseek-bb254145ed0bb56d0482f6ba34e05cb728a7c8cc.zip |
1.7.0 beta 2
Diffstat (limited to 'src/main/java')
34 files changed, 369 insertions, 239 deletions
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<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { + public java.util.List<String> 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 <http://www.gnu.org/licenses/>. - * - */ - -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<String> autoComplete(String parameter) { - 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/map/SetMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java index 2df5824..9978c3c 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java @@ -1,4 +1,4 @@ -package net.tylermurphy.hideAndSeek.command.map; +package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.command.util.Command; @@ -13,7 +13,7 @@ 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 class Send extends Command { public void execute(Player sender, String[] args) { @@ -46,7 +46,7 @@ public class SetMap extends Command { } public String getLabel() { - return "goto"; + return "send"; } public String getUsage() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java index 01e1512..874909b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java @@ -17,11 +17,11 @@ * */ -package net.tylermurphy.hideAndSeek.command.location; +package net.tylermurphy.hideAndSeek.command; 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.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; import org.bukkit.entity.Player; import java.util.List; 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<Player> 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 "<player>"; + 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 "<page>"; + return "<*page>"; } public String getDescription() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java index 69d7c26..5e4afb5 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java @@ -1,4 +1,4 @@ -package net.tylermurphy.hideAndSeek.command.location.util; +package net.tylermurphy.hideAndSeek.command.location; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.configuration.Map; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java index 35f74ea..dd73dac 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java @@ -1,4 +1,4 @@ -package net.tylermurphy.hideAndSeek.command.location.util; +package net.tylermurphy.hideAndSeek.command.location; /** * @author bobby29831 diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java index 55b4267..03c2a95 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java @@ -14,7 +14,7 @@ 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 class Add extends Command { public void execute(Player sender, String[] args) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java index 2eb0eb9..2ec0525 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java @@ -1,4 +1,4 @@ -package net.tylermurphy.hideAndSeek.command; +package net.tylermurphy.hideAndSeek.command.map; import com.cryptomorin.xseries.XMaterial; import net.tylermurphy.hideAndSeek.Main; 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 "<map> <spawn>"; + } + + public String getDescription() { + return "Get the commands for the plugin"; + } + + public List<String> 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/ListMaps.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java index 79490a7..635c011 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java @@ -7,13 +7,12 @@ 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 class List extends Command { public void execute(Player sender, String[] args) { Collection<Map> maps = Maps.getAllMaps(); @@ -40,7 +39,7 @@ public class ListMaps extends Command { return "List all maps in the plugin"; } - public List<String> autoComplete(String parameter) { + public java.util.List<String> autoComplete(String parameter) { return null; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java index 216cca9..45dec99 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java @@ -14,7 +14,7 @@ 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 class Remove extends Command { public void execute(Player sender, String[] args) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java index f3eb4d7..b93250f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java @@ -34,7 +34,7 @@ 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 class Save extends Command { public static boolean runningBackup = false; @@ -60,7 +60,8 @@ public class SaveMap extends Command { sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING")); World world = map.getSpawn().getWorld(); if (world == null) { - throw new RuntimeException("Unable to get spawn world"); + sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD")); + return; } world.save(); BukkitRunnable runnable = new BukkitRunnable() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java index 46b41f7..29442c1 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java @@ -19,20 +19,18 @@ 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 class Status extends Command { public void execute(Player sender, String[] args) { @@ -76,7 +74,7 @@ public class Setup extends Command { } public String getLabel() { - return "setup"; + return "status"; } public String getUsage() { 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 "<map> <bool>"; + } + + public String getDescription() { + return "Sets hide and seeks lobby location to current position"; + } + + public List<String> 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/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java index 8362e02..92339b4 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java @@ -17,7 +17,7 @@ * */ -package net.tylermurphy.hideAndSeek.command.map; +package net.tylermurphy.hideAndSeek.command.map.set; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.command.util.Command; @@ -33,7 +33,7 @@ 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 class Border extends Command { public void execute(Player sender, String[] args) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { @@ -86,7 +86,7 @@ public class SetBorder extends Command { change ); Maps.setMap(map.getName(), map); - sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay)); + sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay).addAmount(change)); map.getWorldBorder().resetWorldBorder(); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java index 92bf5a4..9896389 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java @@ -17,7 +17,7 @@ * */ -package net.tylermurphy.hideAndSeek.command.map; +package net.tylermurphy.hideAndSeek.command.map.set; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.command.util.Command; @@ -32,7 +32,7 @@ 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 class Bounds extends Command { public void execute(Player sender, String[] args) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java index da41d91..c691787 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java @@ -17,18 +17,18 @@ * */ -package net.tylermurphy.hideAndSeek.command.location; +package net.tylermurphy.hideAndSeek.command.map.set; 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.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 SetLobbyLocation extends Command { +public class Lobby extends Command { public void execute(Player sender, String[] args) { LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java index 8a5ebd1..2521f19 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java @@ -1,8 +1,8 @@ -package net.tylermurphy.hideAndSeek.command.location; +package net.tylermurphy.hideAndSeek.command.map.set; 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.command.location.LocationUtils; +import net.tylermurphy.hideAndSeek.command.location.Locations; import net.tylermurphy.hideAndSeek.configuration.Maps; import org.bukkit.entity.Player; @@ -11,7 +11,7 @@ import java.util.stream.Collectors; import static net.tylermurphy.hideAndSeek.configuration.Localization.message; -public class SetSeekerLobbyLocation extends Command { +public class SeekerLobby extends Command { public void execute(Player sender, String[] args) { LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java index 82f71d1..3e8f77e 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java @@ -17,11 +17,11 @@ * */ -package net.tylermurphy.hideAndSeek.command.location; +package net.tylermurphy.hideAndSeek.command.map.set; 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.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; @@ -33,7 +33,7 @@ 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 class Spawn extends Command { public void execute(Player sender, String[] args) { LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> { 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<String> - 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<String, Object> temp = config.getValues(true); - for(Map.Entry<String, Object> 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<String, Object> data = config.getValues(true); + // write each stored config value into the yaml string + for(Map.Entry<String, Object> 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<String> + 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<String,LocalizationString> DEFAULT_LOCAL = new HashMap<>(); private static final Map<String,String[][]> CHANGES = new HashMap<String,String[][]>() {{ - 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(); |