summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/configuration
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-05-16 13:56:52 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-05-16 13:56:52 -0400
commit416e459af261994ad702462812c29d55da8cb2d5 (patch)
tree96eaeda704398b95ddaf65fb2a105dd10419c04c /src/main/java/net/tylermurphy/hideAndSeek/configuration
parentMerge pull request #55 from bobby29831/1.4.3 (diff)
downloadkenshinshideandseek-416e459af261994ad702462812c29d55da8cb2d5.tar.gz
kenshinshideandseek-416e459af261994ad702462812c29d55da8cb2d5.tar.bz2
kenshinshideandseek-416e459af261994ad702462812c29d55da8cb2d5.zip
refactor: Jump Event, InventoryHandler, Relocate One function Utility Classes, Config Manager Getters Use Contains()
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/configuration')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java11
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java15
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java9
3 files changed, 15 insertions, 20 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
index 7ed8454..03d7504 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
@@ -24,7 +24,6 @@ import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
-import net.tylermurphy.hideAndSeek.game.util.Version;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -160,7 +159,7 @@ public class Config {
//Spawn
spawnPosition = new Vector(
config.getDouble("spawns.game.x"),
- Math.max(Version.atLeast("1.18") ? -64 : 0, Math.min(255, config.getDouble("spawns.game.y"))),
+ Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.game.y"))),
config.getDouble("spawns.game.z")
);
spawnWorld = config.getString("spawns.game.world");
@@ -168,7 +167,7 @@ public class Config {
///Lobby
lobbyPosition = new Vector(
config.getDouble("spawns.lobby.x"),
- Math.max(Version.atLeast("1.18") ? -64 : 0, Math.min(255, config.getDouble("spawns.lobby.y"))),
+ Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.lobby.y"))),
config.getDouble("spawns.lobby.z")
);
lobbyWorld = config.getString("spawns.lobby.world");
@@ -177,7 +176,7 @@ public class Config {
exitPosition = new Vector(
config.getDouble("spawns.exit.x"),
- Math.max(Version.atLeast("1.18") ? -64 : 0, Math.min(255, config.getDouble("spawns.exit.y"))),
+ Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.exit.y"))),
config.getDouble("spawns.exit.z")
);
exitWorld = config.getString("spawns.exit.world");
@@ -221,7 +220,7 @@ public class Config {
//Glow
glowLength = Math.max(1, config.getInt("glow.time"));
glowStackable = config.getBoolean("glow.stackable");
- glowEnabled = config.getBoolean("glow.enabled") && Version.atLeast("1.9");
+ glowEnabled = config.getBoolean("glow.enabled") && Main.getInstance().supports(9);
if (glowEnabled) {
glowPowerupItem = createItemStack("glow");
}
@@ -330,7 +329,7 @@ public class Config {
ConfigurationSection item = new YamlConfiguration().createSection("temp");
item.set("name", ChatColor.translateAlternateColorCodes('&',config.getString(path+".name")));
item.set("material", config.getString(path+".material"));
- if (Version.atLeast("1.14")) {
+ if (Main.getInstance().supports(14)) {
if (config.contains(path+".model-data") && config.getInt(path+".model-data") != 0) {
item.set("model-data", config.getInt(path+".model-data"));
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
index 3a95fe9..f02eaba 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
@@ -112,20 +112,18 @@ public class ConfigManager {
}
public double getDouble(String path) {
- double value = config.getDouble(path);
- if (value == 0.0D) {
+ if (!config.contains(path)) {
return defaultConfig.getDouble(path);
} else {
- return value;
+ return config.getDouble(path);
}
}
public int getInt(String path) {
- int value = config.getInt(path);
- if (value == 0) {
+ if (!config.contains(path)) {
return defaultConfig.getInt(path);
} else {
- return value;
+ return config.getInt(path);
}
}
@@ -134,11 +132,10 @@ public class ConfigManager {
}
public float getFloat(String path) {
- float value = (float) config.getDouble(path);
- if (value == 0.0F) {
+ if (!config.contains(path)) {
return (float) defaultConfig.getDouble(path);
} else {
- return value;
+ return (float) config.getDouble(path);
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
index 18a31b2..dfdb197 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
@@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.configuration;
import com.cryptomorin.xseries.XItemStack;
-import net.tylermurphy.hideAndSeek.game.util.Version;
+import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -30,7 +30,6 @@ import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
public class Items {
@@ -90,7 +89,7 @@ public class Items {
ConfigurationSection config = new YamlConfiguration().createSection("temp");
String material = item.getString("material").toUpperCase();
boolean splash = false;
- if (!Version.atLeast("1.9")) {
+ if (!Main.getInstance().supports(9)) {
if (material.contains("POTION")) {
config.set("level", 1);
}
@@ -103,7 +102,7 @@ public class Items {
config.set("material", material);
config.set("enchants", item.getConfigurationSection("enchantments"));
config.set("unbreakable", item.getBoolean("unbreakable"));
- if (Version.atLeast("1.14")) {
+ if (Main.getInstance().supports(14)) {
if (item.contains("model-data")) {
config.set("model-data", item.getInt("model-data"));
}
@@ -123,7 +122,7 @@ public class Items {
if (type == null) return null;
if (PotionEffectType.getByName(type.toUpperCase()) == null) return null;
return new PotionEffect(
- Objects.requireNonNull(PotionEffectType.getByName(type.toUpperCase())),
+ PotionEffectType.getByName(type.toUpperCase()),
item.getInt("duration"),
item.getInt("amplifier"),
item.getBoolean("ambient"),