From 4e5e16ccac3c4d3edd701e48845d28b4f9c866d1 Mon Sep 17 00:00:00 2001 From: Jules Date: Wed, 12 Jul 2023 19:28:17 +0200 Subject: [PATCH] Safe check on dupe stat registration --- MMOItems-API/pom.xml | 2 +- .../java/net/Indyuce/mmoitems/manager/StatManager.java | 9 +++++++++ MMOItems-Dist/pom.xml | 4 ++-- pom.xml | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/MMOItems-API/pom.xml b/MMOItems-API/pom.xml index 7af3f6e4..f2dd9c87 100644 --- a/MMOItems-API/pom.xml +++ b/MMOItems-API/pom.xml @@ -5,7 +5,7 @@ MMOItems net.Indyuce - 6.9.4-SNAPSHOT + 6.9.5-SNAPSHOT jar 4.0.0 diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java index 3a5cb60b..c0089f5f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java @@ -167,10 +167,19 @@ public class StatManager { * @param stat The stat to register */ public void register(@NotNull ItemStat stat) { + + // Skip disabled stats. if (!stat.isEnabled()) return; + // Safe check, this can happen with numerous extra RPG plugins + if (stats.containsKey(stat.getId())) { + MMOItems.plugin.getLogger().log(Level.WARNING, "Could not register stat '" + stat.getId() + "' as a stat with the same ID already exists."); + return; + } + stats.put(stat.getId(), stat); + // Custom registries if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE)) numeric.add((DoubleStat) stat); if (stat instanceof ItemRestriction) itemRestriction.add((ItemRestriction) stat); diff --git a/MMOItems-Dist/pom.xml b/MMOItems-Dist/pom.xml index 7e18b291..b15ab96d 100644 --- a/MMOItems-Dist/pom.xml +++ b/MMOItems-Dist/pom.xml @@ -5,7 +5,7 @@ MMOItems net.Indyuce - 6.9.4-SNAPSHOT + 6.9.5-SNAPSHOT jar 4.0.0 @@ -30,7 +30,7 @@ net.Indyuce MMOItems-API - 6.9.4-SNAPSHOT + 6.9.5-SNAPSHOT true diff --git a/pom.xml b/pom.xml index a6a9b9f3..21000e31 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ net.Indyuce MMOItems pom - 6.9.4-SNAPSHOT + 6.9.5-SNAPSHOT MMOItems-API @@ -56,7 +56,7 @@ io.lumine MythicLib-dist - 1.6-SNAPSHOT + 1.6.2-SNAPSHOT provided