1.3.1 build 2

This commit is contained in:
Tyler Murphy 2021-10-28 23:09:28 -04:00
parent 27dc2bbf90
commit 3ebb86268a
17 changed files with 368 additions and 191 deletions

2
.gitignore vendored
View file

@ -4,3 +4,5 @@ project
bin/ bin/
target/ target/
.git/ .git/
.idea
hideandseek-plugin.iml

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hideandseek-plugin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

82
pom.xml
View file

@ -1,43 +1,57 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion> <?xml version="1.0" encoding="UTF-8"?>
<groupId>net.tylermurphy</groupId> <project xmlns="http://maven.apache.org/POM/4.0.0"
<artifactId>HideAndSeek</artifactId> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<version>1.3.0</version> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<name>Hide and Seek Plugin</name> <modelVersion>4.0.0</modelVersion>
<build>
<plugins> <groupId>net.tylermurphy</groupId>
<plugin> <artifactId>HideAndSeek</artifactId>
<groupId>org.apache.maven.plugins</groupId> <version>1.3.1</version>
<artifactId>maven-compiler-plugin</artifactId> <name>Hide and Seek Plugin</name>
<version>2.3.2</version>
<configuration> <build>
<source>1.8</source> <plugins>
<target>1.8</target> <plugin>
</configuration> <groupId>org.apache.maven.plugins</groupId>
</plugin> <artifactId>maven-compiler-plugin</artifactId>
</plugins> <version>2.3.2</version>
</build> <configuration>
<repositories> <source>1.8</source>
<repository> <target>1.8</target>
<id>spigot-repo</id> </configuration>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url> </plugin>
</repository> </plugins>
</build>
<repositories>
<repository> <repository>
<id>dmulloy2-repo</id> <id>spigot-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository> </repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version> <version>1.17.1-R0.1-SNAPSHOT</version>
<type>jar</type> <type>jar</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.7.0</version> <version>4.7.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project> </project>

View file

@ -61,10 +61,8 @@ public class Main extends JavaPlugin implements Listener {
data = this.getDataFolder(); data = this.getDataFolder();
// Init Configuration // Init Configuration
Main.plugin.saveResource("localization.yml", false);
Main.plugin.saveResource("config.yml", false);
Config.loadConfig(); Config.loadConfig();
Localization.init(); Localization.loadLocalization();
// Create World Loader // Create World Loader
worldLoader = new WorldLoader(spawnWorld); worldLoader = new WorldLoader(spawnWorld);

View file

@ -40,6 +40,7 @@ public class EventListener implements Listener {
if(event.getPlayer().getWorld().getName().equals("hideandseek_"+spawnWorld) || event.getPlayer().getWorld().getName().equals(lobbyWorld)){ 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().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
event.getPlayer().setGameMode(GameMode.ADVENTURE); event.getPlayer().setGameMode(GameMode.ADVENTURE);
} }
} }

View file

@ -7,7 +7,7 @@ public class About implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
sender.sendMessage( 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("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE) String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
); );

View file

@ -19,7 +19,7 @@ public class Reload implements ICommand {
return; return;
} }
Config.loadConfig(); Config.loadConfig();
Localization.init(); Localization.loadLocalization();
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD")); sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
} }

View file

@ -26,9 +26,7 @@ public class SetBorder implements ICommand {
} }
if(args.length < 2) { if(args.length < 2) {
worldborderEnabled = false; worldborderEnabled = false;
Map<String, Object> temp = new HashMap<String,Object>(); addToConfig("worldBorder.enabled",false);
temp.put("enabled", false);
addToSection("worldBorder",temp);
saveConfig(); saveConfig();
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE")); sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
Worldborder.resetWorldborder(spawnWorld); Worldborder.resetWorldborder(spawnWorld);
@ -60,13 +58,11 @@ public class SetBorder implements ICommand {
worldborderSize = num; worldborderSize = num;
worldborderDelay = delay; worldborderDelay = delay;
worldborderEnabled = true; worldborderEnabled = true;
Map<String, Object> temp = new HashMap<String,Object>(); addToConfig("worldBorder.x", worldborderPosition.getBlockX());
temp.put("x", worldborderPosition.getBlockX()); addToConfig("worldBorder.z", worldborderPosition.getBlockZ());
temp.put("z", worldborderPosition.getBlockZ()); addToConfig("worldBorder.delay", worldborderDelay);
temp.put("delay", worldborderDelay); addToConfig("worldBorder.size", worldborderSize);
temp.put("size", worldborderSize); addToConfig("worldBorder.enabled", true);
temp.put("enabled", true);
addToSection("worldBorder",temp);
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay)); sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
saveConfig(); saveConfig();
Worldborder.resetWorldborder(spawnWorld); Worldborder.resetWorldborder(spawnWorld);

View file

@ -27,11 +27,10 @@ public class SetExitLocation implements ICommand {
exitPosition = newExitPosition; exitPosition = newExitPosition;
sender.sendMessage(messagePrefix + message("EXIT_SPAWN")); sender.sendMessage(messagePrefix + message("EXIT_SPAWN"));
Map<String, Object> temp = new HashMap<String,Object>(); Map<String, Object> temp = new HashMap<String,Object>();
temp.put("x", exitPosition.getX()); addToConfig("spawns.exit.x", exitPosition.getX());
temp.put("y", exitPosition.getY()); addToConfig("spawns.exit.y", exitPosition.getY());
temp.put("z", exitPosition.getZ()); addToConfig("spawns.exit.z", exitPosition.getZ());
temp.put("world", player.getLocation().getWorld().getName()); addToConfig("spawns.exit.world", player.getLocation().getWorld().getName());
addToSection("spawns.exit",temp);
saveConfig(); saveConfig();
} }

View file

@ -26,12 +26,10 @@ public class SetLobbyLocation implements ICommand {
} }
lobbyPosition = newLobbyPosition; lobbyPosition = newLobbyPosition;
sender.sendMessage(messagePrefix + message("LOBBY_SPAWN")); sender.sendMessage(messagePrefix + message("LOBBY_SPAWN"));
Map<String, Object> temp = new HashMap<String,Object>(); addToConfig("spawns.lobby.x", lobbyPosition.getX());
temp.put("x", lobbyPosition.getX()); addToConfig("spawns.lobby.y", lobbyPosition.getY());
temp.put("y", lobbyPosition.getY()); addToConfig("spawns.lobby.z", lobbyPosition.getZ());
temp.put("z", lobbyPosition.getZ()); addToConfig("spawns.lobby.world", player.getLocation().getWorld().getName());
temp.put("world", player.getLocation().getWorld().getName());
addToSection("spawns.lobby",temp);
saveConfig(); saveConfig();
} }

View file

@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.configuration.Config.addToConfig;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*; import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetSpawnLocation implements ICommand { public class SetSpawnLocation implements ICommand {
@ -30,12 +32,10 @@ public class SetSpawnLocation implements ICommand {
} }
spawnPosition = newSpawnPosition; spawnPosition = newSpawnPosition;
sender.sendMessage(messagePrefix + message("GAME_SPAWN")); sender.sendMessage(messagePrefix + message("GAME_SPAWN"));
Map<String, Object> temp = new HashMap<String,Object>(); addToConfig("spawns.game.x", spawnPosition.getX());
temp.put("x", spawnPosition.getX()); addToConfig("spawns.game.y", spawnPosition.getY());
temp.put("y", spawnPosition.getY()); addToConfig("spawns.game.z", spawnPosition.getZ());
temp.put("z", spawnPosition.getZ()); addToConfig("spawns.game.world", player.getLocation().getWorld().getName());
temp.put("world", player.getLocation().getWorld().getName());
addToSection("spawns.game",temp);
saveConfig(); saveConfig();
} }

View file

@ -1,16 +1,20 @@
package net.tylermurphy.hideAndSeek.configuration; package net.tylermurphy.hideAndSeek.configuration;
import java.io.File;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
public class Config { public class Config {
static ConfigManager manager;
public static String public static String
messagePrefix, messagePrefix,
errorPrefix, errorPrefix,
@ -46,95 +50,78 @@ public class Config {
saveMaxX, saveMaxX,
saveMaxZ; saveMaxZ;
public static FileConfiguration getConfig() {
return Main.plugin.getConfig();
}
public static void saveConfig() {
Main.plugin.saveConfig();
}
public static void loadConfig() { public static void loadConfig() {
Main.plugin.reloadConfig(); manager = new ConfigManager("config.yml");
//Spawn //Spawn
spawnPosition = new Vector( spawnPosition = new Vector(
getConfig().getDouble("spawns.game.x"), manager.getDouble("spawns.game.x"),
Math.max(0,Math.min(255,getConfig().getDouble("spawns.game.y"))), Math.max(0, Math.min(255, manager.getDouble("spawns.game.y"))),
getConfig().getDouble("spawns.game.z") manager.getDouble("spawns.game.z")
); );
spawnWorld = getConfig().getString("spawns.game.world"); spawnWorld = manager.getString("spawns.game.world");
///Lobby ///Lobby
lobbyPosition = new Vector( lobbyPosition = new Vector(
getConfig().getDouble("spawns.lobby.x"), manager.getDouble("spawns.lobby.x"),
Math.max(0,Math.min(255,getConfig().getDouble("spawns.lobby.y"))), Math.max(0, Math.min(255, manager.getDouble("spawns.lobby.y"))),
getConfig().getDouble("spawns.lobby.z") manager.getDouble("spawns.lobby.z")
); );
lobbyWorld = getConfig().getString("spawns.lobby.world"); lobbyWorld = manager.getString("spawns.lobby.world");
announceMessagesToNonPlayers = getConfig().getBoolean("announceMessagesToNonPlayers"); announceMessagesToNonPlayers = manager.getBoolean("announceMessagesToNonPlayers");
exitPosition = new Vector( exitPosition = new Vector(
getConfig().getDouble("spawns.exit.x"), manager.getDouble("spawns.exit.x"),
Math.max(0,Math.min(255,getConfig().getDouble("spawns.exit.y"))), Math.max(0, Math.min(255, manager.getDouble("spawns.exit.y"))),
getConfig().getDouble("spawns.exit.z") manager.getDouble("spawns.exit.z")
); );
exitWorld = getConfig().getString("spawns.exit.world"); exitWorld = manager.getString("spawns.exit.world");
//World border //World border
worldborderPosition = new Vector( worldborderPosition = new Vector(
getConfig().getInt("worldBorder.x"), manager.getInt("worldBorder.x"),
0, 0,
getConfig().getInt("worldBorder.z") manager.getInt("worldBorder.z")
); );
worldborderSize = Math.max(100,getConfig().getInt("worldBorder.size")); worldborderSize = Math.max(100, manager.getInt("worldBorder.size"));
worldborderDelay = Math.max(1,getConfig().getInt("worldBorder.delay")); worldborderDelay = Math.max(1, manager.getInt("worldBorder.delay"));
worldborderEnabled = getConfig().getBoolean("worldBorder.enabled"); worldborderEnabled = manager.getBoolean("worldBorder.enabled");
//Prefix //Prefix
char SYMBOLE = '\u00A7'; char SYMBOLE = '\u00A7';
String SYMBOLE_STRING = new String(new char[] {SYMBOLE}); String SYMBOLE_STRING = new String(new char[]{SYMBOLE});
messagePrefix = getConfig().getString("prefix.default").replace("&", SYMBOLE_STRING); messagePrefix = manager.getString("prefix.default").replace("&", SYMBOLE_STRING);
errorPrefix = getConfig().getString("prefix.error").replace("&", SYMBOLE_STRING); errorPrefix = manager.getString("prefix.error").replace("&", SYMBOLE_STRING);
tauntPrefix = getConfig().getString("prefix.taunt").replace("&", SYMBOLE_STRING); tauntPrefix = manager.getString("prefix.taunt").replace("&", SYMBOLE_STRING);
worldborderPrefix = getConfig().getString("prefix.border").replace("&", SYMBOLE_STRING); worldborderPrefix = manager.getString("prefix.border").replace("&", SYMBOLE_STRING);
abortPrefix = getConfig().getString("prefix.abort").replace("&", SYMBOLE_STRING); abortPrefix = manager.getString("prefix.abort").replace("&", SYMBOLE_STRING);
gameoverPrefix = getConfig().getString("prefix.gameover").replace("&", SYMBOLE_STRING); gameoverPrefix = manager.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
warningPrefix = getConfig().getString("prefix.warning").replace("&", SYMBOLE_STRING); warningPrefix = manager.getString("prefix.warning").replace("&", SYMBOLE_STRING);
//Map Bounds //Map Bounds
saveMinX = getConfig().getInt("bounds.min.x"); saveMinX = manager.getInt("bounds.min.x");
saveMinZ = getConfig().getInt("bounds.min.z"); saveMinZ = manager.getInt("bounds.min.z");
saveMaxX = getConfig().getInt("bounds.max.x"); saveMaxX = manager.getInt("bounds.max.x");
saveMaxZ = getConfig().getInt("bounds.max.z"); saveMaxZ = manager.getInt("bounds.max.z");
//Other //Other
nametagsVisible = getConfig().getBoolean("nametagsVisible"); nametagsVisible = manager.getBoolean("nametagsVisible");
permissionsRequired = getConfig().getBoolean("permissionsRequired"); permissionsRequired = manager.getBoolean("permissionsRequired");
minPlayers = Math.max(2,getConfig().getInt("minPlayers")); minPlayers = Math.max(2, manager.getInt("minPlayers"));
gameLength = getConfig().getInt("gameLength"); gameLength = manager.getInt("gameLength");
getConfig().options().copyDefaults(true); manager.saveConfig();
saveConfig();
}
public static void addToSection(String sectionName, Map<String,Object> values) {
ConfigurationSection section = getConfig().getConfigurationSection(sectionName);
if(section == null) section = getConfig().createSection(sectionName);
Map<String,Object> sectionValues = section.getValues(true);
for(Entry<String, Object> entry : values.entrySet()) {
sectionValues.put(entry.getKey(), entry.getValue());
}
getConfig().createSection(sectionName, sectionValues);
saveConfig();
} }
public static void addToConfig(String path, Object value) { public static void addToConfig(String path, Object value) {
getConfig().set(path, value); manager.set(path, value);
}
public static void saveConfig() {
manager.saveConfig();
} }
} }

View file

@ -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<String,Object> values) {
ConfigurationSection section = config.getConfigurationSection(sectionName);
if(section == null) section = config.createSection(sectionName);
Map<String,Object> sectionValues = section.getValues(true);
for(Map.Entry<String, Object> 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<String, Object> temp = config.getValues(true);
for(Map.Entry<String, Object> 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();
}
}
}

View file

@ -16,44 +16,29 @@ public class Localization {
public static final Map<String,LocalizationString> LOCAL = new HashMap<String,LocalizationString>(); public static final Map<String,LocalizationString> LOCAL = new HashMap<String,LocalizationString>();
static YamlConfiguration config, defaultConfig; private static ConfigManager manager;
static File location;
public static boolean init() { public static boolean loadLocalization() {
Main.plugin.saveResource("localization.yml", false); manager = new ConfigManager("localization.yml");
String path = Main.data.getAbsolutePath()+File.separator + "localization.yml";
location = new File(path);
config = YamlConfiguration.loadConfiguration(location);
InputStream is = Main.plugin.getResource("localization.yml"); for(String key : manager.getConfigurationSection("Localization").getKeys(false)) {
InputStreamReader isr = new InputStreamReader(is);
defaultConfig = YamlConfiguration.loadConfiguration(isr);
for(String key : config.getConfigurationSection("Localization").getKeys(false)) {
LOCAL.put( LOCAL.put(
key, key,
new LocalizationString( ChatColor.translateAlternateColorCodes('&', config.getString("Localization."+key) ) ) new LocalizationString( ChatColor.translateAlternateColorCodes('&', manager.getString("Localization."+key) ) )
); );
} }
manager.saveConfig();
return true; return true;
} }
public static LocalizationString message(String key) { public static LocalizationString message(String key) {
LocalizationString temp = LOCAL.get(key); LocalizationString temp = LOCAL.get(key);
if(temp == null) { if(temp == null) {
config.set("Localization."+key, defaultConfig.getString("Localization."+key)); return new LocalizationString(ChatColor.RED + "" + ChatColor.ITALIC + key + "is not found in localization.yml. This is a plugin issue, please report it.");
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(temp.toString()); return new LocalizationString(temp.toString());
} }
} }

View file

@ -2,9 +2,12 @@ package net.tylermurphy.hideAndSeek.util;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; 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.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
@ -23,6 +26,7 @@ public class Util {
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false; if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false;
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld); File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(!destenation.exists()) return false; if(!destenation.exists()) return false;
if(saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) return false;
return true; return true;
} }
@ -35,4 +39,27 @@ public class Util {
}, delay); }, 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;
}
} }

View file

@ -42,13 +42,34 @@ spawns:
# The worldborder closes every interval, whish is evey [delay] in minutes. # The worldborder closes every interval, whish is evey [delay] in minutes.
# Thw worldborder stharts at [size], and decreaces 100 blocks every interval. # Thw worldborder stharts at [size], and decreaces 100 blocks every interval.
# x & z are the center location. [enabled] is whenever the border is enabled. # 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: worldBorder:
x: 0 x: 0
z: 0 z: 0
delay: 10 delay: 10
size: 500 size: 500
warn: true
enabled: false 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 # The message prefixes displayed before messages. The message contents themselvs
# can be changed in localization.yml. # can be changed in localization.yml.
prefix: prefix:
@ -59,3 +80,19 @@ prefix:
abort: '&cAbort > &f' abort: '&cAbort > &f'
gameover: '&aGame Over > &f' gameover: '&aGame Over > &f'
warning: '&cWarning > &f' 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

View file

@ -1,6 +1,6 @@
name: HideAndSeek name: HideAndSeek
main: net.tylermurphy.hideAndSeek.Main main: net.tylermurphy.hideAndSeek.Main
version: 1.3.0 version: 1.3.1
author: KenshinEto author: KenshinEto
load: STARTUP load: STARTUP
api-version: 1.17 api-version: 1.17