Throw a more descriptive error of a packet type hasn't got a class.

This commit is contained in:
Kristian S. Stangeland 2014-01-30 02:04:38 +01:00
parent 6e3583b300
commit 96cc518fb0

View File

@ -60,7 +60,12 @@ public class StructureCache {
*/
public static Object newPacket(PacketType type) {
try {
return PacketRegistry.getPacketClassFromType(type, true).newInstance();
Class<?> clazz = PacketRegistry.getPacketClassFromType(type, true);
// Check the return value
if (clazz != null)
return clazz.newInstance();
throw new IllegalArgumentException("Cannot find associated packet class: " + type);
} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {