From 2d38231101f289b4640a1e68c57fbdcbe8b0dd24 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Thu, 21 Dec 2017 08:22:57 +0100 Subject: [PATCH] Small performance improvement in CargoManager done by saving the blockinfo to avoid heavy calls. Would probably need later a more reliable "rewrite". Fixes https://github.com/TheBusyBiscuit/Slimefun4/issues/514 --- .../Slimefun/api/item_transport/CargoManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java b/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java index 5bca98cc3..0a21f4b63 100644 --- a/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java +++ b/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java @@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.api.item_transport; import java.util.ArrayList; import java.util.List; +import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager.DataType; @@ -194,11 +195,13 @@ public class CargoManager { String id = BlockStorage.checkID(block); if (id.equals("CARGO_NODE_OUTPUT")) return true; + Config blockInfo = BlockStorage.getBlockInfo(block); // Store the returned Config instance to avoid heavy calls + BlockMenu menu = BlockStorage.getInventory(block.getLocation()); - boolean lore = BlockStorage.getBlockInfo(block, "filter-lore").equals("true"); - boolean data = BlockStorage.getBlockInfo(block, "filter-durability").equals("true"); + boolean lore = blockInfo.getString("filter-lore").equals("true"); + boolean data = blockInfo.getString("filter-durability").equals("true"); - if (BlockStorage.getBlockInfo(block, "filter-type").equals("whitelist")) { + if (blockInfo.getString("filter-type").equals("whitelist")) { List items = new ArrayList(); for (int slot: slots) { ItemStack template = menu.getItemInSlot(slot);