[SPIGOT-7886] attributeModifier.getUniqueId() throws IllegalArgumentException Created: 28/Aug/24  Updated: 25/Dec/24  Resolved: 28/Aug/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Tim van de Klundert Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: api
Environment:

Windows 10, Java 21, Spigot 1.21.1


Attachments: File attribute-bug.jar    
Version: CraftBukkit version 4300-Spigot-a759b62-7070de8 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
Plugin: AttributeBug
Guidelines Read: Yes

 Description   

When I call the getUniqueId() method of an AttributeModifier instance on Spigot/Paper 1.21, an IllegalArgumentException will be thrown:

 

org.bukkit.command.CommandException: Unhandled exception executing command 'attributes' in plugin AttributeBug v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:150) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_21_R1.CraftServer.dispatchCommand(CraftServer.java:921) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at org.bukkit.craftbukkit.v1_21_R1.CraftServer.dispatchServerCommand(CraftServer.java:906) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at net.minecraft.server.dedicated.DedicatedServer.br(DedicatedServer.java:431) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at net.minecraft.server.dedicated.DedicatedServer.c(DedicatedServer.java:407) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1321) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1071) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4300-Spigot-a759b62-7070de8]
        at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.IllegalArgumentException: Invalid UUID string: minecraft:base_attack_damage
        at java.base/java.util.UUID.fromString1(UUID.java:282) ~[?:?]
        at java.base/java.util.UUID.fromString(UUID.java:260) ~[?:?]
        at org.bukkit.attribute.AttributeModifier.getUniqueId(AttributeModifier.java:68) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
        at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
        at nl.knokko.attribute.AttributePlugin.onCommand(AttributePlugin.java:23) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
        ... 9 more 

This can be reproduced by the following code:

@SuppressWarnings("unused")
public class AttributePlugin extends JavaPlugin {

    @Override
    public void onEnable() {
       getCommand("attributes").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
       var attributes = Material.IRON_SWORD.getDefaultAttributeModifiers(EquipmentSlot.HAND);

       //noinspection ResultOfMethodCallIgnored
       attributes.values().forEach(AttributeModifier::getUniqueId);
       sender.sendMessage("Success! There were " + attributes.size() + " attributes");

       return true;
    }
} 

For reproducing convenience, the plug-in is added as attachment. When the plug-in is enabled, you can run the /attributes command to reproduce it.

 

I'm not entirely sure what the desired behavior is, but it's definitely not just throwing some exception. If possible, the implementation should return some fixed UUID. If not, this method should probably be removed from the API.


Generated at Sat Dec 13 11:53:36 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.