Hi, thank you for developing this awesome plugin. I found a small issue.
Although createAttributeModifier receives a UUID, this method uses
new NamespacedKey(platform.getPlugin(), "modifier")
instead of using the UUID.
|
protected AttributeModifier createAttributeModifier(UUID attributeUUID, double value, AttributeModifier.Operation operation, EquipmentSlotGroup equipmentSlotGroup) { |
|
NamespacedKey namespacedKey = new NamespacedKey(platform.getPlugin(), "modifier"); |
|
return new AttributeModifier(namespacedKey, value, operation, equipmentSlotGroup); |
|
} |
new NamespacedKey(platform.getPlugin(), "modifier") always creates the same key:
magic:modifier.
Therefore, all modifiers created by this method have the same NamespacedKey. This causes the following error when multiple AttributeModifiers are added to the same Attribute:
[16:39:36 WARN]: java.lang.IllegalArgumentException: Cannot register AttributeModifier. Modifier is already applied! AttributeModifier{key=magic:modifier, operation=ADD_NUMBER, amount=0.02, slot=offhand}
[16:39:36 WARN]: at com.google.common.base.Preconditions.checkArgument(Preconditions.java:218)
[16:39:36 WARN]: at org.bukkit.craftbukkit.inventory.CraftMetaItem.addAttributeModifier(CraftMetaItem.java:1735)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.utility.platform.base_v1_20_5.CompatibilityUtilsBase.setItemAttribute(CompatibilityUtilsBase.java:1934)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.utility.platform.base_v1_20_5.InventoryUtilsBase.applyAttributes(InventoryUtilsBase.java:205)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.wand.Wand.updateItem(Wand.java:5989)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.wand.Wand.setMage(Wand.java:5983)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.wand.Wand.activate(Wand.java:5797)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.wand.Wand.activate(Wand.java:5733)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.magic.Mage.checkMainhandWand(Mage.java:1746)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.magic.Mage.checkWand(Mage.java:1761)
[16:39:36 WARN]: at Magic-10.11.1.jar//com.elmakers.mine.bukkit.tasks.CheckWandTask.run(CheckWandTask.java:21)
[16:39:36 WARN]: at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78)
[16:39:36 WARN]: at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
[16:39:36 WARN]: at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1663)
[16:39:36 WARN]: at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1531)
[16:39:36 WARN]: at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1253)
[16:39:36 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:310)
[16:39:36 WARN]: at java.base/java.lang.Thread.run(Thread.java:1575)
A possible fix would be to generate the NamespacedKey from the UUID, for example:
new NamespacedKey(platform.getPlugin(), attributeUUID.toString())
Environment:
・Magic: 10.11.11-160c3cf
・Paper: 1.21.8-56-65641d1
Hi, thank you for developing this awesome plugin. I found a small issue.
Although
createAttributeModifierreceives a UUID, this method usesnew NamespacedKey(platform.getPlugin(), "modifier")instead of using the UUID.
MagicPlugin/CompatibilityLib/base/src/main/java/com/elmakers/mine/bukkit/utility/platform/base/CompatibilityUtilsBase.java
Lines 1994 to 1997 in d494ccd
new NamespacedKey(platform.getPlugin(), "modifier")always creates the same key:magic:modifier.Therefore, all modifiers created by this method have the same NamespacedKey. This causes the following error when multiple AttributeModifiers are added to the same Attribute:
A possible fix would be to generate the NamespacedKey from the UUID, for example:
Environment:
・Magic: 10.11.11-160c3cf
・Paper: 1.21.8-56-65641d1