From 61587ec320089278c69d6146b6e35f05cc0dfe84 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sat, 25 Apr 2020 17:56:19 -0500 Subject: [PATCH] Use Int2ObjectMap in InventoryCache and JavaServerDeclareCommandsTranslator --- .../connector/network/session/cache/InventoryCache.java | 7 +++---- .../java/JavaServerDeclareCommandsTranslator.java | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/InventoryCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/InventoryCache.java index 8734c710..032f6402 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/InventoryCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/InventoryCache.java @@ -25,14 +25,13 @@ package org.geysermc.connector.network.session.cache; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import lombok.Getter; import lombok.Setter; import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; -import java.util.HashMap; -import java.util.Map; - public class InventoryCache { private GeyserSession session; @@ -42,7 +41,7 @@ public class InventoryCache { private Inventory openInventory; @Getter - private Map inventories = new HashMap(); + private Int2ObjectMap inventories = new Int2ObjectOpenHashMap<>(); public InventoryCache(GeyserSession session) { this.session = session; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java index edc20a64..d57b8948 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java @@ -32,6 +32,8 @@ import com.nukkitx.protocol.bedrock.data.CommandData; import com.nukkitx.protocol.bedrock.data.CommandEnumData; import com.nukkitx.protocol.bedrock.data.CommandParamData; import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import lombok.Getter; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.GeyserSession; @@ -45,8 +47,8 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator commandData = new ArrayList<>(); - Map commands = new HashMap<>(); - Map> commandArgs = new HashMap<>(); + Int2ObjectMap commands = new Int2ObjectOpenHashMap<>(); + Int2ObjectMap> commandArgs = new Int2ObjectOpenHashMap<>(); // Get the first node, it should be a root node CommandNode rootNode = packet.getNodes()[packet.getFirstNodeIndex()];