diff options
author | feildmaster <admin@feildmaster.com> | 2013-01-19 00:39:56 -0600 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2013-01-19 08:14:17 -0600 |
commit | 6a499c8589abd6f44e49d02339aa2fa503a377b1 (patch) | |
tree | 4ea0b72373dd347c2af4f27a7ebd935980f65a6e | |
parent | d834ca4c6c6dd051e49ee177eb527c7494bd47bc (diff) | |
download | craftbukkit-6a499c8589abd6f44e49d02339aa2fa503a377b1.tar craftbukkit-6a499c8589abd6f44e49d02339aa2fa503a377b1.tar.gz craftbukkit-6a499c8589abd6f44e49d02339aa2fa503a377b1.tar.lz craftbukkit-6a499c8589abd6f44e49d02339aa2fa503a377b1.tar.xz craftbukkit-6a499c8589abd6f44e49d02339aa2fa503a377b1.zip |
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.
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index e37734c3..c6ac1589 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -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.record = new ItemStack(Item.byId[record.getId()], 1); jukebox.update(); if (record == Material.AIR) { world.getHandle().setData(getX(), getY(), getZ(), 0); |