summaryrefslogtreewikicommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/Main.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java9
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java7
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java12
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java34
-rw-r--r--src/main/resources/config.yml3
-rw-r--r--src/main/resources/items.yml12
-rw-r--r--src/main/resources/localization.yml5
8 files changed, 44 insertions, 41 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
index 4815a30..f92bf15 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
@@ -88,7 +88,8 @@ public class Main extends JavaPlugin implements Listener {
}
public void onDisable() {
- onTickTask.cancel();
+ if(onTickTask != null)
+ onTickTask.cancel();
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
index f2b7680..be86660 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
@@ -1,16 +1,7 @@
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 {
private static ConfigManager manager;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
index 09b3dcf..0129680 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
@@ -73,6 +73,10 @@ public class ConfigManager {
}
}
+ public void reset(String path){
+ config.set(path, defaultConfig.get(path));
+ }
+
public boolean getBoolean(String path){
boolean value = config.getBoolean(path);
if(value == false){
@@ -107,7 +111,6 @@ public class ConfigManager {
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;
@@ -131,7 +134,7 @@ public class ConfigManager {
replace = "\"" + replace + "\"";
}
StringBuilder builder = new StringBuilder(yamlString);
- builder.replace(start+1, end, replace);
+ builder.replace(start+1, end == -1 ? yamlString.length() : end, replace);
yamlString = builder.toString();
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
index fbf5d2c..e5470af 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
@@ -16,16 +16,14 @@ import java.util.Objects;
public class Items {
- private static ConfigManager manager;
-
public static List<ItemStack> HIDER_ITEMS, SEEKER_ITEMS;
public static List<PotionEffect> HIDER_EFFECTS, SEEKER_EFFECTS;
public static void loadItems() {
- manager = new ConfigManager("items.yml");
+ ConfigManager manager = new ConfigManager("items.yml");
- SEEKER_ITEMS = new ArrayList<ItemStack>();
+ SEEKER_ITEMS = new ArrayList<>();
ConfigurationSection SeekerItems = manager.getConfigurationSection("items.seeker");
int i = 1;
while (true) {
@@ -36,7 +34,7 @@ public class Items {
i++;
}
- HIDER_ITEMS = new ArrayList<ItemStack>();
+ HIDER_ITEMS = new ArrayList<>();
ConfigurationSection HiderItems = manager.getConfigurationSection("items.hider");
i = 1;
while (true) {
@@ -47,7 +45,7 @@ public class Items {
i++;
}
- SEEKER_EFFECTS = new ArrayList<PotionEffect>();
+ SEEKER_EFFECTS = new ArrayList<>();
ConfigurationSection SeekerEffects = manager.getConfigurationSection("effects.seeker");
i = 1;
while (true) {
@@ -58,7 +56,7 @@ public class Items {
i++;
}
- HIDER_EFFECTS = new ArrayList<PotionEffect>();
+ HIDER_EFFECTS = new ArrayList<>();
ConfigurationSection HiderEffects = manager.getConfigurationSection("effects.hider");
i = 1;
while (true) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java
index 9980a4e..1ae8ca2 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java
@@ -1,26 +1,32 @@
package net.tylermurphy.hideAndSeek.configuration;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
-import org.bukkit.configuration.file.YamlConfiguration;
-
import net.md_5.bungee.api.ChatColor;
-import net.tylermurphy.hideAndSeek.Main;
public class Localization {
- public static final Map<String,LocalizationString> LOCAL = new HashMap<String,LocalizationString>();
-
- private static ConfigManager manager;
-
- public static boolean loadLocalization() {
+ public static final Map<String,LocalizationString> LOCAL = new HashMap<>();
+
+ private static String[][] CHANGES = {{"WORLDBORDER_DECREASING"}};
+
+ public static void loadLocalization() {
+
+ ConfigManager manager = new ConfigManager("localization.yml");
+
+ int PLUGIN_VERSION = 2;
+ int VERSION = manager.getInt("version");
+ if(VERSION < PLUGIN_VERSION){
+ for(int i = VERSION; i < PLUGIN_VERSION; i++){
+ if(i < 1) continue;
+ String[] changeList = CHANGES[i-1];
+ for(String change : changeList)
+ manager.reset("Localization." + change);
+ }
+ manager.reset("version");
+ }
- manager = new ConfigManager("localization.yml");
manager.saveConfig();
for(String key : manager.getConfigurationSection("Localization").getKeys(false)) {
@@ -29,8 +35,6 @@ public class Localization {
new LocalizationString( ChatColor.translateAlternateColorCodes('&', manager.getString("Localization."+key) ) )
);
}
-
- return true;
}
public static LocalizationString message(String key) {
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 64fdece..c6b5ecd 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -36,6 +36,9 @@ 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/items.yml b/src/main/resources/items.yml
index d9b3b2a..4ef7953 100644
--- a/src/main/resources/items.yml
+++ b/src/main/resources/items.yml
@@ -40,12 +40,6 @@ items:
material: POTION
amount: 2
type: INSTANT_HEAL
- '4':
- type: DOLPHINS_GRACE
- duration: 1000000
- amplifier: 1
- ambient: false
- particles: false
effects:
seeker:
'1':
@@ -72,6 +66,12 @@ effects:
amplifier: 10
ambient: false
particles: false
+ '5':
+ type: DOLPHINS_GRACE
+ duration: 1000000
+ amplifier: 1
+ ambient: false
+ particles: false
hider:
'1':
type: WATER_BREATHING
diff --git a/src/main/resources/localization.yml b/src/main/resources/localization.yml
index f6a82dc..e73ee80 100644
--- a/src/main/resources/localization.yml
+++ b/src/main/resources/localization.yml
@@ -27,7 +27,7 @@ Localization:
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: "Would border decreasing by 100 blocks over the next 30s."
+ 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."
@@ -52,3 +52,6 @@ Localization:
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
+version: 2