From 7364a30f746e125a8823f21cadab79d17e0bb845 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 19 Mar 2021 19:35:16 +0000 Subject: [PATCH 1/4] Added multiple optional required tiers --- .../java/com/willfp/ecoarmor/upgrades/Tier.java | 16 ++++++++-------- .../upgrades/listeners/CrystalListener.java | 8 +++++--- .../src/main/resources/tiers/cobalt.yml | 3 ++- .../src/main/resources/tiers/default.yml | 2 +- .../src/main/resources/tiers/diamond.yml | 3 ++- .../src/main/resources/tiers/exotic.yml | 3 ++- .../src/main/resources/tiers/iron.yml | 3 ++- .../src/main/resources/tiers/manyullyn.yml | 3 ++- .../src/main/resources/tiers/netherite.yml | 3 ++- .../src/main/resources/tiers/osmium.yml | 3 ++- 10 files changed, 28 insertions(+), 19 deletions(-) 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 c211183..b173088 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 @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; public class Tier extends PluginDependent { /** @@ -47,9 +48,9 @@ public class Tier extends PluginDependent { private String displayName; /** - * The name of the tier required for application. + * The names of the tiers required for application. */ - private String requiredTierForApplication; + private List requiredTiersForApplication; /** * If the crafting recipe is enabled. @@ -102,7 +103,7 @@ public class Tier extends PluginDependent { public void update() { this.enabled = this.getConfig().getBool("crystal-craftable"); this.displayName = this.getConfig().getString("display"); - this.requiredTierForApplication = this.getConfig().getString("requires-tier"); + this.requiredTiersForApplication = this.getConfig().getStrings("requires-tiers"); NamespacedKey key = this.getPlugin().getNamespacedKeyFactory().create("upgrade_crystal"); ItemStack out = new ItemStack(Objects.requireNonNull(Material.getMaterial(this.getPlugin().getConfigYml().getString("upgrade-crystal-material").toUpperCase()))); @@ -163,13 +164,12 @@ public class Tier extends PluginDependent { } /** - * Get the required tier for application. + * Get the required tiers for application. * - * @return The tier, or null if 'none' or invalid. + * @return The tiers, or a blank list if always available. */ - @Nullable - public Tier getRequiredTierForApplication() { - return Tiers.getByName(requiredTierForApplication); + public List getRequiredTiersForApplication() { + return requiredTiersForApplication.stream().map(Tiers::getByName).filter(Objects::nonNull).collect(Collectors.toList()); } @Override diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/CrystalListener.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/CrystalListener.java index f3a53bf..fdb98ee 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/CrystalListener.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/upgrades/listeners/CrystalListener.java @@ -12,6 +12,8 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import java.util.List; + public class CrystalListener extends PluginDependent implements Listener { /** * Create new listeners for dragging crystals onto items. @@ -48,11 +50,11 @@ public class CrystalListener extends PluginDependent implements Listener { Tier previousTier = ArmorUtils.getTier(current); boolean allowed = false; - Tier prereq = crystalTier.getRequiredTierForApplication(); + List prereq = crystalTier.getRequiredTiersForApplication(); - if (prereq == null) { + if (prereq.isEmpty()) { allowed = true; - } else if (prereq.equals(previousTier)) { + } else if (prereq.contains(previousTier)) { allowed = true; } diff --git a/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml b/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml index 20efbe6..a348203 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml @@ -1,6 +1,7 @@ enabled: true display: "/ab&lCOBALT" -requires-tier: iron # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - iron crystal-craftable: true crystal-name: "/abCobalt Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/default.yml b/eco-core/core-plugin/src/main/resources/tiers/default.yml index b9c49be..6645637 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/default.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/default.yml @@ -1,5 +1,5 @@ display: "&8&lDEFAULT" -requires-tier: none # Set to 'none' to always allow application +requires-tiers: [] # Leave empty to always allow application crystal-craftable: false crystal-name: "&8Default Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/diamond.yml b/eco-core/core-plugin/src/main/resources/tiers/diamond.yml index 9bb36dc..def3793 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/diamond.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/diamond.yml @@ -1,6 +1,7 @@ enabled: true display: "&b&lDIAMOND" -requires-tier: iron # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - iron crystal-craftable: true crystal-name: "&bDiamond Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/exotic.yml b/eco-core/core-plugin/src/main/resources/tiers/exotic.yml index d8a3215..754127f 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/exotic.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/exotic.yml @@ -1,6 +1,7 @@ enabled: true display: "&6&k!!&r &lEXOTIC&r &6&k!!&r" -requires-tier: netherite # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - netherite crystal-craftable: true crystal-name: "Exotic Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/iron.yml b/eco-core/core-plugin/src/main/resources/tiers/iron.yml index f59292c..52a2398 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/iron.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/iron.yml @@ -1,6 +1,7 @@ enabled: true display: "&7&lIRON" -requires-tier: default # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - default crystal-craftable: true crystal-name: "&7Iron Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml b/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml index 23e864f..f7b8ead 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml @@ -1,6 +1,7 @@ enabled: true display: "&d&k!!&r &lMANYULLYN&r &d&k!!&r" -requires-tier: netherite # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - netherite crystal-craftable: true crystal-name: "Manyullyn Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/netherite.yml b/eco-core/core-plugin/src/main/resources/tiers/netherite.yml index 57278c6..cbcfa47 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/netherite.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/netherite.yml @@ -1,6 +1,7 @@ enabled: true display: "&c&lNETHERITE" -requires-tier: diamond # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - diamond crystal-craftable: true crystal-name: "&cNetherite Upgrade Crystal" crystal-recipe: diff --git a/eco-core/core-plugin/src/main/resources/tiers/osmium.yml b/eco-core/core-plugin/src/main/resources/tiers/osmium.yml index 380d5ff..3de34eb 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/osmium.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/osmium.yml @@ -1,6 +1,7 @@ enabled: true display: "&b&k!!&r &lOSMIUM&r &b&k!!" -requires-tier: cobalt # Set to 'none' to always allow application +requires-tiers: # Leave empty to always allow application + - cobalt crystal-craftable: true crystal-name: "Osmium upgrade crystal" crystal-recipe: From 92f0e44538bedc80ab317fb30e3089c0bf3699b6 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 19 Mar 2021 19:35:31 +0000 Subject: [PATCH 2/4] Updated to 3.50 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 576a4fa..2803d8f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 3.4.0 +version = 3.5.0 plugin-name = EcoArmor \ No newline at end of file From 022d95814514e1f28af5de450fa845eee07d2a43 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 19 Mar 2021 19:35:52 +0000 Subject: [PATCH 3/4] Fixed incorrect commit message --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2803d8f..576a4fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 3.5.0 +version = 3.4.0 plugin-name = EcoArmor \ No newline at end of file From 6214ee54f4c77fdfccb3586705fa7243dc95f1b6 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 19 Mar 2021 19:36:06 +0000 Subject: [PATCH 4/4] Updated to 3.5.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 576a4fa..2803d8f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 3.4.0 +version = 3.5.0 plugin-name = EcoArmor \ No newline at end of file