From 193084927b5cc626114a61d561558d14f0368a0b Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Tue, 15 Jan 2019 14:21:37 -0200 Subject: [PATCH] store constructor --- .../storage/BlockConnectionStorage.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java index 259e9dfe6..6b9a7abdc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java @@ -5,6 +5,7 @@ import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.Position; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; @@ -12,20 +13,20 @@ import java.util.Map; public class BlockConnectionStorage extends StoredObject { private Map> blockStorage = createLongObjectMap(); - private static Class fastUtilLongObjectHashMap; - private static Class fastUtilShortShortHashMap; + private static Constructor fastUtilLongObjectHashMap; + private static Constructor fastUtilShortShortHashMap; static { try { - fastUtilLongObjectHashMap = Class.forName("it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap"); + fastUtilLongObjectHashMap = Class.forName("it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap").getConstructor(); Via.getPlatform().getLogger().info("Using FastUtil Long2ObjectOpenHashMap for block connections"); - } catch (ClassNotFoundException ignored) { + } catch (ClassNotFoundException | NoSuchMethodException ignored) { } try { - fastUtilShortShortHashMap = Class.forName("it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap"); + fastUtilShortShortHashMap = Class.forName("it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap").getConstructor(); Via.getPlatform().getLogger().info("Using FastUtil Short2ShortOpenHashMap for block connections"); - } catch (ClassNotFoundException ignored) { + } catch (ClassNotFoundException | NoSuchMethodException ignored) { } } @@ -91,8 +92,8 @@ public class BlockConnectionStorage extends StoredObject { private Map createLongObjectMap() { if (fastUtilLongObjectHashMap != null) { try { - return (Map) fastUtilLongObjectHashMap.getConstructor().newInstance(); - } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) { + return (Map) fastUtilLongObjectHashMap.newInstance(); + } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { e.printStackTrace(); } } @@ -102,8 +103,8 @@ public class BlockConnectionStorage extends StoredObject { private Map createShortShortMap() { if (fastUtilShortShortHashMap != null) { try { - return (Map) fastUtilShortShortHashMap.getConstructor().newInstance(); - } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) { + return (Map) fastUtilShortShortHashMap.newInstance(); + } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { e.printStackTrace(); } }