Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7886

attributeModifier.getUniqueId() throws IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Windows 10, Java 21, Spigot 1.21.1

    • CraftBukkit version 4300-Spigot-a759b62-7070de8 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • AttributeBug
    • Yes

      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.

            Unassigned Unassigned
            knokko Tim van de Klundert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: