mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 21:19:00 +01:00
Fix broken null contract with Jukebox.setPlaying, Fixes BUKKIT-3429
The javadocs state that a null may be used to remove the currently playing sound, however this causes a NullPointerException. It also doesn't process registering the record correctly, along with processing non-valid items.
This commit is contained in:
parent
d834ca4c6c
commit
6a499c8589
@ -23,14 +23,20 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
}
|
||||
|
||||
public Material getPlaying() {
|
||||
return Material.getMaterial(jukebox.record.id);
|
||||
ItemStack record = jukebox.record;
|
||||
if (record == null) {
|
||||
return Material.AIR;
|
||||
}
|
||||
return Material.getMaterial(record.id);
|
||||
}
|
||||
|
||||
public void setPlaying(Material record) {
|
||||
if (record == null) {
|
||||
if (record == null || Item.byId[record.getId()] == null) {
|
||||
record = Material.AIR;
|
||||
}
|
||||
jukebox.record = null;
|
||||
} else {
|
||||
jukebox.record = new ItemStack(Item.byId[record.getId()], 1);
|
||||
}
|
||||
jukebox.update();
|
||||
if (record == Material.AIR) {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 0);
|
||||
|
Loading…
Reference in New Issue
Block a user