From 664c0d9ad5eaaefd9bc7e56ca732c58cb6030b72 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Wed, 4 May 2022 09:28:38 -0400 Subject: [PATCH] 1.4.3 beta 2 (bug fix issue requests) --- .../net/tylermurphy/hideAndSeek/command/Stop.java | 3 +-- .../hideAndSeek/configuration/ConfigManager.java | 15 ++++++++------- .../net/tylermurphy/hideAndSeek/game/Game.java | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java index b41277b..0b53ed6 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java @@ -37,8 +37,7 @@ public class Stop implements ICommand { return; } if(Game.status == Status.STARTING || Game.status == Status.PLAYING) { - if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("STOP")); - else Game.broadcastMessage(abortPrefix + message("STOP")); + Game.broadcastMessage(abortPrefix + message("STOP")); Game.stop(WinType.NONE); } else { sender.sendMessage(errorPrefix + message("GAME_NOT_INPROGRESS")); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java index 1684896..71c9e02 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java @@ -176,11 +176,10 @@ public class ConfigManager { } public boolean getBoolean(String path){ - boolean value = config.getBoolean(path); - if(!value){ + if(!config.contains(path)){ return defaultConfig.getBoolean(path); } else { - return true; + return config.getBoolean(path); } } @@ -209,7 +208,7 @@ public class ConfigManager { while((c = reader.read()) != -1){ textBuilder.append((char) c); } - String yamlString = textBuilder.toString(); + 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){ @@ -239,18 +238,20 @@ public class ConfigManager { } replace = replace.substring(0, replace.length()-2); replace = replace + "]"; + replace = new String(replace.getBytes(), StandardCharsets.UTF_8); } else { - replace = entry.getValue().toString(); + replace = new String(entry.getValue().toString().getBytes(), StandardCharsets.UTF_8); } if(entry.getValue() instanceof String){ replace = "\"" + replace + "\""; } StringBuilder builder = new StringBuilder(yamlString); builder.replace(start+1, end, replace); - yamlString = builder.toString(); + yamlString = new String(builder.toString().getBytes(), StandardCharsets.UTF_8); } } - PrintWriter out = new PrintWriter(file); + OutputStream os = new FileOutputStream(file); + PrintWriter out = new PrintWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8), true); out.print(yamlString); out.close(); } catch (IOException e){ diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index eb467c4..72a530f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -171,6 +171,7 @@ public class Game { } worldBorder.resetWorldborder("hideandseek_"+spawnWorld); for(Player player : Board.getPlayers()) { + player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); Board.createLobbyBoard(player); player.setGameMode(GameMode.ADVENTURE); Board.addHider(player); @@ -179,7 +180,6 @@ public class Game { player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem); if(lobbyLeaveItem != null) player.getInventory().setItem(lobbyItemLeavePosition, lobbyLeaveItem); - player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); for(PotionEffect effect : player.getActivePotionEffects()){ player.removePotionEffect(effect.getType()); } @@ -259,6 +259,7 @@ public class Game { public static void join(Player player){ if(Game.status == Status.STANDBY) { + player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); player.getInventory().clear(); if(lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start"))) player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem); @@ -267,7 +268,6 @@ public class Game { Board.addHider(player); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player)); else Game.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player)); - player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); player.setGameMode(GameMode.ADVENTURE); Board.createLobbyBoard(player); Board.reloadLobbyBoards();