mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
optimize Cargo Node's filter index saving.
This commit is contained in:
parent
ebd8974155
commit
ec6698602c
@ -256,31 +256,32 @@ final class CargoUtils {
|
|||||||
boolean lore = "true".equals(blockInfo.getString("filter-lore"));
|
boolean lore = "true".equals(blockInfo.getString("filter-lore"));
|
||||||
|
|
||||||
if ("whitelist".equals(blockInfo.getString("filter-type"))) {
|
if ("whitelist".equals(blockInfo.getString("filter-type"))) {
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> templateItems = new ArrayList<>();
|
||||||
|
|
||||||
for (int slot : SLOTS) {
|
for (int slot : SLOTS) {
|
||||||
ItemStack template = menu.getItemInSlot(slot);
|
ItemStack template = menu.getItemInSlot(slot);
|
||||||
if (template != null) {
|
if (template != null) {
|
||||||
items.add(template);
|
templateItems.add(template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.isEmpty()) {
|
if (templateItems.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
index++;
|
index++;
|
||||||
if (index > (items.size() - 1)) index = 0;
|
if (index > (templateItems.size() - 1)) index = 0;
|
||||||
|
|
||||||
BlockStorage.addBlockInfo(block, "index", String.valueOf(index));
|
blockInfo.setValue("index", String.valueOf(index));
|
||||||
|
BlockStorage.setBlockInfo(block, blockInfo, false);
|
||||||
|
|
||||||
return SlimefunUtils.isItemSimilar(item, items.get(index), lore);
|
return SlimefunUtils.isItemSimilar(item, templateItems.get(index), lore);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (ItemStack stack : items) {
|
for (ItemStack stack : templateItems) {
|
||||||
if (SlimefunUtils.isItemSimilar(item, stack, lore)) {
|
if (SlimefunUtils.isItemSimilar(item, stack, lore)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ public class BlockStorage {
|
|||||||
|
|
||||||
private static final String PATH_BLOCKS = "data-storage/Slimefun/stored-blocks/";
|
private static final String PATH_BLOCKS = "data-storage/Slimefun/stored-blocks/";
|
||||||
private static final String PATH_CHUNKS = "data-storage/Slimefun/stored-chunks/";
|
private static final String PATH_CHUNKS = "data-storage/Slimefun/stored-chunks/";
|
||||||
|
private static final String PATH_INVENTORIES = "data-storage/Slimefun/stored-inventories/";
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
private final Map<Location, Config> storage = new ConcurrentHashMap<>();
|
private final Map<Location, Config> storage = new ConcurrentHashMap<>();
|
||||||
@ -450,14 +451,13 @@ public class BlockStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!storage.hasInventory(l)) {
|
else if (!storage.hasInventory(l)) {
|
||||||
File file = new File("data-storage/Slimefun/stored-inventories/" + serializeLocation(l) + ".sfi");
|
File file = new File(PATH_INVENTORIES + serializeLocation(l) + ".sfi");
|
||||||
|
|
||||||
if (file.exists()) storage.inventories.put(l, new BlockMenu(BlockMenuPreset.getPreset(id), l, new io.github.thebusybiscuit.cscorelib2.config.Config(file)));
|
if (file.exists()) storage.inventories.put(l, new BlockMenu(BlockMenuPreset.getPreset(id), l, new io.github.thebusybiscuit.cscorelib2.config.Config(file)));
|
||||||
else storage.loadInventory(l, BlockMenuPreset.getPreset(id));
|
else storage.loadInventory(l, BlockMenuPreset.getPreset(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshCache(getStorage(l.getWorld()), l, id, serializeBlockInfo(cfg), updateTicker);
|
refreshCache(storage, l, id, serializeBlockInfo(cfg), updateTicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBlockInfo(Block b, String json, boolean updateTicker) {
|
public static void setBlockInfo(Block b, String json, boolean updateTicker) {
|
||||||
|
Loading…
Reference in New Issue
Block a user