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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 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.

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

              Created:
              Updated:
              Resolved: