Safe check on dupe stat registration

This commit is contained in:
Jules 2023-07-12 19:28:17 +02:00
parent a284fb1a49
commit 4e5e16ccac
4 changed files with 14 additions and 5 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MMOItems</artifactId>
<groupId>net.Indyuce</groupId>
<version>6.9.4-SNAPSHOT</version>
<version>6.9.5-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@ -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);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MMOItems</artifactId>
<groupId>net.Indyuce</groupId>
<version>6.9.4-SNAPSHOT</version>
<version>6.9.5-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
@ -30,7 +30,7 @@
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems-API</artifactId>
<version>6.9.4-SNAPSHOT</version>
<version>6.9.5-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems</artifactId>
<packaging>pom</packaging>
<version>6.9.4-SNAPSHOT</version>
<version>6.9.5-SNAPSHOT</version>
<modules>
<module>MMOItems-API</module>
@ -56,7 +56,7 @@
<dependency>
<groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId>
<version>1.6-SNAPSHOT</version>
<version>1.6.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Jetbrains Annotations -->