-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
When validating data provided in World#playEffect(Location loc, Effect effect, T data), CraftBukkit checks if the required Class of data equals the provided one. This is incorrect, as the provided class may extend the required Class.
The line in question:
Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
The fix:
Validate.isTrue(effect.getData().isAssignableFrom(data.getClass()), "Wrong kind of data for this effect!");
To replicate this issue, the following listener can be used.
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!event.hasBlock()) { return; } Block clicked = event.getClickedBlock(); MaterialData data = clicked.getState().getData(); Bukkit.broadcastMessage("Comparing " + Effect.TILE_BREAK.getData() + " and " + data.getClass()); Bukkit.broadcastMessage("Assignable: " + TILE_BREAK.getData().isAssignableFrom(data.getClass())); Bukkit.broadcastMessage("Equal: " + Effect.TILE_BREAK.getData().equals(state.getData().getClass())); clicked.getWorld().playEffect(clicked.getLocation(), Effect.TILE_BREAK, data); }
When clicking a Block with a special MaterialData, such as wheat, an IllegalArgumentException is thrown.
Technically this is a Spigot bug as Craftbukkit does not provide any particles which accept a MaterialData, but I believe it would be better to fix it on the Craftbukkit side as it is a Craftbukkit shortcoming.