diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/commands/CommandGive.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/commands/CommandGive.java
index 4e5f026..040ebaf 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/commands/CommandGive.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/commands/CommandGive.java
@@ -5,7 +5,6 @@ import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.TabCompleteHandler;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.config.updating.ConfigUpdater;
-import com.willfp.eco.core.display.Display;
import com.willfp.ecoarmor.sets.ArmorSet;
import com.willfp.ecoarmor.sets.ArmorSets;
import com.willfp.ecoarmor.sets.meta.ArmorSlot;
@@ -18,7 +17,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
-import java.io.DataInput;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -71,12 +69,12 @@ public class CommandGive extends Subcommand {
@ConfigUpdater
public static void reload() {
ITEM_NAMES.clear();
- ITEM_NAMES.addAll(ArmorSets.values().stream().map(armorSet -> "set:" + armorSet.getName()).collect(Collectors.toList()));
- ITEM_NAMES.addAll(ArmorSets.values().stream().map(armorSet -> "shard:" + armorSet.getName()).collect(Collectors.toList()));
- ITEM_NAMES.addAll(Tiers.values().stream().map(crystal -> "crystal:" + crystal.getName()).collect(Collectors.toList()));
+ ITEM_NAMES.addAll(ArmorSets.values().stream().map(armorSet -> "set:" + armorSet.getId()).collect(Collectors.toList()));
+ ITEM_NAMES.addAll(ArmorSets.values().stream().map(armorSet -> "shard:" + armorSet.getId()).collect(Collectors.toList()));
+ ITEM_NAMES.addAll(Tiers.values().stream().map(crystal -> "crystal:" + crystal.getId()).collect(Collectors.toList()));
SLOTS.addAll(Arrays.stream(ArmorSlot.values()).map(slot -> slot.name().toLowerCase()).collect(Collectors.toList()));
SLOTS.add("full");
- TIERS.addAll(Tiers.values().stream().map(Tier::getName).collect(Collectors.toList()));
+ TIERS.addAll(Tiers.values().stream().map(Tier::getId).collect(Collectors.toList()));
}
@Override
@@ -119,14 +117,14 @@ public class CommandGive extends Subcommand {
int amount = 1;
if (itemNamespace.equalsIgnoreCase("set")) {
- ArmorSet set = ArmorSets.getByName(itemKey);
+ ArmorSet set = ArmorSets.getByID(itemKey);
if (set == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-item"));
return;
}
String message = this.getPlugin().getLangYml().getMessage("give-success");
- message = message.replace("%item%", set.getName() + " Set").replace("%recipient%", reciever.getName());
+ message = message.replace("%item%", set.getId() + " Set").replace("%recipient%", reciever.getName());
sender.sendMessage(message);
boolean advanced = false;
@@ -159,7 +157,7 @@ public class CommandGive extends Subcommand {
}
if (args.size() >= 5) {
- tier = Tiers.getByName(args.get(4));
+ tier = Tiers.getByID(args.get(4));
}
if (args.size() >= 6) {
@@ -183,7 +181,7 @@ public class CommandGive extends Subcommand {
}
if (itemNamespace.equalsIgnoreCase("crystal")) {
- Tier tier = Tiers.getByName(itemKey);
+ Tier tier = Tiers.getByID(itemKey);
if (tier == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-item"));
return;
@@ -204,7 +202,7 @@ public class CommandGive extends Subcommand {
}
if (itemNamespace.equalsIgnoreCase("shard")) {
- ArmorSet set = ArmorSets.getByName(itemKey);
+ ArmorSet set = ArmorSets.getByID(itemKey);
if (set == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-item"));
return;
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java
index ede75a2..bdc5371 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java
@@ -7,10 +7,7 @@ import com.willfp.eco.core.items.CustomItem;
import com.willfp.eco.core.items.Items;
import com.willfp.eco.core.items.builder.ItemBuilder;
import com.willfp.eco.core.items.builder.ItemStackBuilder;
-import com.willfp.eco.core.items.builder.LeatherArmorBuilder;
-import com.willfp.eco.core.items.builder.SkullBuilder;
import com.willfp.eco.core.recipe.Recipes;
-import com.willfp.ecoarmor.EcoArmorPlugin;
import com.willfp.ecoarmor.sets.meta.ArmorSlot;
import com.willfp.ecoarmor.sets.util.ArmorUtils;
import com.willfp.ecoarmor.upgrades.Tier;
@@ -23,8 +20,6 @@ import com.willfp.libreforge.effects.Effects;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@@ -59,7 +54,7 @@ public class ArmorSet {
* The name of the set.
*/
@Getter
- private final String name;
+ private final String id;
/**
* The advanced holder.
@@ -73,15 +68,6 @@ public class ArmorSet {
@Getter
private final Holder regularHolder;
- /**
- * The base64 texture of a skull used as a helmet.
- *
- * Null if no skull.
- */
- @Getter
- @Nullable
- private String skullBase64;
-
/**
* Items in set.
*/
@@ -108,11 +94,11 @@ public class ArmorSet {
@NotNull final EcoPlugin plugin) {
this.config = config;
this.plugin = plugin;
- this.name = config.getString("name");
+ this.id = config.getString("id");
Set conditions = new HashSet<>();
for (Config cfg : this.getConfig().getSubsections("conditions")) {
- ConfiguredCondition conf = Conditions.compile(cfg, "Armor Set " + this.name);
+ ConfiguredCondition conf = Conditions.compile(cfg, "Armor Set " + this.id);
if (conf != null) {
conditions.add(conf);
}
@@ -120,7 +106,7 @@ public class ArmorSet {
Set effects = new HashSet<>();
for (Config cfg : this.getConfig().getSubsections("effects")) {
- ConfiguredEffect conf = Effects.compile(cfg, "Armor Set " + this.name);
+ ConfiguredEffect conf = Effects.compile(cfg, "Armor Set " + this.id);
if (conf != null) {
effects.add(conf);
}
@@ -128,7 +114,7 @@ public class ArmorSet {
Set advancedEffects = new HashSet<>();
for (Config cfg : this.getConfig().getSubsections("advancedEffects")) {
- ConfiguredEffect conf = Effects.compile(cfg, "Armor Set " + this.name + " (Advanced)");
+ ConfiguredEffect conf = Effects.compile(cfg, "Armor Set " + this.id + " (Advanced)");
if (conf != null) {
advancedEffects.add(conf);
}
@@ -160,18 +146,18 @@ public class ArmorSet {
.addEnchantment(Enchantment.DURABILITY, 3)
.addItemFlag(ItemFlag.HIDE_ENCHANTS)
.addLoreLines(shardLore)
- .writeMetaKey(this.getPlugin().getNamespacedKeyFactory().create("advancement-shard"), PersistentDataType.STRING, name)
+ .writeMetaKey(this.getPlugin().getNamespacedKeyFactory().create("advancement-shard"), PersistentDataType.STRING, id)
.build();
if (this.getConfig().getBool("shardCraftable")) {
Recipes.createAndRegisterRecipe(this.getPlugin(),
- this.getName() + "_shard",
+ this.getId() + "_shard",
shard,
this.getConfig().getStrings("shardRecipe"));
}
new CustomItem(
- this.getPlugin().getNamespacedKeyFactory().create("shard_" + name.toLowerCase()),
+ this.getPlugin().getNamespacedKeyFactory().create("shard_" + id.toLowerCase()),
test -> this.equals(ArmorUtils.getShardSet(test)),
shard
).register();
@@ -182,25 +168,8 @@ public class ArmorSet {
private ItemStack construct(@NotNull final ArmorSlot slot,
@NotNull final Config slotConfig,
final boolean advanced) {
- Material material = Material.getMaterial(slotConfig.getString("material").toUpperCase());
-
- assert material != null;
-
- ItemBuilder builder;
-
- builder = switch (material) {
- case PLAYER_HEAD -> new SkullBuilder();
- case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS -> new LeatherArmorBuilder(material);
- default -> new ItemStackBuilder(material);
- };
-
- builder.setDisplayName(advanced ? slotConfig.getString("advancedName") : slotConfig.getString("name"))
- .addItemFlag(
- slotConfig.getStrings("flags").stream()
- .map(s -> ItemFlag.valueOf(s.toUpperCase()))
- .toArray(ItemFlag[]::new)
- )
- .setUnbreakable(slotConfig.getBool("unbreakable"))
+ ItemBuilder builder = new ItemStackBuilder(Items.lookup(slotConfig.getString("item")).getItem())
+ .setDisplayName(advanced ? slotConfig.getString("advancedName") : slotConfig.getString("name"))
.addLoreLines(slotConfig.getStrings("lore").stream().map(s -> Display.PREFIX + s).collect(Collectors.toList()))
.addLoreLines(() -> {
if (advanced) {
@@ -209,43 +178,12 @@ public class ArmorSet {
return null;
}
})
- .setCustomModelData(() -> {
- int data = slotConfig.getInt("customModelData");
- return data != -1 ? data : null;
- })
.setDisplayName(() -> advanced ? slotConfig.getString("advancedName") : slotConfig.getString("name"));
-
- if (builder instanceof SkullBuilder skullBuilder) {
- this.skullBase64 = slotConfig.getString("skullTexture");
- skullBuilder.setSkullTexture(skullBase64);
- }
-
- if (builder instanceof LeatherArmorBuilder leatherArmorBuilder) {
- String colorString = slotConfig.getString("leatherColor");
- java.awt.Color awtColor = java.awt.Color.decode(colorString);
- leatherArmorBuilder.setColor(awtColor);
- builder.addItemFlag(ItemFlag.HIDE_DYE);
- }
-
-
- Map enchants = new HashMap<>();
-
- for (Config enchantSection : slotConfig.getSubsections("enchants")) {
- Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchantSection.getString("id")));
- if (enchantment == null) {
- continue;
- }
- int level = enchantSection.getInt("level");
- enchants.put(enchantment, level);
- }
-
- enchants.forEach(builder::addEnchantment);
-
builder.writeMetaKey(
this.getPlugin().getNamespacedKeyFactory().create("set"),
PersistentDataType.STRING,
- name
+ id
).writeMetaKey(
this.getPlugin().getNamespacedKeyFactory().create("effective-durability"),
PersistentDataType.INTEGER,
@@ -255,16 +193,16 @@ public class ArmorSet {
ItemStack itemStack = builder.build();
ArmorUtils.setAdvanced(itemStack, advanced);
- Tier defaultTier = Tiers.getByName(slotConfig.getString("defaultTier"));
+ Tier defaultTier = Tiers.getByID(slotConfig.getString("defaultTier"));
if (defaultTier == null) {
- Bukkit.getLogger().warning("Default tier specified in " + this.name + " " + slot.name().toLowerCase() + " is invalid! Defaulting to 'default'");
+ Bukkit.getLogger().warning("Default tier specified in " + this.id + " " + slot.name().toLowerCase() + " is invalid! Defaulting to 'default'");
ArmorUtils.setTier(itemStack, Tiers.getDefaultTier());
} else {
ArmorUtils.setTier(itemStack, defaultTier);
}
if (advanced) {
- new CustomItem(this.getPlugin().getNamespacedKeyFactory().create("set_" + name.toLowerCase() + "_" + slot.name().toLowerCase() + "_advanced"), test -> {
+ new CustomItem(this.getPlugin().getNamespacedKeyFactory().create("set_" + id.toLowerCase() + "_" + slot.name().toLowerCase() + "_advanced"), test -> {
if (ArmorSlot.getSlot(test) != ArmorSlot.getSlot(itemStack)) {
return false;
}
@@ -278,7 +216,7 @@ public class ArmorSet {
return Objects.equals(this, ArmorUtils.getSetOnItem(test));
}, itemStack).register();
} else {
- new CustomItem(this.getPlugin().getNamespacedKeyFactory().create("set_" + name.toLowerCase() + "_" + slot.name().toLowerCase()), test -> {
+ new CustomItem(this.getPlugin().getNamespacedKeyFactory().create("set_" + id.toLowerCase() + "_" + slot.name().toLowerCase()), test -> {
if (ArmorSlot.getSlot(test) != ArmorSlot.getSlot(itemStack)) {
return false;
}
@@ -317,7 +255,7 @@ public class ArmorSet {
Recipes.createAndRegisterRecipe(
this.getPlugin(),
- this.getName() + "_" + slot.name().toLowerCase(),
+ this.getId() + "_" + slot.name().toLowerCase(),
formattedOut,
slotConfig.getStrings("recipe")
);
@@ -352,8 +290,8 @@ public class ArmorSet {
*/
public Tier getDefaultTier(@Nullable final ArmorSlot slot) {
if (slot == null) return Tiers.getDefaultTier();
- Tier tier = Tiers.getByName(this.config.getSubsection(slot.name().toLowerCase()).getString("defaultTier"));
- return tier != null ? tier: Tiers.getDefaultTier();
+ Tier tier = Tiers.getByID(this.config.getSubsection(slot.name().toLowerCase()).getString("defaultTier"));
+ return tier != null ? tier : Tiers.getDefaultTier();
}
@Override
@@ -366,18 +304,18 @@ public class ArmorSet {
return false;
}
- return this.name.equals(set.name);
+ return this.id.equals(set.id);
}
@Override
public int hashCode() {
- return Objects.hash(this.name);
+ return Objects.hash(this.id);
}
@Override
public String toString() {
return "ArmorSet{"
- + this.name
+ + this.id
+ "}";
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSets.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSets.java
index 1f79955..7b438ff 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSets.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSets.java
@@ -18,7 +18,7 @@ public class ArmorSets {
/**
* Registered armor sets.
*/
- private static final BiMap BY_NAME = HashBiMap.create();
+ private static final BiMap BY_ID = HashBiMap.create();
/**
* Get all registered {@link ArmorSet}s.
@@ -26,18 +26,18 @@ public class ArmorSets {
* @return A list of all {@link ArmorSet}s.
*/
public static List values() {
- return ImmutableList.copyOf(BY_NAME.values());
+ return ImmutableList.copyOf(BY_ID.values());
}
/**
- * Get {@link ArmorSet} matching name.
+ * Get {@link ArmorSet} matching ID.
*
* @param name The name to search for.
* @return The matching {@link ArmorSet}, or null if not found.
*/
@Nullable
- public static ArmorSet getByName(@NotNull final String name) {
- return BY_NAME.get(name);
+ public static ArmorSet getByID(@NotNull final String name) {
+ return BY_ID.get(name);
}
/**
@@ -62,8 +62,8 @@ public class ArmorSets {
* @param set The {@link ArmorSet} to add.
*/
public static void addNewSet(@NotNull final ArmorSet set) {
- BY_NAME.remove(set.getName());
- BY_NAME.put(set.getName(), set);
+ BY_ID.remove(set.getId());
+ BY_ID.put(set.getId(), set);
}
/**
@@ -72,6 +72,6 @@ public class ArmorSets {
* @param set The {@link ArmorSet} to remove.
*/
public static void removeSet(@NotNull final ArmorSet set) {
- BY_NAME.remove(set.getName());
+ BY_ID.remove(set.getId());
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/util/ArmorUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/util/ArmorUtils.java
index bb948db..a3b3f6a 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/util/ArmorUtils.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/util/ArmorUtils.java
@@ -61,7 +61,7 @@ public class ArmorUtils {
return null;
}
- return ArmorSets.getByName(setName);
+ return ArmorSets.getByID(setName);
}
/**
@@ -151,7 +151,7 @@ public class ArmorUtils {
@Nullable
public static Tier getCrystalTier(@NotNull final ItemMeta meta) {
if (meta.getPersistentDataContainer().has(PLUGIN.getNamespacedKeyFactory().create("upgrade_crystal"), PersistentDataType.STRING)) {
- return Tiers.getByName(meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("upgrade_crystal"), PersistentDataType.STRING));
+ return Tiers.getByID(meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("upgrade_crystal"), PersistentDataType.STRING));
}
return null;
@@ -194,7 +194,7 @@ public class ArmorUtils {
}
if (meta.getPersistentDataContainer().has(PLUGIN.getNamespacedKeyFactory().create("tier"), PersistentDataType.STRING)) {
- return Tiers.getByName(meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("tier"), PersistentDataType.STRING));
+ return Tiers.getByID(meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("tier"), PersistentDataType.STRING));
}
return null;
@@ -218,7 +218,7 @@ public class ArmorUtils {
return;
}
- meta.getPersistentDataContainer().set(PLUGIN.getNamespacedKeyFactory().create("tier"), PersistentDataType.STRING, tier.getName());
+ meta.getPersistentDataContainer().set(PLUGIN.getNamespacedKeyFactory().create("tier"), PersistentDataType.STRING, tier.getId());
ArmorSlot slot = ArmorSlot.getSlot(itemStack);
@@ -391,6 +391,6 @@ public class ArmorUtils {
return null;
}
- return ArmorSets.getByName(shardSet);
+ return ArmorSets.getByID(shardSet);
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tier.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tier.java
index 8964d41..614b6e7 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tier.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tier.java
@@ -32,7 +32,7 @@ public class Tier extends PluginDependent {
* The tier name.
*/
@Getter
- private final String name;
+ private final String id;
/**
* The config of the crystal.
@@ -84,7 +84,7 @@ public class Tier extends PluginDependent {
public Tier(@NotNull final Config config,
@NotNull final EcoPlugin plugin) {
super(plugin);
- this.name = config.getString("name");
+ this.id = config.getString("id");
this.config = config;
Tiers.addNewTier(this);
@@ -104,7 +104,7 @@ public class Tier extends PluginDependent {
ItemMeta outMeta = out.getItemMeta();
assert outMeta != null;
PersistentDataContainer container = outMeta.getPersistentDataContainer();
- container.set(key, PersistentDataType.STRING, name);
+ container.set(key, PersistentDataType.STRING, id);
outMeta.setDisplayName(this.getConfig().getString("crystal.name"));
@@ -131,7 +131,7 @@ public class Tier extends PluginDependent {
}
new CustomItem(
- this.getPlugin().getNamespacedKeyFactory().create("crystal_" + name.toLowerCase()),
+ this.getPlugin().getNamespacedKeyFactory().create("crystal_" + id.toLowerCase()),
test -> this.equals(ArmorUtils.getCrystalTier(test)),
out
).register();
@@ -139,12 +139,12 @@ public class Tier extends PluginDependent {
if (this.isCraftable()) {
ItemStack recipeOut = out.clone();
recipeOut.setAmount(this.getConfig().getInt("crystal.giveAmount"));
- ShapedCraftingRecipe.Builder builder = ShapedCraftingRecipe.builder(this.getPlugin(), "upgrade_crystal_" + name)
+ ShapedCraftingRecipe.Builder builder = ShapedCraftingRecipe.builder(this.getPlugin(), "upgrade_crystal_" + id)
.setOutput(recipeOut);
List recipeStrings = this.getConfig().getStrings("crystal.recipe");
- new CustomItem(this.getPlugin().getNamespacedKeyFactory().create("upgrade_crystal_" + name), test -> {
+ new CustomItem(this.getPlugin().getNamespacedKeyFactory().create("upgrade_crystal_" + id), test -> {
if (test == null) {
return false;
}
@@ -169,7 +169,7 @@ public class Tier extends PluginDependent {
* @return The tiers, or a blank list if always available.
*/
public List getRequiredTiersForApplication() {
- return requiredTiersForApplication.stream().map(Tiers::getByName).filter(Objects::nonNull).collect(Collectors.toList());
+ return requiredTiersForApplication.stream().map(Tiers::getByID).filter(Objects::nonNull).collect(Collectors.toList());
}
@Override
@@ -182,11 +182,11 @@ public class Tier extends PluginDependent {
}
Tier tier = (Tier) o;
- return Objects.equals(getName(), tier.getName());
+ return Objects.equals(this.getId(), tier.getId());
}
@Override
public int hashCode() {
- return Objects.hash(getName());
+ return Objects.hash(this.getId());
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tiers.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tiers.java
index 35861cd..404966b 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tiers.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/Tiers.java
@@ -18,7 +18,7 @@ public class Tiers {
/**
* Registered tiers.
*/
- private static final BiMap BY_NAME = HashBiMap.create();
+ private static final BiMap BY_ID = HashBiMap.create();
/**
* Default tier.
@@ -27,14 +27,14 @@ public class Tiers {
private static Tier defaultTier;
/**
- * Get {@link Tiers} matching name.
+ * Get {@link Tiers} matching ID.
*
* @param name The name to search for.
* @return The matching {@link Tiers}, or null if not found.
*/
@Nullable
- public static Tier getByName(@Nullable final String name) {
- return BY_NAME.get(name);
+ public static Tier getByID(@Nullable final String name) {
+ return BY_ID.get(name);
}
/**
@@ -43,7 +43,7 @@ public class Tiers {
* @return A list of all {@link Tiers}s.
*/
public static List values() {
- return ImmutableList.copyOf(BY_NAME.values());
+ return ImmutableList.copyOf(BY_ID.values());
}
/**
@@ -52,8 +52,8 @@ public class Tiers {
* @param tier The {@link Tier} to add.
*/
public static void addNewTier(@NotNull final Tier tier) {
- BY_NAME.remove(tier.getName());
- BY_NAME.put(tier.getName(), tier);
+ BY_ID.remove(tier.getId());
+ BY_ID.put(tier.getId(), tier);
}
/**
@@ -63,13 +63,13 @@ public class Tiers {
*/
@ConfigUpdater
public static void reload(@NotNull final EcoArmorPlugin plugin) {
- BY_NAME.clear();
+ BY_ID.clear();
for (Config tierConfig : plugin.getEcoArmorYml().getSubsections("tiers")) {
new Tier(tierConfig, plugin);
}
- defaultTier = Tiers.getByName("default");
+ defaultTier = Tiers.getByID("default");
}
static {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/AdvancementShardListener.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/AdvancementShardListener.java
index a055452..48b0680 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/AdvancementShardListener.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/AdvancementShardListener.java
@@ -62,7 +62,7 @@ public class AdvancementShardListener extends PluginDependent impleme
return;
}
- if (!ArmorSets.getByName(shardSet).getName().equals(set.getName())) {
+ if (!ArmorSets.getByID(shardSet).getId().equals(set.getId())) {
return;
}
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/display/ArmorDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/display/ArmorDisplay.kt
index ded3dcf..6fec552 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/display/ArmorDisplay.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/display/ArmorDisplay.kt
@@ -1,106 +1,70 @@
-package com.willfp.ecoarmor.display;
+package com.willfp.ecoarmor.display
-import com.willfp.eco.core.EcoPlugin;
-import com.willfp.eco.core.display.DisplayModule;
-import com.willfp.eco.core.display.DisplayPriority;
-import com.willfp.eco.core.fast.FastItemStack;
-import com.willfp.eco.util.SkullUtils;
-import com.willfp.ecoarmor.sets.ArmorSet;
-import com.willfp.ecoarmor.sets.meta.ArmorSlot;
-import com.willfp.ecoarmor.sets.util.ArmorUtils;
-import com.willfp.ecoarmor.upgrades.Tier;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.inventory.meta.LeatherArmorMeta;
-import org.bukkit.inventory.meta.SkullMeta;
-import org.jetbrains.annotations.NotNull;
+import com.willfp.eco.core.EcoPlugin
+import com.willfp.eco.core.display.DisplayModule
+import com.willfp.eco.core.display.DisplayPriority
+import com.willfp.eco.core.fast.FastItemStack
+import com.willfp.ecoarmor.sets.meta.ArmorSlot
+import com.willfp.ecoarmor.sets.util.ArmorUtils
+import org.bukkit.inventory.ItemStack
+import org.bukkit.inventory.meta.LeatherArmorMeta
-import java.util.ArrayList;
-import java.util.List;
+class ArmorDisplay(plugin: EcoPlugin) : DisplayModule(plugin, DisplayPriority.LOWEST) {
+ override fun display(
+ itemStack: ItemStack,
+ vararg args: Any
+ ) {
+ val meta = itemStack.itemMeta ?: return
-public class ArmorDisplay extends DisplayModule {
- /**
- * Create armor display.
- *
- * @param plugin Instance of EcoArmor.
- */
- public ArmorDisplay(@NotNull final EcoPlugin plugin) {
- super(plugin, DisplayPriority.LOWEST);
- }
+ val fis = FastItemStack.wrap(itemStack)
- @Override
- public void display(@NotNull final ItemStack itemStack,
- @NotNull final Object... args) {
- ItemMeta meta = itemStack.getItemMeta();
- if (meta == null) {
- return;
- }
- FastItemStack fis = FastItemStack.wrap(itemStack);
-
- ArmorSet set = ArmorUtils.getSetOnItem(meta);
+ val set = ArmorUtils.getSetOnItem(meta)
if (set == null) {
- Tier crystalTier = ArmorUtils.getCrystalTier(meta);
+ val crystalTier = ArmorUtils.getCrystalTier(meta)
if (crystalTier != null) {
- List lore = fis.getLore();
- lore.addAll(FastItemStack.wrap(crystalTier.getCrystal()).getLore());
- fis.setLore(lore);
+ val lore = fis.lore
+ lore.addAll(FastItemStack.wrap(crystalTier.crystal).lore)
+ fis.lore = lore
}
- ArmorSet shardSet = ArmorUtils.getShardSet(meta);
+ val shardSet = ArmorUtils.getShardSet(meta)
if (shardSet != null) {
- List lore = fis.getLore();
- lore.addAll(FastItemStack.wrap(shardSet.getAdvancementShardItem()).getLore());
-
- itemStack.setItemMeta(shardSet.getAdvancementShardItem().getItemMeta());
- FastItemStack.wrap(itemStack).setLore(lore);
+ val lore = fis.lore
+ lore.addAll(FastItemStack.wrap(shardSet.advancementShardItem).lore)
+ itemStack.itemMeta = shardSet.advancementShardItem.itemMeta
+ FastItemStack.wrap(itemStack).lore = lore
}
- return;
+ return
}
- ArmorSlot slot = ArmorSlot.getSlot(itemStack);
- if (slot == null) {
- return;
- }
+ val slot = ArmorSlot.getSlot(itemStack) ?: return
- ItemStack slotStack;
-
- if (ArmorUtils.isAdvanced(meta)) {
- slotStack = set.getAdvancedItemStack(slot);
+ val slotStack: ItemStack = if (ArmorUtils.isAdvanced(meta)) {
+ set.getAdvancedItemStack(slot)
} else {
- slotStack = set.getItemStack(slot);
+ set.getItemStack(slot)
}
- ItemMeta slotMeta = slotStack.getItemMeta();
- assert slotMeta != null;
- Tier tier = ArmorUtils.getTier(meta);
+ val slotMeta = slotStack.itemMeta ?: return
- List lore = new ArrayList<>();
-
- for (String s : FastItemStack.wrap(slotStack).getLore()) {
- s = s.replace("%tier%", tier.getDisplayName());
- lore.add(s);
- }
+ val tier = ArmorUtils.getTier(meta) ?: return
+ val lore = FastItemStack.wrap(slotStack).lore.map { it.replace("%tier%", tier.displayName) }.toMutableList()
if (meta.hasLore()) {
- lore.addAll(fis.getLore());
- }
- meta.setDisplayName(slotMeta.getDisplayName());
-
- if (meta instanceof SkullMeta && slotMeta instanceof SkullMeta) {
- if (set.getSkullBase64() != null) {
- SkullUtils.setSkullTexture((SkullMeta) meta, set.getSkullBase64());
- }
+ lore.addAll(fis.lore)
}
- if (meta instanceof LeatherArmorMeta && slotMeta instanceof LeatherArmorMeta) {
- ((LeatherArmorMeta) meta).setColor(((LeatherArmorMeta) slotMeta).getColor());
+ meta.setDisplayName(slotMeta.displayName)
+
+ if (meta is LeatherArmorMeta && slotMeta is LeatherArmorMeta) {
+ meta.setColor(slotMeta.color)
}
- itemStack.setItemMeta(meta);
- FastItemStack.wrap(itemStack).setLore(lore);
+ itemStack.itemMeta = meta
+ FastItemStack.wrap(itemStack).lore = lore
}
}
\ No newline at end of file
diff --git a/eco-core/core-plugin/src/main/resources/ecoarmor.yml b/eco-core/core-plugin/src/main/resources/ecoarmor.yml
index abc7398..8da9da3 100644
--- a/eco-core/core-plugin/src/main/resources/ecoarmor.yml
+++ b/eco-core/core-plugin/src/main/resources/ecoarmor.yml
@@ -1,5 +1,5 @@
sets:
- - name: reaper
+ - id: reaper
conditions: []
effects:
- id: damage_multiplier
@@ -43,19 +43,10 @@ sets:
- ecoarmor:set_reaper_boots
- prismarine_shard
helmet:
- enchants:
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_helmet
- leatherColor: "#303030"
+ item: leather_helmet color:#303030
name: "&cReaper Helmet"
advancedName: "Advanced&c Reaper Helmet"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&c&lREAPER SET BONUS"
- "&8» &cDeal 25% more damage"
@@ -76,19 +67,10 @@ sets:
- nether_star
- air
chestplate:
- enchants:
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_chestplate
- leatherColor: "#303030"
+ item: leather_chestplate color:#303030
name: "&cReaper Chestplate"
advancedName: "Advanced&c Reaper Chestplate"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&c&lREAPER SET BONUS"
- "&8» &cDeal 25% more damage"
@@ -109,16 +91,10 @@ sets:
- nether_star
- air
elytra:
- enchants:
- - id: unbreaking
- level: 3
- material: elytra
+ item: elytra
name: "&cReaper Elytra"
advancedName: "Advanced&c Reaper Elytra"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&c&lREAPER SET BONUS"
- "&8» &cDeal 25% more damage"
@@ -139,19 +115,10 @@ sets:
- nether_star
- air
leggings:
- enchants:
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_leggings
- leatherColor: "#303030"
+ item: leather_leggings color:#303030
name: "&cReaper Leggings"
advancedName: "Advanced&c Reaper Leggings"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&c&lREAPER SET BONUS"
- "&8» &cDeal 25% more damage"
@@ -172,19 +139,10 @@ sets:
- nether_star
- air
boots:
- enchants:
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_boots
- leatherColor: "#303030"
+ item: leather_boots color:#303030
name: "&cReaper Boots"
advancedName: "Advanced&c Reaper Boots"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&c&lREAPER SET BONUS"
- "&8» &cDeal 25% more damage"
@@ -204,7 +162,7 @@ sets:
- air
- nether_star
- air
- - name: slayer
+ - id: slayer
conditions: []
effects:
- id: damage_multiplier
@@ -258,21 +216,10 @@ sets:
- ecoarmor:set_slayer_boots
- prismarine_shard
helmet:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_helmet
- leatherColor: "#750909"
+ item: leather_helmet color:#750909
name: "&4Slayer Helmet"
advancedName: "Advanced&4 Slayer Helmet"
effectiveDurability: 768
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&4&lSLAYER SET BONUS"
- "&8» &4Deal 50% more damage to bosses"
@@ -294,21 +241,11 @@ sets:
- ecoitems:armor_core ? nether_star
- obsidian
chestplate:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_chestplate
+ item: leather_chestplate color:#750909
leatherColor: "#750909"
name: "&4Slayer Chestplate"
advancedName: "Advanced&4 Slayer Chestplate"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&4&lSLAYER SET BONUS"
- "&8» &4Deal 50% more damage to bosses"
@@ -330,20 +267,10 @@ sets:
- ecoitems:armor_core ? nether_star
- obsidian
elytra:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: elytra
+ item: elytra
name: "&4Slayer Elytra"
advancedName: "Advanced &4Slayer Elytra"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&4&lSLAYER SET BONUS"
- "&8» &4Deal 50% more damage to bosses"
@@ -365,21 +292,10 @@ sets:
- ecoitems:armor_core ? nether_star
- obsidian
leggings:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_leggings
- leatherColor: "#750909"
+ item: leather_leggings color:#750909
name: "&4Slayer Leggings"
advancedName: "Advanced&4 Slayer Leggings"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&4&lSLAYER SET BONUS"
- "&8» &4Deal 50% more damage to bosses"
@@ -401,21 +317,10 @@ sets:
- ecoitems:armor_core ? nether_star
- obsidian
boots:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_boots
- leatherColor: "#750909"
+ item: leather_boots color:#750909
name: "&4Slayer Boots"
advancedName: "Advanced&4 Slayer Boots"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&4&lSLAYER SET BONUS"
- "&8» &4Deal 50% more damage to bosses"
@@ -436,7 +341,7 @@ sets:
- obsidian
- ecoitems:armor_core ? nether_star
- obsidian
- - name: angelic
+ - id: angelic
conditions: []
effects:
- id: bonus_health
@@ -484,21 +389,10 @@ sets:
- ecoarmor:set_angelic_boots
- prismarine_shard
helmet:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_helmet
- leatherColor: "#bd15a9"
+ item: leather_helmet color:#bd15a9
name: "&5Angelic Helmet"
advancedName: "Advanced&5 Angelic Helmet"
effectiveDurability: 768
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&5&lANGELIC SET BONUS"
- "&8» &dGain 10 more hearts"
@@ -521,21 +415,10 @@ sets:
- ecoitems:armor_core ? enchanted_book mending:1
- gold_block
chestplate:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_chestplate
- leatherColor: "#bd15a9"
+ item: leather_chestplate color:#bd15a9
name: "&5Angelic Chestplate"
advancedName: "Advanced&5 Angelic Chestplate"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&5&lANGELIC SET BONUS"
- "&8» &dGain 10 more hearts"
@@ -558,20 +441,10 @@ sets:
- ecoitems:armor_core ? enchanted_book mending:1
- gold_block
elytra:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: elytra
+ item: elytra
name: "&5Angelic Elytra"
advancedName: "Advanced&5 Angelic Elytra"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&5&lANGELIC SET BONUS"
- "&8» &dGain 10 more hearts"
@@ -594,21 +467,11 @@ sets:
- ecoitems:armor_core ? enchanted_book mending:1
- gold_block
leggings:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_leggings
+ item: leather_leggings color:#bd15a9
leatherColor: "#bd15a9"
name: "&5Angelic Leggings"
advancedName: "Advanced&5 Angelic Leggings"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&5&lANGELIC SET BONUS"
- "&8» &dGain 10 more hearts"
@@ -631,21 +494,11 @@ sets:
- ecoitems:armor_core ? enchanted_book mending:1
- gold_block
boots:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_boots
+ item: leather_boots color:#bd15a9
leatherColor: "#bd15a9"
name: "&5Angelic Boots"
advancedName: "Advanced&5 Angelic Boots"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModeldata: -1
lore:
- "&5&lANGELIC SET BONUS"
- "&8» &dGain 10 more hearts"
@@ -667,7 +520,7 @@ sets:
- gold_block
- ecoitems:armor_core ? enchanted_book mending:1
- gold_block
- - name: huntress
+ - id: huntress
conditions: []
effects:
- id: damage_multiplier
@@ -721,21 +574,10 @@ sets:
- ecoarmor:set_huntress_boots
- prismarine_shard
helmet:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_helmet
- leatherColor: "#97fbfc"
+ item: leather_helmet color:#96fbfc
name: "&bHuntress Helmet"
advancedName: "Advanced&b Huntress Helmet"
effectiveDurability: 1024
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&b&lHUNTRESS SET BONUS"
- "&8» &bDeal 2.5x trident damage"
@@ -765,14 +607,10 @@ sets:
level: 4
- id: unbreaking
level: 3
- material: leather_chestplate
- leatherColor: "#97fbfc"
+ item: leather_chestplate color:#97fbfc
name: "&bHuntress Chestplate"
advancedName: "Advanced&b Huntress Chestplate"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&b&lHUNTRESS SET BONUS"
- "&8» &bDeal 2.5x trident damage"
@@ -795,20 +633,10 @@ sets:
- enchanted_book power:5
- spectral_arrow
elytra:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: elytra
+ item: elytra
name: "&bHuntress Elytra"
advancedName: "Advanced&b Huntress Elytra"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&b&lHUNTRESS SET BONUS"
- "&8» &bDeal 2.5x trident damage"
@@ -831,21 +659,10 @@ sets:
- enchanted_book power:5
- spectral_arrow
leggings:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_leggings
- leatherColor: "#97fbfc"
+ item: leather_leggings color:#97fbfc
name: "&bHuntress Leggings"
advancedName: "Advanced&b Huntress Leggings"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModelData: -1
lore:
- "&b&lHUNTRESS SET BONUS"
- "&8» &bDeal 2.5x trident damage"
@@ -868,21 +685,10 @@ sets:
- enchanted_book power:5
- spectral_arrow
boots:
- enchants:
- - id: evasion
- level: 3
- - id: protection
- level: 4
- - id: unbreaking
- level: 3
- material: leather_boots
- leatherColor: "#97fbfc"
+ item: leather_boots color:#97fbfc
name: "&bHuntress Boots"
advancedName: "Advanced&b Huntress Boots"
effectiveDurability: 2048
- unbreakable: false
- flags: []
- customModeldata: -1
lore:
- "&b&lHUNTRESS SET BONUS"
- "&8» &bDeal 2.5x trident damage"
@@ -905,7 +711,7 @@ sets:
- enchanted_book power:5
- spectral_arrow
tiers:
- - name: default
+ - id: default
display: "&8&lDEFAULT"
requiresTiers: []
crystal:
@@ -967,7 +773,7 @@ tiers:
attackSpeedPercentage: 0
attackDamagePercentage: 0
attackKnockbackPercentage: 0
- - name: iron
+ - id: iron
display: "&7&lIRON"
requiresTiers:
- default
@@ -1032,7 +838,7 @@ tiers:
attackSpeedPercentage: 0
attackDamagePercentage: 0
attackKnockbackPercentage: 0
- - name: diamond
+ - id: diamond
display: "&b&lDIAMOND"
requiresTiers:
- iron
@@ -1097,7 +903,7 @@ tiers:
attackSpeedPercentage: 0
attackDamagePercentage: 0
attackKnockbackPercentage: 0
- - name: netherite
+ - id: netherite
display: "&c&lNETHERITE"
requiresTiers:
- diamond
@@ -1162,7 +968,7 @@ tiers:
attackSpeedPercentage: 0
attackDamagePercentage: 0
attackKnockbackPercentage: 0
- - name: manyullyn
+ - id: manyullyn
display: "&d&k!!&r &lMANYULLYN&r &d&k!!&r"
requiresTiers:
- netherite
@@ -1227,7 +1033,7 @@ tiers:
attackSpeedPercentage: 0
attackDamagePercentage: 0
attackKnockbackPercentage: 0
- - name: cobalt
+ - id: cobalt
display: "/ab&lCOBALT"
requiresTiers:
- iron
@@ -1292,7 +1098,7 @@ tiers:
attackSpeedPercentage: -10
attackDamagePercentage: 0
attackKnockbackPercentage: 10
- - name: osmium
+ - id: osmium
display: "&b&k!!&r &lOSMIUM&r &b&k!!"
requiresTiers:
- cobalt
@@ -1357,7 +1163,7 @@ tiers:
attackSpeedPercentage: -15
attackDamagePercentage: 5
attackKnockbackPercentage: 25
- - name: exotic
+ - id: exotic
display: "&6&k!!&r &lEXOTIC&r &6&k!!&r"
requiresTiers:
- netherite
@@ -1422,7 +1228,7 @@ tiers:
attackSpeedPercentage: 10
attackDamagePercentage: -5
attackKnockbackPercentage: -20
- - name: ancient
+ - id: ancient
display: "&6&k!!&r &lANCIENT&r &6&k!!&r"
requiresTiers: []
crystal:
@@ -1484,7 +1290,7 @@ tiers:
attackSpeedPercentage: 5
attackDamagePercentage: 0
attackKnockbackPercentage: 0
- - name: mythic
+ - id: mythic
display: "&1&k!!&r &lMYTHIC&r &1&k!!&r"
requiresTiers: []
crystal: