summaryrefslogtreewikicommitdiff
path: root/src/main/java/dev/tylerm/khs/configuration/Items.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/dev/tylerm/khs/configuration/Items.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java)119
1 files changed, 103 insertions, 16 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java b/src/main/java/dev/tylerm/khs/configuration/Items.java
index e5f970b..af8216d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java
+++ b/src/main/java/dev/tylerm/khs/configuration/Items.java
@@ -1,7 +1,7 @@
-package net.tylermurphy.hideAndSeek.configuration;
+package dev.tylerm.khs.configuration;
import com.cryptomorin.xseries.XItemStack;
-import net.tylermurphy.hideAndSeek.Main;
+import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -16,6 +16,12 @@ import java.util.List;
public class Items {
public static List<ItemStack> HIDER_ITEMS, SEEKER_ITEMS;
+ public static ItemStack
+ HIDER_HELM, SEEKER_HELM,
+ HIDER_CHEST, SEEKER_CHEST,
+ HIDER_LEGS, SEEKER_LEGS,
+ HIDER_BOOTS, SEEKER_BOOTS;
+
public static List<PotionEffect> HIDER_EFFECTS, SEEKER_EFFECTS;
public static void loadItems() {
@@ -23,29 +29,109 @@ public class Items {
ConfigManager manager = ConfigManager.create("items.yml");
SEEKER_ITEMS = new ArrayList<>();
+ SEEKER_HELM = null;
+ SEEKER_CHEST = null;
+ SEEKER_LEGS = null;
+ SEEKER_BOOTS = null;
+
ConfigurationSection SeekerItems = manager.getConfigurationSection("items.seeker");
- int i = 1;
- while (true) {
+
+ for (int i = 0; i < 9; i++) {
ConfigurationSection section = SeekerItems.getConfigurationSection(String.valueOf(i));
- if (section == null) break;
+ if (section == null) {
+ SEEKER_ITEMS.add(null);
+ continue;
+ }
ItemStack item = createItem(section);
- if (item != null) SEEKER_ITEMS.add(item);
- i++;
+ SEEKER_ITEMS.add(item);
+ }
+
+ ConfigurationSection SeekerHelmet = SeekerItems.getConfigurationSection("helmet");
+ if (SeekerHelmet != null) {
+ ItemStack item = createItem(SeekerHelmet);
+ if (item != null) {
+ SEEKER_HELM = item;
+ }
+ }
+
+ ConfigurationSection SeekerChestplate = SeekerItems.getConfigurationSection("chestplate");
+ if (SeekerChestplate != null) {
+ ItemStack item = createItem(SeekerChestplate);
+ if (item != null) {
+ SEEKER_CHEST = item;
+ }
+ }
+
+ ConfigurationSection SeekerLeggings = SeekerItems.getConfigurationSection("leggings");
+ if (SeekerLeggings != null) {
+ ItemStack item = createItem(SeekerLeggings);
+ if (item != null) {
+ SEEKER_LEGS = item;
+ }
+ }
+
+ ConfigurationSection SeekerBoots = SeekerItems.getConfigurationSection("boots");
+ if (SeekerBoots != null) {
+ ItemStack item = createItem(SeekerBoots);
+ if (item != null) {
+ SEEKER_BOOTS = item;
+ }
}
HIDER_ITEMS = new ArrayList<>();
+ HIDER_HELM = null;
+ HIDER_CHEST = null;
+ HIDER_LEGS = null;
+ HIDER_BOOTS = null;
+
ConfigurationSection HiderItems = manager.getConfigurationSection("items.hider");
- i = 1;
- while (true) {
+
+ for (int i = 0; i < 9; i++) {
ConfigurationSection section = HiderItems.getConfigurationSection(String.valueOf(i));
- if (section == null) break;
+ if (section == null) {
+ HIDER_ITEMS.add(null);
+ continue;
+ }
ItemStack item = createItem(section);
- if (item != null) HIDER_ITEMS.add(item);
- i++;
+ HIDER_ITEMS.add(item);
+ }
+
+ ConfigurationSection HiderHelmet = HiderItems.getConfigurationSection("helmet");
+ if (HiderHelmet != null) {
+ ItemStack item = createItem(HiderHelmet);
+ if (item != null) {
+ HIDER_HELM = item;
+ }
+ }
+
+ ConfigurationSection HiderChestplate = HiderItems.getConfigurationSection("chestplate");
+ if (HiderChestplate != null) {
+ ItemStack item = createItem(HiderChestplate);
+ if (item != null) {
+ HIDER_CHEST = item;
+ }
}
+
+ ConfigurationSection HiderLeggings = HiderItems.getConfigurationSection("leggings");
+ if (HiderLeggings != null) {
+ ItemStack item = createItem(HiderLeggings);
+ if (item != null) {
+ HIDER_LEGS = item;
+ }
+ }
+
+ ConfigurationSection HiderBoots = HiderItems.getConfigurationSection("boots");
+ if (HiderBoots != null) {
+ ItemStack item = createItem(HiderBoots);
+ if (item != null) {
+ HIDER_BOOTS = item;
+ }
+ }
+
SEEKER_EFFECTS = new ArrayList<>();
ConfigurationSection SeekerEffects = manager.getConfigurationSection("effects.seeker");
- i = 1;
+
+ int i = 1;
while (true) {
ConfigurationSection section = SeekerEffects.getConfigurationSection(String.valueOf(i));
if (section == null) break;
@@ -64,7 +150,6 @@ public class Items {
if (effect != null) HIDER_EFFECTS.add(effect);
i++;
}
-
}
private static ItemStack createItem(ConfigurationSection item) {
@@ -94,7 +179,9 @@ public class Items {
if (material.equalsIgnoreCase("POTION") || material.equalsIgnoreCase("SPLASH_POTION") || material.equalsIgnoreCase("LINGERING_POTION"))
config.set("base-effect", String.format("%s,%s,%s", item.getString("type"), false, splash));
ItemStack stack = XItemStack.deserialize(config);
- stack.setAmount(item.getInt("amount"));
+ int amt = item.getInt("amount");
+ if (amt < 1) amt = 1;
+ stack.setAmount(amt);
if (stack.getData().getItemType() == Material.AIR) return null;
return stack;
}
@@ -121,7 +208,7 @@ public class Items {
}
private static boolean equals(ItemStack a, ItemStack b) {
- if (a == null) {
+ if (a == null || b == null) {
return false;
} else if (a == b) {
return true;