Update usages of MagicValues.key to account for throwing IllegalArgumentException instead of returning null.

This commit is contained in:
Steven Smith 2015-08-23 12:48:33 -07:00
parent 1b913851ee
commit 03379f767d
3 changed files with 7 additions and 5 deletions

View file

@ -39,7 +39,7 @@ public class ServerWindowPropertyPacket implements Packet {
}
public <T extends Enum<T> & WindowProperty> T getProperty(Class<T> type) {
return MagicValues.key(type, value);
return MagicValues.key(type, this.value);
}
public int getValue() {

View file

@ -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;
}
}

View file

@ -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);
}