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> <parent>
<artifactId>MMOItems</artifactId> <artifactId>MMOItems</artifactId>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<version>6.9.4-SNAPSHOT</version> <version>6.9.5-SNAPSHOT</version>
</parent> </parent>
<packaging>jar</packaging> <packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -167,10 +167,19 @@ public class StatManager {
* @param stat The stat to register * @param stat The stat to register
*/ */
public void register(@NotNull ItemStat<?, ?> stat) { public void register(@NotNull ItemStat<?, ?> stat) {
// Skip disabled stats.
if (!stat.isEnabled()) return; 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); stats.put(stat.getId(), stat);
// Custom registries
if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE)) if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE))
numeric.add((DoubleStat) stat); numeric.add((DoubleStat) stat);
if (stat instanceof ItemRestriction) itemRestriction.add((ItemRestriction) stat); if (stat instanceof ItemRestriction) itemRestriction.add((ItemRestriction) stat);

View File

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

View File

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