From 7bc3b4e3998ad3af4db837b9d3585a01fd843f85 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 20 Dec 2021 21:17:30 -0500 Subject: [PATCH] 1.3.1 rc1 --- pom.xml | 7 --- .../configuration/ConfigManager.java | 26 ++++++--- .../configuration/Localization.java | 9 +-- src/main/resources/config.yml | 3 - .../resources/lang/localization_de-DE.yml | 2 + .../resources/lang/localization_en-US.yml | 2 + src/main/resources/localization.yml | 58 ------------------- 7 files changed, 27 insertions(+), 80 deletions(-) delete mode 100644 src/main/resources/localization.yml diff --git a/pom.xml b/pom.xml index bf694ed..320e622 100644 --- a/pom.xml +++ b/pom.xml @@ -40,11 +40,4 @@ 4.7.0 - - - github - GitHub Packages - https://maven.pkg.github.com/tylermurphy534/KenshinsHideAndSeek - - \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java index d16f3d8..dee1643 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java @@ -13,9 +13,11 @@ public class ConfigManager { private File file; private YamlConfiguration config,defaultConfig; + private String defaultFilename; public ConfigManager(String filename){ this.file = new File(Main.plugin.getDataFolder(), filename); + this.defaultFilename = file.getName(); if(!file.exists()){ saveDefaultConfiguration(); @@ -33,6 +35,8 @@ public class ConfigManager { } public ConfigManager(String filename, String defaultFilename){ + + this.defaultFilename = defaultFilename; this.file = new File(Main.plugin.getDataFolder(), filename); if(!file.exists()){ @@ -99,9 +103,14 @@ public class ConfigManager { config.set(path, defaultConfig.get(path)); } - public void resetConfig(){ - config = defaultConfig; - saveConfig(); + public void resetFile(String newDefaultFilename){ + this.defaultFilename = newDefaultFilename; + + InputStream input = Main.plugin.getResource(defaultFilename); + InputStreamReader reader = new InputStreamReader(input); + this.config = YamlConfiguration.loadConfiguration(reader); + this.defaultConfig = YamlConfiguration.loadConfiguration(reader); + } public boolean getBoolean(String path){ @@ -128,7 +137,7 @@ public class ConfigManager { public void saveConfig(){ try { - InputStream is = Main.plugin.getResource(file.getName()); + InputStream is = Main.plugin.getResource(defaultFilename); StringBuilder textBuilder = new StringBuilder(); Reader reader = new BufferedReader(new InputStreamReader(is, Charset.forName(StandardCharsets.UTF_8.name()))); int c = 0; @@ -144,15 +153,15 @@ public class ConfigManager { int i = 0; for(String part : parts) { if(i == 0) { - index = yamlString.indexOf(part, index); + index = yamlString.indexOf(part+":", index); } else { - index = yamlString.indexOf(" " + part, index); + index = yamlString.indexOf(" " + part+":", index); index++; } i++; if(index == -1) break; } - if(index == -1) continue;; + if(index < 10) continue;; int start = yamlString.indexOf(' ', index); int end = yamlString.indexOf('\n', index); if(end == -1) end = yamlString.length(); @@ -160,8 +169,9 @@ public class ConfigManager { if(entry.getValue() instanceof String){ replace = "\"" + replace + "\""; } + System.out.println(entry.getKey() + " " + index + " " + start + " " + end); StringBuilder builder = new StringBuilder(yamlString); - builder.replace(start+1, end == -1 ? yamlString.length() : end, replace); + builder.replace(start+1, end, replace); yamlString = builder.toString(); } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java index c404aa3..61dc5a4 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java @@ -28,12 +28,13 @@ public class Localization { manager.reset("version"); } - String SELECTED_LOCAL = manager.getString("local"); - if(!SELECTED_LOCAL.equals(Config.local)){ - manager.resetConfig(); + String SELECTED_LOCAL = manager.getString("type"); + if(SELECTED_LOCAL == null){ + manager.reset("type"); + } else if(!SELECTED_LOCAL.equals(Config.local)){ + manager.resetFile("lang"+File.separator+"localization_"+Config.local+".yml"); } - manager.saveConfig(); for(String key : manager.getConfigurationSection("Localization").getKeys(false)) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7d16cae..7366476 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -36,9 +36,6 @@ autoJoin: false # default: false teleportToExit: false -countdown: - - # The worldborder closes every interval, which is evey [delay] in minutes. # Thw worldborder starts at [size], and decreases 100 blocks every interval. # x & z are the center location. [enabled] is whenever the border is enabled. diff --git a/src/main/resources/lang/localization_de-DE.yml b/src/main/resources/lang/localization_de-DE.yml index d8930f8..829d792 100644 --- a/src/main/resources/lang/localization_de-DE.yml +++ b/src/main/resources/lang/localization_de-DE.yml @@ -57,4 +57,6 @@ Localization: HIDERS_SUBTITLE: "Verstecke dich gut vor den Seekern!" SEEKERS_SUBTITLE: "Finde alle Hider!" +# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE +version: 2 type: "de-DE" diff --git a/src/main/resources/lang/localization_en-US.yml b/src/main/resources/lang/localization_en-US.yml index 19c79b7..af5b80c 100644 --- a/src/main/resources/lang/localization_en-US.yml +++ b/src/main/resources/lang/localization_en-US.yml @@ -61,4 +61,6 @@ Localization: BOUNDS: "Successfully set bounds at this position ({AMOUNT}/2)." NOT_AT_ZERO: "Please do not set at a location containing a coordinate at 0." +# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE +version: 2 type: "en-US" \ No newline at end of file diff --git a/src/main/resources/localization.yml b/src/main/resources/localization.yml deleted file mode 100644 index 2acb0fc..0000000 --- a/src/main/resources/localization.yml +++ /dev/null @@ -1,58 +0,0 @@ -Localization: - COMMAND_PLAYER_ONLY: "This command can only be run as a player." - COMMAND_NOT_ALLOWED: "You are not allowed to run this command." - COMMAND_ERROR: "An internal error has occurred." - GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed." - GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker." - GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker." - GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found." - GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit." - GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!" - GAME_SETUP: "Game is not setup. Run /hs setup to see what you need to do." - GAME_INGAME: "You are already in the lobby/game." - GAME_NOT_INGAME: "You are not in a lobby/game." - GAME_INPROGRESS: "There is currently a game in progress." - GAME_NOT_INPROGRESS: "There is no game in progress." - GAME_JOIN: "{PLAYER} has joined the HideAndSeek lobby." - GAME_JOIN_SPECTATOR: "You have joined mid game and are now a spectator." - GAME_LEAVE: "{PLAYER} has left the HideAndSeek lobby." - CONFIG_RELOAD: "Reloaded the config." - MAPSAVE_INPROGRESS: "Map save is currently in progress. Try again later." - MAPSAVE_START: "Starting map save." - MAPSAVE_WARNING: "All commands will be disabled when the save is in progress. Do not turn off the server." - MAPSAVE_END: "Map save complete." - MAPSAVE_ERROR: "Couldn't find current map." - WORLDBORDER_DISABLE: "Disabled world border." - WORLDBORDER_INVALID_INPUT: "Invalid integer {AMOUNT}." - WORLDBORDER_MIN_SIZE: "World border cannot be smaller than 100 blocks." - WORLDBORDER_POSITION: "Spawn position must be 100 from world border center." - WORLDBORDER_ENABLE: "Set border center to current location, size to {AMOUNT}, and delay to {AMOUNT}." - WORLDBORDER_DECREASING: "World border decreasing by 100 blocks over the next 30s." - TAUNTED: "$c$oOh no! You have been chosen to be taunted." - TAUNT: "A random hider will be taunted in the next 30s." - TAUNT_ACTIVATE: "Taunt has been activated." - ERROR_GAME_SPAWN: "Please set game spawn location first" - SETUP: "&f&lThe following is needed for setup..." - SETUP_GAME: "&c&l- &fGame spawn isn't set, /hs setspawn" - SETUP_LOBBY: "&c&l- &fLobby spawn isn't set, /hs setlobby" - SETUP_EXIT: "&c&l- &fQuit/exit teleport location isn't set, /hs setexit" - SETUP_SAVEMAP: "&c&l- &fHide and seek map isn't saved, /hs savemap (after /hs setspawn)" - SETUP_BOUNDS: "&c&l- &fPlease set game bounds in 2 opposite corners of the game map, /hs setbounds" - SETUP_COMPLETE: "Everything is setup and ready to go!" - GAME_SPAWN: "Set game spawn position to current location" - LOBBY_SPAWN: "Set lobby position to current location" - EXIT_SPAWN: "Set exit position to current location" - START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start." - START_INVALID_NAME: "Invalid player: {PLAYER}." - START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!" - START: "Attention SEEKERS, its time to fin the hiders!" - STOP: "Game has been force stopped." - HIDERS_SUBTITLE: "Hide away from the seekers" - SEEKERS_SUBTITLE: "Eliminate all hiders" - BOUNDS_WRONG_WORLD: "Please run this command in the game world." - BOUNDS: "Successfully set bounds at this position ({AMOUNT}/2)." - NOT_AT_ZERO: "Please do not set at a location containing a coordinate at 0." - -# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE -version: 2 -type: "en-US" \ No newline at end of file