attributeModifier.getUniqueId() doesn't match the UUID passed to its constructor

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • CraftBukkit version 4302-Spigot-a759b62-63f9166 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      When I pass a UUID to the constructor of AttributeModifier, I would expect the getUniqueId() method of the newly created attribute modifier to return that same UUID. However, this seems to return a completely different UUID.

       

      The problem is demonstrated by the following code:

      @Override
      public void onEnable() {
          UUID exampleID = UUID.fromString("cdbfab97-f3d1-4b8e-b320-a66c3f0abea5");
          AttributeModifier testModifier = new AttributeModifier(
                exampleID, "generic.attackDamage", 1.0, AttributeModifier.Operation.ADD_NUMBER
          );
          if (exampleID.equals(testModifier.getUniqueId())) Bukkit.broadcastMessage("It works, great job!");
          else throw new RuntimeException("Expected " + exampleID + ", but got " + testModifier.getUniqueId());
      } 

      Running this code on the latest Spigot build results in

      RuntimeException: Expected cdbfab97-f3d1-4b8e-b320-a66c3f0abea5, but got 50e9750c-cc25-3624-acd0-f11b2b383591 

      I believe the correct output would be "It works, great job!".

       

      For reproduction convenience, I added a pre-built version of this 'plug-in' in the attachments.

            Assignee:
            Unassigned
            Reporter:
            Tim van de Klundert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: