mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 11:36:51 +01:00
Throw a more descriptive error of a packet type hasn't got a class.
This commit is contained in:
parent
6e3583b300
commit
96cc518fb0
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user