diff --git a/.gitignore b/.gitignore
index 1679bd7..633697f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@ project
bin/
target/
.git/
+.idea
+hideandseek-plugin.iml
diff --git a/.project b/.project
deleted file mode 100644
index e024f12..0000000
--- a/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- hideandseek-plugin
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.m2e.core.maven2Nature
-
-
diff --git a/pom.xml b/pom.xml
index 5a78364..e0cca85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,43 +1,57 @@
-4.0.0
- net.tylermurphy
- HideAndSeek
- 1.3.0
- Hide and Seek Plugin
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.3.2
-
-
- 1.8
-
-
-
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/repositories/public/
-
+
+
+ 4.0.0
+
+ net.tylermurphy
+ HideAndSeek
+ 1.3.1
+ Hide and Seek Plugin
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+
+ 1.8
+
+
+
+
+
+
- dmulloy2-repo
- https://repo.dmulloy2.net/repository/public/
-
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/public/
+
+
+ dmulloy2-repo
+ https://repo.dmulloy2.net/repository/public/
+
+
-
+
org.spigotmc
spigot-api
1.17.1-R0.1-SNAPSHOT
jar
- provided
+ provided
-
- com.comphenix.protocol
- ProtocolLib
- 4.7.0
-
-
+
+ com.comphenix.protocol
+ ProtocolLib
+ 4.7.0
+
+
+
+
+ 11
+ 11
+
+
\ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
index 1e78bc9..1a5570e 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
@@ -61,10 +61,8 @@ public class Main extends JavaPlugin implements Listener {
data = this.getDataFolder();
// Init Configuration
- Main.plugin.saveResource("localization.yml", false);
- Main.plugin.saveResource("config.yml", false);
Config.loadConfig();
- Localization.init();
+ Localization.loadLocalization();
// Create World Loader
worldLoader = new WorldLoader(spawnWorld);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java
index 4a4bac1..9c88ccf 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java
@@ -40,6 +40,7 @@ public class EventListener implements Listener {
if(event.getPlayer().getWorld().getName().equals("hideandseek_"+spawnWorld) || event.getPlayer().getWorld().getName().equals(lobbyWorld)){
event.getPlayer().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
event.getPlayer().setGameMode(GameMode.ADVENTURE);
+
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
index 4b207fb..897a9a0 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
@@ -7,7 +7,7 @@ public class About implements ICommand {
public void execute(CommandSender sender, String[] args) {
sender.sendMessage(
- String.format("%s%sHide and Seek %s(1.3.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
+ String.format("%s%sHide and Seek %s(1.3.1%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)
);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
index cf580c9..2c7ba04 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
@@ -19,7 +19,7 @@ public class Reload implements ICommand {
return;
}
Config.loadConfig();
- Localization.init();
+ Localization.loadLocalization();
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
index 25e0a87..472396c 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
@@ -26,9 +26,7 @@ public class SetBorder implements ICommand {
}
if(args.length < 2) {
worldborderEnabled = false;
- Map temp = new HashMap();
- temp.put("enabled", false);
- addToSection("worldBorder",temp);
+ addToConfig("worldBorder.enabled",false);
saveConfig();
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
Worldborder.resetWorldborder(spawnWorld);
@@ -60,13 +58,11 @@ public class SetBorder implements ICommand {
worldborderSize = num;
worldborderDelay = delay;
worldborderEnabled = true;
- Map temp = new HashMap();
- temp.put("x", worldborderPosition.getBlockX());
- temp.put("z", worldborderPosition.getBlockZ());
- temp.put("delay", worldborderDelay);
- temp.put("size", worldborderSize);
- temp.put("enabled", true);
- addToSection("worldBorder",temp);
+ addToConfig("worldBorder.x", worldborderPosition.getBlockX());
+ addToConfig("worldBorder.z", worldborderPosition.getBlockZ());
+ addToConfig("worldBorder.delay", worldborderDelay);
+ addToConfig("worldBorder.size", worldborderSize);
+ addToConfig("worldBorder.enabled", true);
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
saveConfig();
Worldborder.resetWorldborder(spawnWorld);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
index e82d0e4..c9d2fae 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
@@ -27,11 +27,10 @@ public class SetExitLocation implements ICommand {
exitPosition = newExitPosition;
sender.sendMessage(messagePrefix + message("EXIT_SPAWN"));
Map temp = new HashMap();
- temp.put("x", exitPosition.getX());
- temp.put("y", exitPosition.getY());
- temp.put("z", exitPosition.getZ());
- temp.put("world", player.getLocation().getWorld().getName());
- addToSection("spawns.exit",temp);
+ addToConfig("spawns.exit.x", exitPosition.getX());
+ addToConfig("spawns.exit.y", exitPosition.getY());
+ addToConfig("spawns.exit.z", exitPosition.getZ());
+ addToConfig("spawns.exit.world", player.getLocation().getWorld().getName());
saveConfig();
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java
index 31cad53..a8a1887 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java
@@ -26,12 +26,10 @@ public class SetLobbyLocation implements ICommand {
}
lobbyPosition = newLobbyPosition;
sender.sendMessage(messagePrefix + message("LOBBY_SPAWN"));
- Map temp = new HashMap();
- temp.put("x", lobbyPosition.getX());
- temp.put("y", lobbyPosition.getY());
- temp.put("z", lobbyPosition.getZ());
- temp.put("world", player.getLocation().getWorld().getName());
- addToSection("spawns.lobby",temp);
+ addToConfig("spawns.lobby.x", lobbyPosition.getX());
+ addToConfig("spawns.lobby.y", lobbyPosition.getY());
+ addToConfig("spawns.lobby.z", lobbyPosition.getZ());
+ addToConfig("spawns.lobby.world", player.getLocation().getWorld().getName());
saveConfig();
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java
index 45ee758..d634968 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java
@@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.addToConfig;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetSpawnLocation implements ICommand {
@@ -30,12 +32,10 @@ public class SetSpawnLocation implements ICommand {
}
spawnPosition = newSpawnPosition;
sender.sendMessage(messagePrefix + message("GAME_SPAWN"));
- Map temp = new HashMap();
- temp.put("x", spawnPosition.getX());
- temp.put("y", spawnPosition.getY());
- temp.put("z", spawnPosition.getZ());
- temp.put("world", player.getLocation().getWorld().getName());
- addToSection("spawns.game",temp);
+ addToConfig("spawns.game.x", spawnPosition.getX());
+ addToConfig("spawns.game.y", spawnPosition.getY());
+ addToConfig("spawns.game.z", spawnPosition.getZ());
+ addToConfig("spawns.game.world", player.getLocation().getWorld().getName());
saveConfig();
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
index efae5d2..d82f01c 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
@@ -1,15 +1,19 @@
package net.tylermurphy.hideAndSeek.configuration;
+import java.io.File;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main;
public class Config {
+
+ static ConfigManager manager;
public static String
messagePrefix,
@@ -46,95 +50,78 @@ public class Config {
saveMaxX,
saveMaxZ;
- public static FileConfiguration getConfig() {
- return Main.plugin.getConfig();
- }
-
- public static void saveConfig() {
- Main.plugin.saveConfig();
- }
-
public static void loadConfig() {
-
- Main.plugin.reloadConfig();
-
+
+ manager = new ConfigManager("config.yml");
+
//Spawn
spawnPosition = new Vector(
- getConfig().getDouble("spawns.game.x"),
- Math.max(0,Math.min(255,getConfig().getDouble("spawns.game.y"))),
- getConfig().getDouble("spawns.game.z")
- );
- spawnWorld = getConfig().getString("spawns.game.world");
-
+ manager.getDouble("spawns.game.x"),
+ Math.max(0, Math.min(255, manager.getDouble("spawns.game.y"))),
+ manager.getDouble("spawns.game.z")
+ );
+ spawnWorld = manager.getString("spawns.game.world");
+
///Lobby
lobbyPosition = new Vector(
- getConfig().getDouble("spawns.lobby.x"),
- Math.max(0,Math.min(255,getConfig().getDouble("spawns.lobby.y"))),
- getConfig().getDouble("spawns.lobby.z")
- );
- lobbyWorld = getConfig().getString("spawns.lobby.world");
-
- announceMessagesToNonPlayers = getConfig().getBoolean("announceMessagesToNonPlayers");
-
+ manager.getDouble("spawns.lobby.x"),
+ Math.max(0, Math.min(255, manager.getDouble("spawns.lobby.y"))),
+ manager.getDouble("spawns.lobby.z")
+ );
+ lobbyWorld = manager.getString("spawns.lobby.world");
+
+ announceMessagesToNonPlayers = manager.getBoolean("announceMessagesToNonPlayers");
+
exitPosition = new Vector(
- getConfig().getDouble("spawns.exit.x"),
- Math.max(0,Math.min(255,getConfig().getDouble("spawns.exit.y"))),
- getConfig().getDouble("spawns.exit.z")
- );
- exitWorld = getConfig().getString("spawns.exit.world");
-
+ manager.getDouble("spawns.exit.x"),
+ Math.max(0, Math.min(255, manager.getDouble("spawns.exit.y"))),
+ manager.getDouble("spawns.exit.z")
+ );
+ exitWorld = manager.getString("spawns.exit.world");
+
//World border
worldborderPosition = new Vector(
- getConfig().getInt("worldBorder.x"),
- 0,
- getConfig().getInt("worldBorder.z")
- );
- worldborderSize = Math.max(100,getConfig().getInt("worldBorder.size"));
- worldborderDelay = Math.max(1,getConfig().getInt("worldBorder.delay"));
- worldborderEnabled = getConfig().getBoolean("worldBorder.enabled");
-
+ manager.getInt("worldBorder.x"),
+ 0,
+ manager.getInt("worldBorder.z")
+ );
+ worldborderSize = Math.max(100, manager.getInt("worldBorder.size"));
+ worldborderDelay = Math.max(1, manager.getInt("worldBorder.delay"));
+ worldborderEnabled = manager.getBoolean("worldBorder.enabled");
+
//Prefix
char SYMBOLE = '\u00A7';
- String SYMBOLE_STRING = new String(new char[] {SYMBOLE});
-
- messagePrefix = getConfig().getString("prefix.default").replace("&", SYMBOLE_STRING);
- errorPrefix = getConfig().getString("prefix.error").replace("&", SYMBOLE_STRING);
- tauntPrefix = getConfig().getString("prefix.taunt").replace("&", SYMBOLE_STRING);
- worldborderPrefix = getConfig().getString("prefix.border").replace("&", SYMBOLE_STRING);
- abortPrefix = getConfig().getString("prefix.abort").replace("&", SYMBOLE_STRING);
- gameoverPrefix = getConfig().getString("prefix.gameover").replace("&", SYMBOLE_STRING);
- warningPrefix = getConfig().getString("prefix.warning").replace("&", SYMBOLE_STRING);
-
+ String SYMBOLE_STRING = new String(new char[]{SYMBOLE});
+
+ messagePrefix = manager.getString("prefix.default").replace("&", SYMBOLE_STRING);
+ errorPrefix = manager.getString("prefix.error").replace("&", SYMBOLE_STRING);
+ tauntPrefix = manager.getString("prefix.taunt").replace("&", SYMBOLE_STRING);
+ worldborderPrefix = manager.getString("prefix.border").replace("&", SYMBOLE_STRING);
+ abortPrefix = manager.getString("prefix.abort").replace("&", SYMBOLE_STRING);
+ gameoverPrefix = manager.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
+ warningPrefix = manager.getString("prefix.warning").replace("&", SYMBOLE_STRING);
+
//Map Bounds
- saveMinX = getConfig().getInt("bounds.min.x");
- saveMinZ = getConfig().getInt("bounds.min.z");
- saveMaxX = getConfig().getInt("bounds.max.x");
- saveMaxZ = getConfig().getInt("bounds.max.z");
-
+ saveMinX = manager.getInt("bounds.min.x");
+ saveMinZ = manager.getInt("bounds.min.z");
+ saveMaxX = manager.getInt("bounds.max.x");
+ saveMaxZ = manager.getInt("bounds.max.z");
+
//Other
- nametagsVisible = getConfig().getBoolean("nametagsVisible");
- permissionsRequired = getConfig().getBoolean("permissionsRequired");
- minPlayers = Math.max(2,getConfig().getInt("minPlayers"));
- gameLength = getConfig().getInt("gameLength");
-
- getConfig().options().copyDefaults(true);
- saveConfig();
-
- }
-
- public static void addToSection(String sectionName, Map values) {
- ConfigurationSection section = getConfig().getConfigurationSection(sectionName);
- if(section == null) section = getConfig().createSection(sectionName);
- Map sectionValues = section.getValues(true);
- for(Entry entry : values.entrySet()) {
- sectionValues.put(entry.getKey(), entry.getValue());
- }
- getConfig().createSection(sectionName, sectionValues);
- saveConfig();
+ nametagsVisible = manager.getBoolean("nametagsVisible");
+ permissionsRequired = manager.getBoolean("permissionsRequired");
+ minPlayers = Math.max(2, manager.getInt("minPlayers"));
+ gameLength = manager.getInt("gameLength");
+
+ manager.saveConfig();
}
public static void addToConfig(String path, Object value) {
- getConfig().set(path, value);
+ manager.set(path, value);
+ }
+
+ public static void saveConfig() {
+ manager.saveConfig();
}
}
\ 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
new file mode 100644
index 0000000..7ea38db
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
@@ -0,0 +1,156 @@
+package net.tylermurphy.hideAndSeek.configuration;
+
+import net.tylermurphy.hideAndSeek.Main;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+public class ConfigManager {
+
+ private File file;
+ private YamlConfiguration config,defaultConfig;
+
+ public ConfigManager(String filename){
+ this.file = new File(Main.plugin.getDataFolder(), filename);
+
+ if(!file.exists()){
+ saveDefaultConfiguration();
+ }
+
+ this.config = YamlConfiguration.loadConfiguration(file);
+
+ InputStream input = Main.plugin.getResource(file.getName());
+ InputStreamReader reader = new InputStreamReader(input);
+ this.defaultConfig = YamlConfiguration.loadConfiguration(reader);
+ try{
+ input.close();
+ reader.close();
+ } catch (IOException e){}
+
+ }
+
+ private void saveDefaultConfiguration(){
+ try{
+ InputStream input = Main.plugin.getResource(file.getName());
+ java.nio.file.Files.copy(input, file.toPath());
+ input.close();
+ } catch(IOException e){
+ e.printStackTrace();
+ }
+ }
+
+ public void addToSection(String sectionName, Map values) {
+ ConfigurationSection section = config.getConfigurationSection(sectionName);
+ if(section == null) section = config.createSection(sectionName);
+ Map sectionValues = section.getValues(true);
+ for(Map.Entry entry : values.entrySet()) {
+ sectionValues.put(entry.getKey(), entry.getValue());
+ }
+ config.createSection(sectionName, sectionValues);
+ }
+
+ public void addToConfig(String path, Object value) {
+ config.set(path, value);
+ }
+
+ public double getDouble(String path){
+ double value = config.getDouble(path);
+ if(value == 0.0D){
+ return defaultConfig.getDouble(path);
+ } else {
+ return value;
+ }
+ }
+
+ public int getInt(String path){
+ int value = config.getInt(path);
+ if(value == 0){
+ return defaultConfig.getInt(path);
+ } else {
+ return value;
+ }
+ }
+
+ public String getString(String path){
+ String value = config.getString(path);
+ if(value == null){
+ return defaultConfig.getString(path);
+ } else {
+ return value;
+ }
+ }
+
+ public boolean getBoolean(String path){
+ boolean value = config.getBoolean(path);
+ if(value == false){
+ return defaultConfig.getBoolean(path);
+ } else {
+ return value;
+ }
+ }
+
+ public ConfigurationSection getConfigurationSection(String path){
+ ConfigurationSection section = config.getConfigurationSection(path);
+ if(section == null){
+ return defaultConfig.getConfigurationSection(path);
+ } else {
+ return section;
+ }
+ }
+
+ public void set(String path, Object value){
+ config.set(path, value);
+ }
+
+ public void saveConfig(){
+ try {
+ InputStream is = Main.plugin.getResource(file.getName());
+ StringBuilder textBuilder = new StringBuilder();
+ Reader reader = new BufferedReader(new InputStreamReader(is, Charset.forName(StandardCharsets.UTF_8.name())));
+ int c = 0;
+ while((c = reader.read()) != -1){
+ textBuilder.append((char) c);
+ }
+ String yamlString = textBuilder.toString();
+ Map temp = config.getValues(true);
+ for(Map.Entry entry: temp.entrySet()){
+ System.out.println(entry.getKey() + " " + entry.getValue().getClass().getName());
+ if(entry.getValue() instanceof Integer || entry.getValue() instanceof Double || entry.getValue() instanceof String || entry.getValue() instanceof Boolean){
+ 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 == -1) continue;;
+ int start = yamlString.indexOf(' ', index);
+ int end = yamlString.indexOf('\n', index);
+ String replace = entry.getValue().toString();
+ if(entry.getValue() instanceof String){
+ replace = "\"" + replace + "\"";
+ }
+ StringBuilder builder = new StringBuilder(yamlString);
+ builder.replace(start+1, end, replace);
+ yamlString = builder.toString();
+ }
+ }
+ PrintWriter out = new PrintWriter(file);
+ out.print(yamlString);
+ out.close();
+ } catch (IOException e){
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java
index ee34d4a..82d19d4 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java
@@ -16,44 +16,29 @@ public class Localization {
public static final Map LOCAL = new HashMap();
- static YamlConfiguration config, defaultConfig;
- static File location;
+ private static ConfigManager manager;
- public static boolean init() {
+ public static boolean loadLocalization() {
+
+ manager = new ConfigManager("localization.yml");
- Main.plugin.saveResource("localization.yml", false);
- String path = Main.data.getAbsolutePath()+File.separator + "localization.yml";
- location = new File(path);
- config = YamlConfiguration.loadConfiguration(location);
-
- InputStream is = Main.plugin.getResource("localization.yml");
- InputStreamReader isr = new InputStreamReader(is);
- defaultConfig = YamlConfiguration.loadConfiguration(isr);
-
- for(String key : config.getConfigurationSection("Localization").getKeys(false)) {
+ for(String key : manager.getConfigurationSection("Localization").getKeys(false)) {
LOCAL.put(
key,
- new LocalizationString( ChatColor.translateAlternateColorCodes('&', config.getString("Localization."+key) ) )
+ new LocalizationString( ChatColor.translateAlternateColorCodes('&', manager.getString("Localization."+key) ) )
);
}
+
+ manager.saveConfig();
+
return true;
}
public static LocalizationString message(String key) {
LocalizationString temp = LOCAL.get(key);
if(temp == null) {
- config.set("Localization."+key, defaultConfig.getString("Localization."+key));
- try {
- config.save(location);
- } catch (IOException e) {
- Main.plugin.getLogger().severe(e.getMessage());
- }
- LOCAL.put(key,
- new LocalizationString( ChatColor.translateAlternateColorCodes('&', defaultConfig.getString("Localization."+key) ) )
- );
- return new LocalizationString(LOCAL.get(key).toString());
+ return new LocalizationString(ChatColor.RED + "" + ChatColor.ITALIC + key + "is not found in localization.yml. This is a plugin issue, please report it.");
}
return new LocalizationString(temp.toString());
-
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
index 57839f1..9c6c1eb 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
@@ -2,9 +2,12 @@ package net.tylermurphy.hideAndSeek.util;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import java.io.File;
+import java.io.*;
+import net.md_5.bungee.api.ChatColor;
+import net.tylermurphy.hideAndSeek.configuration.LocalizationString;
import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.Main;
@@ -23,6 +26,7 @@ public class Util {
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false;
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(!destenation.exists()) return false;
+ if(saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) return false;
return true;
}
@@ -34,5 +38,28 @@ public class Util {
}
}, delay);
}
+
+ public YamlConfiguration loadDefaultConfig(String name) {
+
+ YamlConfiguration defaultConfig = null;
+
+ InputStream deafult_stream = null;
+ InputStreamReader default_stream_reader = null;
+ try {
+ deafult_stream = Class.class.getResourceAsStream(name + ".yml");
+ default_stream_reader = new InputStreamReader(deafult_stream);
+ defaultConfig = YamlConfiguration.loadConfiguration(default_stream_reader);
+ } catch (Exception e) {
+ // No Issue Here
+ } finally {
+ try {
+ deafult_stream.close();
+ default_stream_reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return defaultConfig;
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 368bca4..f826a88 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -42,13 +42,34 @@ spawns:
# The worldborder closes every interval, whish is evey [delay] in minutes.
# Thw worldborder stharts at [size], and decreaces 100 blocks every interval.
# x & z are the center location. [enabled] is whenever the border is enabled.
+# You can choose if Hiders are warned 30 seconds before the border moves.
worldBorder:
x: 0
z: 0
delay: 10
size: 500
+ warn: true
enabled: false
+# The taunt will activate every delay set in seconds. It will spawn a firework
+# on a random Hider to alert a Seeker where someone may be. You can choose
+# to publially show the taunt countdown, and have the taunt run with only
+# one Hider left.
+taunt:
+ delay: 360
+ whenLastPerson: false
+ showCountdown: true
+ enabled: true
+
+# The glow powerup allows all Hiders to see where every Seeker is. It last for
+# the amount of time set in seconds. You can allow it to be stackable, meaning
+# when multiple Hiders use the powerup at the same time, it stacks the times, or
+# just overwrites. Only Hiders can see that the Seekers are glowing.
+glow:
+ time: 30
+ stackable: true
+ enabled: true
+
# The message prefixes displayed before messages. The message contents themselvs
# can be changed in localization.yml.
prefix:
@@ -58,4 +79,20 @@ prefix:
border: '&cWorld Border > &f'
abort: '&cAbort > &f'
gameover: '&aGame Over > &f'
- warning: '&cWarning > &f'
\ No newline at end of file
+ warning: '&cWarning > &f'
+
+# ---------------------------------------------------------- #
+# ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING #
+# ---------------------------------------------------------- #
+
+# The 2 coordinate bounds that will contain your hideAndSeek map. Its reccomended
+# that you use /hs setbounds for this, and not edit this directly, as breaking
+# this section will completly break the entire plugin when you run /hs mapsave.
+bounds:
+ min:
+ x: 0
+ z: 0
+ max:
+ x: 0
+ z: 0
+
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 200d799..2f6b145 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: HideAndSeek
main: net.tylermurphy.hideAndSeek.Main
-version: 1.3.0
+version: 1.3.1
author: KenshinEto
load: STARTUP
api-version: 1.17