diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java index b629ab98f..ff57ebdb8 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java @@ -429,7 +429,7 @@ public abstract class Protocol0x" + toNiceHex(newId)); + + " IN REMAP OF " + toNiceHex(oldId) + "->" + toNiceHex(newId)); } throw e; } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java index 2e914f432..24c9255d4 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.Map; public class BlockIdData { + public static final String[] PREVIOUS = new String[0]; public static Map blockIdMapping; public static Map fallbackReverseMapping; public static Int2ObjectMap numberIdToString; @@ -20,44 +21,36 @@ public class BlockIdData { public static void init() { InputStream stream = MappingData.class.getClassLoader() .getResourceAsStream("assets/viaversion/data/blockIds1.12to1.13.json"); - InputStreamReader reader = new InputStreamReader(stream); - try { - blockIdMapping = new HashMap<>(GsonUtil.getGson().fromJson( + try (InputStreamReader reader = new InputStreamReader(stream)) { + Map map = GsonUtil.getGson().fromJson( reader, new TypeToken>() { - }.getType() - ), 1F); + }.getType()); + blockIdMapping = new HashMap<>(map); fallbackReverseMapping = new HashMap<>(); for (Map.Entry entry : blockIdMapping.entrySet()) { for (String val : entry.getValue()) { String[] previous = fallbackReverseMapping.get(val); - if (previous == null) previous = new String[0]; + if (previous == null) previous = PREVIOUS; fallbackReverseMapping.put(val, ObjectArrays.concat(previous, entry.getKey())); } } - } finally { - try { - reader.close(); - } catch (IOException ignored) { - // Ignored - } + } catch (IOException e) { + e.printStackTrace(); } InputStream blockS = MappingData.class.getClassLoader() .getResourceAsStream("assets/viaversion/data/blockNumberToString1.12.json"); - InputStreamReader blockR = new InputStreamReader(blockS); - try { - numberIdToString = new Int2ObjectOpenHashMap<>(GsonUtil.getGson().fromJson( + try (InputStreamReader blockR = new InputStreamReader(blockS)) { + Map map = GsonUtil.getGson().fromJson( blockR, new TypeToken>() { }.getType() - )); - } finally { - try { - blockR.close(); - } catch (IOException ignored) { - // Ignored - } + ); + numberIdToString = new Int2ObjectOpenHashMap<>(map); + } catch (IOException e) { + e.printStackTrace(); } + // Ignored } }