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

Arrow#getColor IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 3433-Spigot-699290c-c0326c2 (MC: 1.18.1)
    • Yes

      Calling getColor on a regular arrow will produce the folloing exception:

      Caused by: java.lang.IllegalArgumentException: Extrenuous data in: -1
          at org.apache.commons.lang.Validate.isTrue(Validate.java:93) ~[commons-lang-2.6.jar:2.6]
          at org.bukkit.Color.fromRGB(Color.java:147) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
          at org.bukkit.craftbukkit.v1_18_R1.entity.CraftTippedArrow.getColor(CraftTippedArrow.java:124) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3433-Spigot-699290c-c0326c2] 

      This is due to the fact that Mojang uses -1 to indicate an arrow has no colour (and thus produces no particles) This can reproduced by creating a plugin with this simple listener and shooting a regular arrow from a bow:

          @EventHandler
          public void onShoot(EntityShootBowEvent event) {
              if (!(event.getProjectile() instanceof Arrow arrow)) {
                  return;
              }
              
              Bukkit.broadcastMessage(arrow.getColor().toString());
          } 

      Due to this it is also impossible to remove an arrows colour (set it to -1) since setColor only accepts a Color as an argument.

       

            Doc Doc
            joshl5324@gmail.com JishunaMatata
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: