From 8e64fb8c21b94ad9437ace5352e2996758d7443f Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 23 Apr 2016 20:39:16 +0100 Subject: [PATCH] Add magical unknown protocol version, so that if it's not registered it doesn't NPE. --- .../us/myles/ViaVersion/api/protocol/ProtocolVersion.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index b8bcf6c01..7a366be27 100644 --- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -37,7 +37,11 @@ public class ProtocolVersion { } public static ProtocolVersion getProtocol(int id) { - return versions.get(id); + if (versions.containsKey(id)) { + return versions.get(id); + } else { + return new ProtocolVersion(id, "Unknown (" + id + ")"); + } } public static List getProtocols() {