From 03379f767d103172a2783e59ecde342375528906 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Sun, 23 Aug 2015 12:48:33 -0700 Subject: [PATCH] Update usages of MagicValues.key to account for throwing IllegalArgumentException instead of returning null. --- .../ingame/server/window/ServerWindowPropertyPacket.java | 2 +- .../ingame/server/world/ServerBlockBreakAnimPacket.java | 5 +++-- .../packet/ingame/server/world/ServerPlaySoundPacket.java | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java index f687af73..4c3cc0ff 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java @@ -39,7 +39,7 @@ public class ServerWindowPropertyPacket implements Packet { } public & WindowProperty> T getProperty(Class type) { - return MagicValues.key(type, value); + return MagicValues.key(type, this.value); } public int getValue() { diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java index 32bade81..3e7981ea 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java @@ -42,8 +42,9 @@ public class ServerBlockBreakAnimPacket implements Packet { public void read(NetInput in) throws IOException { this.breakerEntityId = in.readVarInt(); this.position = NetUtil.readPosition(in); - this.stage = MagicValues.key(BlockBreakStage.class, in.readUnsignedByte()); - if(this.stage == null) { + try { + this.stage = MagicValues.key(BlockBreakStage.class, in.readUnsignedByte()); + } catch(IllegalArgumentException e) { this.stage = BlockBreakStage.RESET; } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java index afce8ffc..7a0366c7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java @@ -59,8 +59,9 @@ public class ServerPlaySoundPacket implements Packet { @Override public void read(NetInput in) throws IOException { String value = in.readString(); - this.sound = MagicValues.key(GenericSound.class, value); - if(this.sound == null) { + try { + this.sound = MagicValues.key(GenericSound.class, value); + } catch(IllegalArgumentException e) { this.sound = new CustomSound(value); }