[SPIGOT-6935] Arrow#getColor IllegalArgumentException Created: 16/Feb/22 Updated: 18/Feb/22 Resolved: 18/Feb/22 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | JishunaMatata | Assignee: | Doc |
Resolution: | Fixed | Votes: | 0 |
Labels: | Arrow |
Version: | 3433-Spigot-699290c-c0326c2 (MC: 1.18.1) |
Guidelines Read: | Yes |
Description |
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.
|
Comments |
Comment by Doc [ 16/Feb/22 ] |
Created PR for this case, the method still throw a error but can validate using a #hasColor method. EDIT: Added clearColor for set the color in -1 like NMS https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/728/overview https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1014/overview |