From 204dd8dd84c1d97859806f1b334a2d41389083aa Mon Sep 17 00:00:00 2001 From: LobbyTech <1187755698@qq.com> Date: Wed, 6 Nov 2024 07:07:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=87=B31.21.1=20=E5=88=9D?= =?UTF-8?q?=E6=AD=A5=E9=80=82=E9=85=8D=E6=96=B0BS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 16 ++--- .../io/taraxacum/finaltech/FinalTech.java | 59 +++++++++++-------- .../core/enchantment/NullEnchantment.java | 15 ++++- .../core/helper/MachineMaxStack.java | 9 ++- .../core/helper/MachineRecipeLock.java | 5 +- .../finaltech/core/helper/PositionInfo.java | 17 +++--- .../finaltech/core/helper/SlotSearchLine.java | 17 +++--- .../machine/cargo/AdvancedLineTransfer.java | 23 ++++---- .../cargo/AdvancedLocationTransfer.java | 8 ++- .../machine/cargo/AdvancedMeshTransfer.java | 25 ++++---- .../machine/cargo/AdvancedPointTransfer.java | 19 +++--- .../core/item/machine/cargo/LineTransfer.java | 23 ++++---- .../item/machine/cargo/LocationTransfer.java | 2 +- .../core/item/machine/cargo/MeshTransfer.java | 4 +- .../item/machine/cargo/PointTransfer.java | 4 +- .../cargo/storage/StorageInteractPort.java | 7 ++- .../core/menu/clicker/AreaAccessorMenu.java | 9 ++- .../patch/EnergyRegulatorBlockTicker.java | 2 +- .../core/patch/EnergyRegulatorDetailMenu.java | 6 +- .../taraxacum/finaltech/setup/SetupUtil.java | 5 +- 20 files changed, 157 insertions(+), 118 deletions(-) diff --git a/pom.xml b/pom.xml index f584b8e5..ab63ac0f 100644 --- a/pom.xml +++ b/pom.xml @@ -8,8 +8,8 @@ 2.0-preview-2 - 1.17 - 1.17 + 21 + 21 UTF-8 @@ -33,14 +33,14 @@ maven-compiler-plugin 3.10.1 - 17 - 17 + 21 + 21 org.apache.maven.plugins maven-shade-plugin - 3.4.1 + 3.6.0 @@ -77,14 +77,14 @@ org.spigotmc spigot-api - 1.19.3-R0.1-SNAPSHOT + 1.21.1-R0.1-SNAPSHOT provided - com.github.Slimefun + com.github.SlimefunGuguProject Slimefun4 - RC-33 + 2024.3.1 provided diff --git a/src/main/java/io/taraxacum/finaltech/FinalTech.java b/src/main/java/io/taraxacum/finaltech/FinalTech.java index 255fee37..1ac36b2b 100644 --- a/src/main/java/io/taraxacum/finaltech/FinalTech.java +++ b/src/main/java/io/taraxacum/finaltech/FinalTech.java @@ -1,34 +1,41 @@ package io.taraxacum.finaltech; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.taraxacum.common.util.StringNumberUtil; -import io.taraxacum.finaltech.core.patch.EnergyRegulatorBlockTicker; -import io.taraxacum.finaltech.setup.TemplateParser; -import io.taraxacum.finaltech.setup.Updater; -import io.taraxacum.finaltech.util.ConstantTableUtil; -import io.taraxacum.libs.plugin.dto.ConfigFileManager; -import io.taraxacum.libs.plugin.dto.*; -import io.taraxacum.finaltech.setup.FinalTechItemStacks; -import io.taraxacum.finaltech.setup.SetupUtil; -import io.taraxacum.libs.slimefun.dto.ItemValueTable; -import me.mrCookieSlime.Slimefun.api.BlockStorage; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.logging.Logger; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import org.bstats.bukkit.Metrics; import org.bstats.charts.AdvancedPie; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.logging.Logger; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.taraxacum.common.util.StringNumberUtil; +import io.taraxacum.finaltech.core.patch.EnergyRegulatorBlockTicker; +import io.taraxacum.finaltech.setup.FinalTechItemStacks; +import io.taraxacum.finaltech.setup.SetupUtil; +import io.taraxacum.finaltech.setup.Updater; +import io.taraxacum.finaltech.util.ConstantTableUtil; +import io.taraxacum.libs.plugin.dto.ConfigFileManager; +import io.taraxacum.libs.plugin.dto.CustomLogger; +import io.taraxacum.libs.plugin.dto.LanguageManager; +import io.taraxacum.libs.plugin.dto.ServerRunnableLockFactory; +import io.taraxacum.libs.slimefun.dto.ItemValueTable; /** * @author Final_ROOT @@ -315,13 +322,14 @@ public void onDisable() { if (this.bukkitTask != null) { this.bukkitTask.cancel(); } - BlockStorage.saveChunks(); + //BlockStorage.saveChunks(); try { FinalTech.logger().info("Waiting all task to end.(" + FinalTech.getLocationRunnableFactory().taskSize() + ")"); FinalTech.getLocationRunnableFactory().waitAllTask(); } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); - } finally { + } + /*finally { BlockStorage.saveChunks(); try { for (World world : Bukkit.getWorlds()) { @@ -335,11 +343,13 @@ public void onDisable() { e.printStackTrace(); } } + */ try { FinalTech.getEntityRunnableFactory().waitAllTask(); } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); - } finally { + } + /*finally { BlockStorage.saveChunks(); try { for (World world : Bukkit.getWorlds()) { @@ -353,6 +363,7 @@ public void onDisable() { e.printStackTrace(); } } + */ } @Override diff --git a/src/main/java/io/taraxacum/finaltech/core/enchantment/NullEnchantment.java b/src/main/java/io/taraxacum/finaltech/core/enchantment/NullEnchantment.java index d4926b85..f2317273 100644 --- a/src/main/java/io/taraxacum/finaltech/core/enchantment/NullEnchantment.java +++ b/src/main/java/io/taraxacum/finaltech/core/enchantment/NullEnchantment.java @@ -16,10 +16,11 @@ * @since 1.0 */ public class NullEnchantment extends Enchantment { - public static final Enchantment ENCHANTMENT = new NullEnchantment(new NamespacedKey(JavaPlugin.getPlugin(FinalTech.class), "FINALTECH_NULL_ENCHANTMENT")); + public static final NamespacedKey KEY = new NamespacedKey(JavaPlugin.getPlugin(FinalTech.class), "FINALTECH_NULL_ENCHANTMENT"); + public static final Enchantment ENCHANTMENT = new NullEnchantment(KEY); private NullEnchantment(NamespacedKey key) { - super(key); + super(); } @Nonnull @@ -68,4 +69,14 @@ public static void addAndHidden(@Nonnull ItemStack item) { item.addUnsafeEnchantment(ENCHANTMENT, 0); ItemStackUtil.addItemFlag(item, ItemFlag.HIDE_ENCHANTS); } + + @Override + public NamespacedKey getKey() { + return KEY; + } + + @Override + public String getTranslationKey() { + return ""; + } } diff --git a/src/main/java/io/taraxacum/finaltech/core/helper/MachineMaxStack.java b/src/main/java/io/taraxacum/finaltech/core/helper/MachineMaxStack.java index f79fdce7..d1dbe71b 100644 --- a/src/main/java/io/taraxacum/finaltech/core/helper/MachineMaxStack.java +++ b/src/main/java/io/taraxacum/finaltech/core/helper/MachineMaxStack.java @@ -7,12 +7,14 @@ import io.taraxacum.libs.slimefun.dto.BlockStorageLoreHelper; import io.taraxacum.finaltech.core.item.machine.AbstractMachine; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.LinkedHashMap; @@ -69,7 +71,8 @@ public String previousOrDefaultValue(@Nullable String value) { public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { if (slimefunItem instanceof AbstractMachine) { return (player, i, itemStack, clickAction) -> { - int quantity = Integer.parseInt(BlockStorage.getLocationInfo(location, MachineMaxStack.KEY)); + SlimefunBlockData blockData = StorageCacheUtils.getBlock(location); + int quantity = Integer.parseInt(blockData.getData(MachineMaxStack.KEY)); if (clickAction.isShiftClicked()) { quantity = 0; } else { @@ -80,7 +83,7 @@ public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonn } } MachineMaxStack.HELPER.setIcon(inventory.getItem(slot), String.valueOf(quantity)); - BlockStorage.addBlockInfo(location, MachineMaxStack.KEY, String.valueOf(quantity)); + blockData.setData(MachineMaxStack.KEY, String.valueOf(quantity)); return false; }; } else { diff --git a/src/main/java/io/taraxacum/finaltech/core/helper/MachineRecipeLock.java b/src/main/java/io/taraxacum/finaltech/core/helper/MachineRecipeLock.java index ba446bb9..905ab76c 100644 --- a/src/main/java/io/taraxacum/finaltech/core/helper/MachineRecipeLock.java +++ b/src/main/java/io/taraxacum/finaltech/core/helper/MachineRecipeLock.java @@ -10,12 +10,13 @@ import io.taraxacum.libs.slimefun.dto.MachineRecipeFactory; import io.taraxacum.libs.plugin.util.ItemStackUtil; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.ArrayList; @@ -62,7 +63,7 @@ public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonn HELPER.checkOrSetBlockStorage(location); String value = clickAction.isRightClicked() ? VALUE_LOCK_OFF : VALUE_UNLOCK; HELPER.setIcon(inventory.getItem(slot), value); - BlockStorage.addBlockInfo(location, KEY, value); + StorageCacheUtils.setData(location, KEY, value); return false; }; } diff --git a/src/main/java/io/taraxacum/finaltech/core/helper/PositionInfo.java b/src/main/java/io/taraxacum/finaltech/core/helper/PositionInfo.java index 2f70b7db..af06cc8f 100644 --- a/src/main/java/io/taraxacum/finaltech/core/helper/PositionInfo.java +++ b/src/main/java/io/taraxacum/finaltech/core/helper/PositionInfo.java @@ -10,13 +10,14 @@ import io.taraxacum.libs.slimefun.dto.BlockStorageLoreHelper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; @@ -128,7 +129,7 @@ public static abstract class BlockStorageLoreMaterialHelper extends BlockStorage @Nonnull @Override public String getOrDefaultValue(@Nonnull Location location) { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getValueKey()); if ("".equals(value)) { @@ -171,7 +172,7 @@ public boolean setIcon(@Nonnull ItemStack iconItem, @Nullable String value, @Non @Override public boolean checkAndUpdateIcon(@Nonnull Inventory inventory, @Nonnull Location location, int slot) { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); if (valueMap == null) { valueMap = ""; } @@ -183,7 +184,7 @@ public boolean checkAndUpdateIcon(@Nonnull Inventory inventory, @Nonnull Locatio if (!BlockStorageLoreMaterialHelper.this.validValue(value)) { value = BlockStorageLoreMaterialHelper.this.defaultValue(); keyValueStringHelper.putEntry(BlockStorageLoreMaterialHelper.this.getValueKey(), value); - BlockStorage.addBlockInfo(location, KEY, keyValueStringHelper.toString()); + StorageCacheUtils.setData(location, KEY, keyValueStringHelper.toString()); } ItemStack item = inventory.getItem(slot); item.setAmount(keyValueStringHelper.getKeyIndex(this.getValueKey()) > 0 ? keyValueStringHelper.getKeyIndex(this.getValueKey()) + 1 : 1); @@ -195,7 +196,7 @@ public boolean checkAndUpdateIcon(@Nonnull Inventory inventory, @Nonnull Locatio @Override public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getValueKey()); if ("".equals(value)) { @@ -218,7 +219,7 @@ public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonn @Override public ChestMenu.MenuClickHandler getUpdateHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getValueKey()); if ("".equals(value)) { @@ -239,7 +240,7 @@ public ChestMenu.MenuClickHandler getUpdateHandler(@Nonnull Inventory inventory, @Override public ChestMenu.MenuClickHandler getNextHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getValueKey()); if ("".equals(value)) { @@ -258,7 +259,7 @@ public ChestMenu.MenuClickHandler getNextHandler(@Nonnull Inventory inventory, @ @Override public ChestMenu.MenuClickHandler getPreviousHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getValueKey()); if ("".equals(value)) { diff --git a/src/main/java/io/taraxacum/finaltech/core/helper/SlotSearchLine.java b/src/main/java/io/taraxacum/finaltech/core/helper/SlotSearchLine.java index e40cd70c..e50e45d3 100644 --- a/src/main/java/io/taraxacum/finaltech/core/helper/SlotSearchLine.java +++ b/src/main/java/io/taraxacum/finaltech/core/helper/SlotSearchLine.java @@ -8,12 +8,13 @@ import io.taraxacum.libs.slimefun.dto.BlockStorageLoreHelper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; @@ -94,7 +95,7 @@ public static abstract class BlockStorageLoreMaterialHelper extends BlockStorage @Nonnull @Override public String getOrDefaultValue(@Nonnull Location location) { - String valueMap = BlockStorage.getLocationInfo(location, KEY); + String valueMap = StorageCacheUtils.getData(location, KEY); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getKey()); if (!BlockStorageLoreMaterialHelper.this.validValue(value)) { @@ -131,7 +132,7 @@ public boolean setIcon(@Nonnull ItemStack iconItem, @Nullable String value, @Non @Override public boolean checkAndUpdateIcon(@Nonnull Inventory inventory, @Nonnull Location location, int slot) { - String valueMap = BlockStorage.getLocationInfo(location, this.getKey()); + String valueMap = StorageCacheUtils.getData(location, this.getKey()); if (valueMap == null) { valueMap = ""; } @@ -140,7 +141,7 @@ public boolean checkAndUpdateIcon(@Nonnull Inventory inventory, @Nonnull Locatio if (!BlockStorageLoreMaterialHelper.this.validValue(value)) { value = BlockStorageLoreMaterialHelper.this.defaultValue(); keyValueStringHelper.putEntry(BlockStorageLoreMaterialHelper.this.getKey(), value); - BlockStorage.addBlockInfo(location, KEY, keyValueStringHelper.toString()); + StorageCacheUtils.setData(location, KEY, keyValueStringHelper.toString()); } ItemStack item = inventory.getItem(slot); BlockStorageLoreMaterialHelper.this.setIcon(item, value); @@ -151,7 +152,7 @@ public boolean checkAndUpdateIcon(@Nonnull Inventory inventory, @Nonnull Locatio @Override public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, KEY); + String valueMap = StorageCacheUtils.getData(location, KEY); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getKey()); if (!action.isRightClicked()) { @@ -170,7 +171,7 @@ public ChestMenu.MenuClickHandler getHandler(@Nonnull Inventory inventory, @Nonn @Override public ChestMenu.MenuClickHandler getUpdateHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, KEY); + String valueMap = StorageCacheUtils.getData(location, KEY); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getKey()); if (!BlockStorageLoreMaterialHelper.this.validValue(value)) { @@ -187,7 +188,7 @@ public ChestMenu.MenuClickHandler getUpdateHandler(@Nonnull Inventory inventory, @Override public ChestMenu.MenuClickHandler getNextHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, KEY); + String valueMap = StorageCacheUtils.getData(location, KEY); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getKey()); value = BlockStorageLoreMaterialHelper.this.clickNextValue(value, action); @@ -202,7 +203,7 @@ public ChestMenu.MenuClickHandler getNextHandler(@Nonnull Inventory inventory, @ @Override public ChestMenu.MenuClickHandler getPreviousHandler(@Nonnull Inventory inventory, @Nonnull Location location, @Nonnull SlimefunItem slimefunItem, int slot) { return (p, slot1, item, action) -> { - String valueMap = BlockStorage.getLocationInfo(location, KEY); + String valueMap = StorageCacheUtils.getData(location, KEY); KeyValueStringHelper keyValueStringHelper = MAP_EXAMPLE.parseString(valueMap); String value = keyValueStringHelper.getValue(BlockStorageLoreMaterialHelper.this.getKey()); value = BlockStorageLoreMaterialHelper.this.clickPreviousValue(value, action); diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLineTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLineTransfer.java index b378eeca..2341919a 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLineTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLineTransfer.java @@ -20,7 +20,6 @@ import io.taraxacum.libs.plugin.dto.ServerRunnableLockFactory; import io.taraxacum.libs.plugin.util.ParticleUtil; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Location; import org.bukkit.Particle; @@ -33,6 +32,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; @@ -58,7 +59,7 @@ public void onPlayerPlace(@Nonnull BlockPlaceEvent blockPlaceEvent) { Location location = block.getLocation(); IgnorePermission.HELPER.checkOrSetBlockStorage(location); - BlockStorage.addBlockInfo(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); + StorageCacheUtils.setData(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); BlockSearchMode.LINE_HELPER.checkOrSetBlockStorage(location); BlockSearchOrder.HELPER.checkOrSetBlockStorage(location); @@ -94,7 +95,7 @@ protected AbstractMachineMenu setMachineMenu() { @Override protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonnull Config config) { - BlockMenu blockMenu = BlockStorage.getInventory(block); + BlockMenu blockMenu = StorageCacheUtils.getMenu(block.getLocation()); Location location = block.getLocation(); JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); boolean primaryThread = javaPlugin.getServer().isPrimaryThread(); @@ -183,12 +184,12 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N continue; } - if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(outputBlock)) { + if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = null; } else { outputMap = CargoUtil.getInvWithSlots(outputBlock, outputSize, outputOrder); } - if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(inputBlock)) { + if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = null; } else { inputMap = CargoUtil.getInvWithSlots(inputBlock, inputSize, inputOrder); @@ -231,7 +232,7 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N } ServerRunnableLockFactory.getInstance(javaPlugin, Location.class).waitThenRun(() -> { - if (!BlockStorage.hasBlockInfo(location)) { + if (!StorageCacheUtils.hasBlock(location)) { return; } @@ -334,18 +335,18 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N continue; } - if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(inputBlock)) { + if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = null; - } else if (BlockStorage.hasInventory(inputBlock)) { + } else if (StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = CargoUtil.getInvWithSlots(inputBlock, inputSize, inputOrder); } else if (finalVanillaInventories.get(input) != null) { inputMap = CargoUtil.calInvWithSlots(finalVanillaInventories.get(input), inputOrder); } else { continue; } - if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(outputBlock)) { + if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = null; - } else if (BlockStorage.hasInventory(outputBlock)) { + } else if (StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = CargoUtil.getInvWithSlots(outputBlock, outputSize, outputOrder); } else if (finalVanillaInventories.get(output) != null) { outputMap = CargoUtil.calInvWithSlots(finalVanillaInventories.get(output), outputOrder); @@ -392,7 +393,7 @@ public List searchBlock(@Nonnull Block begin, @Nonnull BlockFace blockFac return list; } while (CargoUtil.hasInventory(block)) { - if (BlockStorage.hasInventory(block) && BlockStorage.getInventory(block).getPreset().getID().equals(FinalTechItemStacks.LINE_TRANSFER.getItemId())) { + if (StorageCacheUtils.getMenu(block.getLocation()) != null && StorageCacheUtils.getMenu(block.getLocation()).getPreset().getID().equals(FinalTechItemStacks.LINE_TRANSFER.getItemId())) { if (BlockSearchMode.VALUE_PENETRATE.equals(blockSearchMode)) { block = block.getRelative(blockFace); continue; diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLocationTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLocationTransfer.java index 2d0adba3..a6aa5087 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLocationTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedLocationTransfer.java @@ -18,8 +18,8 @@ import io.taraxacum.libs.plugin.util.ItemStackUtil; import io.taraxacum.libs.plugin.util.ParticleUtil; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; + import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.block.Block; @@ -27,6 +27,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; @@ -77,7 +79,7 @@ protected AbstractMachineMenu setMachineMenu() { @Override protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonnull Config config) { - BlockMenu blockMenu = BlockStorage.getInventory(block); + BlockMenu blockMenu = StorageCacheUtils.getMenu(block.getLocation()); Location location = block.getLocation(); JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); boolean drawParticle = blockMenu.hasViewer() || RouteShow.VALUE_TRUE.equals(RouteShow.HELPER.getOrDefaultValue(config)); @@ -130,7 +132,7 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N locationList.add(LocationUtil.getCenterLocation(block)); locationList.add(LocationUtil.getCenterLocation(targetBlock)); final List finalLocationList = positive ? locationList : JavaUtil.reserve(locationList); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L, this.particleDistance, finalLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L, this.particleDistance, finalLocationList)); } } diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedMeshTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedMeshTransfer.java index cfa99e2b..5cded96b 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedMeshTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedMeshTransfer.java @@ -19,7 +19,6 @@ import io.taraxacum.libs.plugin.dto.ServerRunnableLockFactory; import io.taraxacum.libs.plugin.util.ParticleUtil; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Location; import org.bukkit.Material; @@ -31,6 +30,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.List; import java.util.ArrayList; @@ -57,7 +58,7 @@ public void onPlayerPlace(@Nonnull BlockPlaceEvent blockPlaceEvent) { Location location = block.getLocation(); IgnorePermission.HELPER.checkOrSetBlockStorage(location); - BlockStorage.addBlockInfo(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); + StorageCacheUtils.setData(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); CargoFilter.HELPER.checkOrSetBlockStorage(location); BlockSearchMode.MESH_INPUT_HELPER.checkOrSetBlockStorage(location); @@ -75,7 +76,7 @@ public void onPlayerPlace(@Nonnull BlockPlaceEvent blockPlaceEvent) { SlotSearchOrder.OUTPUT_HELPER.checkOrSetBlockStorage(location); CargoLimit.OUTPUT_HELPER.checkOrSetBlockStorage(location); - BlockStorage.addBlockInfo(block, PositionInfo.KEY, ""); + StorageCacheUtils.setData(block.getLocation(), PositionInfo.KEY, ""); } }; } @@ -94,7 +95,7 @@ protected AbstractMachineMenu setMachineMenu() { @Override public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonnull Config config) { - BlockMenu blockMenu = BlockStorage.getInventory(block); + BlockMenu blockMenu = StorageCacheUtils.getMenu(block.getLocation()); Location location = block.getLocation(); JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); boolean primaryThread = javaPlugin.getServer().isPrimaryThread(); @@ -163,7 +164,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn for (Block outputBlock : outputBlocks) { InvWithSlots outputMap; - if (BlockStorage.hasInventory(outputBlock)) { + if (StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = null; } else { outputMap = CargoUtil.getInvWithSlots(outputBlock, outputSize, outputOrder); @@ -215,7 +216,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn for (Block inputBlock : inputBlocks) { InvWithSlots inputMap; - if (BlockStorage.hasInventory(inputBlock)) { + if (StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = null; } else { inputMap = CargoUtil.getInvWithSlots(inputBlock, inputSize, inputOrder); @@ -262,7 +263,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn } locations[locations.length - 1] = block.getLocation(); ServerRunnableLockFactory.getInstance(javaPlugin, Location.class).waitThenRun(() -> { - if (!BlockStorage.hasBlockInfo(location)) { + if (!StorageCacheUtils.hasBlock(location)) { return; } @@ -311,7 +312,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn for (int i = 0; i < outputBlocks.length; i++) { Block outputBlock = outputBlocks[i]; InvWithSlots outputMap; - if (BlockStorage.hasInventory(outputBlock)) { + if (StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = null; } else if (outputVanillaInventories[i] != null) { outputMap = CargoUtil.calInvWithSlots(outputVanillaInventories[i], outputOrder); @@ -361,7 +362,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn for (int i = 0; i < inputBlocks.length; i++) { Block inputBlock = inputBlocks[i]; InvWithSlots inputMap; - if (BlockStorage.hasInventory(inputBlock)) { + if (StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = null; } else if (inputVanillaInventories[i] != null) { inputMap = CargoUtil.calInvWithSlots(inputVanillaInventories[i], inputOrder); @@ -393,7 +394,7 @@ public Block searchBlock(@Nonnull Block sourceBlock, @Nonnull BlockFace blockFac particleLocationList.add(LocationUtil.getCenterLocation(result)); if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); } return result; } @@ -403,7 +404,7 @@ public Block searchBlock(@Nonnull Block sourceBlock, @Nonnull BlockFace blockFac result = result.getRelative(blockFace); continue; } - if (BlockSearchMode.VALUE_PENETRATE.equals(searchMode) && BlockStorage.hasInventory(result) && BlockStorage.getInventory(result).getPreset().getID().equals(FinalTechItemStacks.MESH_TRANSFER.getItemId())) { + if (BlockSearchMode.VALUE_PENETRATE.equals(searchMode) && StorageCacheUtils.getMenu(result.getLocation()) != null && StorageCacheUtils.getMenu(result.getLocation()).getPreset().getID().equals(FinalTechItemStacks.MESH_TRANSFER.getItemId())) { result = result.getRelative(blockFace); continue; } @@ -411,7 +412,7 @@ public Block searchBlock(@Nonnull Block sourceBlock, @Nonnull BlockFace blockFac } if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); } return result; } diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedPointTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedPointTransfer.java index 033e0f7e..f1296780 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedPointTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/AdvancedPointTransfer.java @@ -22,7 +22,6 @@ import io.taraxacum.libs.plugin.dto.ServerRunnableLockFactory; import io.taraxacum.libs.plugin.util.ParticleUtil; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Location; import org.bukkit.Particle; @@ -36,6 +35,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.HashSet; @@ -65,7 +66,7 @@ public void onPlayerPlace(@Nonnull BlockPlaceEvent blockPlaceEvent) { Location location = block.getLocation(); IgnorePermission.HELPER.checkOrSetBlockStorage(location); - BlockStorage.addBlockInfo(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); + StorageCacheUtils.setData(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); CargoNumber.HELPER.checkOrSetBlockStorage(location); CargoFilter.HELPER.checkOrSetBlockStorage(location); @@ -97,7 +98,7 @@ protected AbstractMachineMenu setMachineMenu() { @Override public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonnull Config config) { - BlockMenu blockMenu = BlockStorage.getInventory(block); + BlockMenu blockMenu = StorageCacheUtils.getMenu(block.getLocation()); Location location = block.getLocation(); JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); boolean primaryThread = javaPlugin.getServer().isPrimaryThread(); @@ -154,7 +155,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn Inventory outputInventory = CargoUtil.getVanillaInventory(outputBlock); ServerRunnableLockFactory.getInstance(javaPlugin, Location.class).waitThenRun(() -> { - if (!BlockStorage.hasBlockInfo(location)) { + if (!StorageCacheUtils.hasBlock(location)) { return; } @@ -171,7 +172,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn String cargoMode = CargoMode.HELPER.getOrDefaultValue(config); InvWithSlots inputMap; - if (BlockStorage.hasInventory(inputBlock)) { + if (StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode)) { inputMap = null; } else { @@ -184,7 +185,7 @@ public void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonn } InvWithSlots outputMap; - if (BlockStorage.hasInventory(outputBlock)) { + if (StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode)) { outputMap = null; } else { @@ -220,14 +221,14 @@ private Block searchBlock(@Nonnull Block begin, @Nonnull String searchMode, @Non particleLocationList.add(LocationUtil.getCenterLocation(result)); if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); } return result; } Set locationSet = new HashSet<>(); locationSet.add(begin.getLocation()); while(true) { - if (BlockStorage.hasInventory(result) && !result.getType().equals(FinalTechItemStacks.POINT_TRANSFER.getType())) { + if (StorageCacheUtils.getMenu(result.getLocation()) != null && !result.getType().equals(FinalTechItemStacks.POINT_TRANSFER.getType())) { particleLocationList.add(LocationUtil.getCenterLocation(result)); break; } @@ -260,7 +261,7 @@ private Block searchBlock(@Nonnull Block begin, @Nonnull String searchMode, @Non } if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); } return result; } diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LineTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LineTransfer.java index 70fe433e..54bdf524 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LineTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LineTransfer.java @@ -25,7 +25,6 @@ import io.taraxacum.finaltech.util.LocationUtil; import io.taraxacum.finaltech.util.MachineUtil; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Location; import org.bukkit.Particle; @@ -38,6 +37,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; @@ -63,7 +64,7 @@ public void onPlayerPlace(@Nonnull BlockPlaceEvent blockPlaceEvent) { Location location = block.getLocation(); IgnorePermission.HELPER.checkOrSetBlockStorage(location); - BlockStorage.addBlockInfo(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); + StorageCacheUtils.setData(location, ConstantTableUtil.CONFIG_UUID, blockPlaceEvent.getPlayer().getUniqueId().toString()); BlockSearchMode.LINE_HELPER.checkOrSetBlockStorage(location); BlockSearchOrder.HELPER.checkOrSetBlockStorage(location); @@ -91,7 +92,7 @@ protected AbstractMachineMenu setMachineMenu() { @Override protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @Nonnull Config config) { - BlockMenu blockMenu = BlockStorage.getInventory(block); + BlockMenu blockMenu = StorageCacheUtils.getMenu(block.getLocation()); Location location = block.getLocation(); JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); boolean primaryThread = javaPlugin.getServer().isPrimaryThread(); @@ -180,12 +181,12 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N continue; } - if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(outputBlock)) { + if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = null; } else { outputMap = CargoUtil.getInvWithSlots(outputBlock, outputSize, outputOrder); } - if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(inputBlock)) { + if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = null; } else { inputMap = CargoUtil.getInvWithSlots(inputBlock, inputSize, inputOrder); @@ -228,7 +229,7 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N } ServerRunnableLockFactory.getInstance(javaPlugin, Location.class).waitThenRun(() -> { - if (!BlockStorage.hasBlockInfo(location)) { + if (!StorageCacheUtils.hasBlock(location)) { return; } @@ -331,18 +332,18 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N continue; } - if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(inputBlock)) { + if (CargoMode.VALUE_OUTPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = null; - } else if (BlockStorage.hasInventory(inputBlock)) { + } else if (StorageCacheUtils.getMenu(inputBlock.getLocation()) != null) { inputMap = CargoUtil.getInvWithSlots(inputBlock, inputSize, inputOrder); } else if (finalVanillaInventories.get(input) != null) { inputMap = CargoUtil.calInvWithSlots(finalVanillaInventories.get(input), inputOrder); } else { continue; } - if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && BlockStorage.hasInventory(outputBlock)) { + if (CargoMode.VALUE_INPUT_MAIN.equals(cargoMode) && StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = null; - } else if (BlockStorage.hasInventory(outputBlock)) { + } else if (StorageCacheUtils.getMenu(outputBlock.getLocation()) != null) { outputMap = CargoUtil.getInvWithSlots(outputBlock, outputSize, outputOrder); } else if (finalVanillaInventories.get(output) != null) { outputMap = CargoUtil.calInvWithSlots(finalVanillaInventories.get(output), outputOrder); @@ -389,7 +390,7 @@ public List searchBlock(@Nonnull Block begin, @Nonnull BlockFace blockFac return list; } while (CargoUtil.hasInventory(block)) { - if (BlockStorage.hasInventory(block) && BlockStorage.getInventory(block).getPreset().getID().equals(FinalTechItemStacks.LINE_TRANSFER.getItemId())) { + if (StorageCacheUtils.getMenu(block.getLocation()) != null && StorageCacheUtils.getMenu(block.getLocation()).getPreset().getID().equals(FinalTechItemStacks.LINE_TRANSFER.getItemId())) { if (BlockSearchMode.VALUE_PENETRATE.equals(blockSearchMode)) { block = block.getRelative(blockFace); continue; diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LocationTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LocationTransfer.java index 1536fc66..930964c7 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LocationTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/LocationTransfer.java @@ -129,7 +129,7 @@ protected void tick(@Nonnull Block block, @Nonnull SlimefunItem slimefunItem, @N locationList.add(LocationUtil.getCenterLocation(block)); locationList.add(LocationUtil.getCenterLocation(targetBlock)); final List finalLocationList = positive ? locationList : JavaUtil.reserve(locationList); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L, this.particleDistance, finalLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L, this.particleDistance, finalLocationList)); } } diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/MeshTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/MeshTransfer.java index d3601828..c1fdcd18 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/MeshTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/MeshTransfer.java @@ -386,7 +386,7 @@ public Block searchBlock(@Nonnull Block sourceBlock, @Nonnull BlockFace blockFac particleLocationList.add(LocationUtil.getCenterLocation(result)); if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); } return result; } @@ -404,7 +404,7 @@ public Block searchBlock(@Nonnull Block sourceBlock, @Nonnull BlockFace blockFac } if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, particleLocationList)); } return result; } diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/PointTransfer.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/PointTransfer.java index eef355b6..303b1101 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/PointTransfer.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/PointTransfer.java @@ -217,7 +217,7 @@ private Block searchBlock(@Nonnull Block begin, @Nonnull String searchMode, @Non particleLocationList.add(LocationUtil.getCenterLocation(result)); if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); } return result; } @@ -257,7 +257,7 @@ private Block searchBlock(@Nonnull Block begin, @Nonnull String searchMode, @Non } if (drawParticle && FinalTech.getSlimefunTickCount() % this.particleInterval == 0) { JavaPlugin javaPlugin = this.getAddon().getJavaPlugin(); - javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT_MAGIC, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); + javaPlugin.getServer().getScheduler().runTaskAsynchronously(javaPlugin, () -> ParticleUtil.drawLineByDistance(javaPlugin, Particle.CRIT, this.particleInterval * Slimefun.getTickerTask().getTickRate() * 50L / particleLocationList.size(), this.particleDistance, input ? JavaUtil.reserve(particleLocationList) : particleLocationList)); } return result; } diff --git a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/storage/StorageInteractPort.java b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/storage/StorageInteractPort.java index e041f067..7866af48 100644 --- a/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/storage/StorageInteractPort.java +++ b/src/main/java/io/taraxacum/finaltech/core/item/machine/cargo/storage/StorageInteractPort.java @@ -19,7 +19,6 @@ import io.taraxacum.finaltech.util.RecipeUtil; import io.taraxacum.finaltech.util.MachineUtil; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -32,6 +31,8 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.*; @@ -55,8 +56,8 @@ protected AbstractMachineMenu setMachineMenu() { @Override protected void tick(Block block, @Nonnull SlimefunItem slimefunItem, @Nonnull Config config) { Block targetBlock = block.getRelative(BlockFace.UP); - BlockMenu blockMenu = BlockStorage.getInventory(block); - if (!BlockStorage.hasInventory(targetBlock)) { + BlockMenu blockMenu = StorageCacheUtils.getMenu(block.getLocation()); + if (StorageCacheUtils.getMenu(targetBlock.getLocation()) != null) { if (Bukkit.isPrimaryThread()) { BlockState blockState = targetBlock.getState(); if (blockState instanceof InventoryHolder) { diff --git a/src/main/java/io/taraxacum/finaltech/core/menu/clicker/AreaAccessorMenu.java b/src/main/java/io/taraxacum/finaltech/core/menu/clicker/AreaAccessorMenu.java index 31f3eda2..af73d4bd 100644 --- a/src/main/java/io/taraxacum/finaltech/core/menu/clicker/AreaAccessorMenu.java +++ b/src/main/java/io/taraxacum/finaltech/core/menu/clicker/AreaAccessorMenu.java @@ -22,6 +22,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.HashMap; @@ -101,8 +103,8 @@ public void generateMenu(@Nonnull Player player, @Nonnull Location location, int if (world == null) { return; } - BlockStorage storage = BlockStorage.getStorage(world); - if (storage == null) { + var blockData = StorageCacheUtils.getBlock(location); + if (blockData == null) { return; } @@ -121,7 +123,8 @@ public void generateMenu(@Nonnull Player player, @Nonnull Location location, int tempLocation.setY(y); for (int z = minZ; z <= maxZ; z++) { tempLocation.setZ(z); - if (BlockStorage.hasBlockInfo(tempLocation) && storage.hasInventory(tempLocation)) { + + if (StorageCacheUtils.hasBlock(tempLocation) && StorageCacheUtils.getMenu(tempLocation) != null) { int distance = Math.abs(tempLocation.getBlockX() - location.getBlockX()) + Math.abs(tempLocation.getBlockY() - location.getBlockY()) + Math.abs(tempLocation.getBlockZ() - location.getBlockZ()); List locationList = distanceLocationMap.computeIfAbsent(distance, d -> new ArrayList<>(d * d * 4 + 2)); locationList.add(tempLocation.clone()); diff --git a/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorBlockTicker.java b/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorBlockTicker.java index f4184edd..77119dc8 100644 --- a/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorBlockTicker.java +++ b/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorBlockTicker.java @@ -96,7 +96,7 @@ public void tick(Block block, SlimefunItem slimefunItem, Config config) { } } else { energyNetwork.markDirty(location); - energyNetwork.tick(block); + energyNetwork.tick(); } } } diff --git a/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorDetailMenu.java b/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorDetailMenu.java index 534eac97..cae7a2a8 100644 --- a/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorDetailMenu.java +++ b/src/main/java/io/taraxacum/finaltech/core/patch/EnergyRegulatorDetailMenu.java @@ -17,7 +17,7 @@ import io.taraxacum.libs.plugin.util.ParticleUtil; import io.taraxacum.libs.slimefun.util.SfItemUtil; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.api.BlockStorage; + import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -25,6 +25,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitTask; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; + import javax.annotation.Nonnull; import java.util.*; import java.util.stream.Collectors; @@ -237,7 +239,7 @@ public void updateMenu() { this.replaceExistingItem(CONTENT[i], itemStack); this.addMenuClickHandler(CONTENT[i], (p, slot, item, action) -> { - BlockMenu blockMenu = BlockStorage.getInventory(componentLocation); + BlockMenu blockMenu = StorageCacheUtils.getMenu(componentLocation); if(blockMenu != null && blockMenu.canOpen(this.location.getBlock(), p)) { blockMenu.open(p); } diff --git a/src/main/java/io/taraxacum/finaltech/setup/SetupUtil.java b/src/main/java/io/taraxacum/finaltech/setup/SetupUtil.java index d3d4cbea..8087ffba 100644 --- a/src/main/java/io/taraxacum/finaltech/setup/SetupUtil.java +++ b/src/main/java/io/taraxacum/finaltech/setup/SetupUtil.java @@ -116,7 +116,6 @@ public String apply(String s) { private static void setupEnchantment() { try { ReflectionUtil.setStaticValue(Enchantment.class, "acceptingNew", true); - Enchantment.registerEnchantment(NullEnchantment.ENCHANTMENT); // material @@ -180,9 +179,9 @@ private static void setupEnchantment() { public static void setupItem() { ItemStackUtil.setLore(FinalTechItemStacks.TROPHY_MEAWERFUL, - "§fThanks for some good idea"); + "§f欢迎提供好的想法"); ItemStackUtil.setLore(FinalTechItemStacks.TROPHY_SHIXINZIA, - "§fThanks for some test work"); + "§f感谢您的测试工作"); ItemStackUtil.addItemFlag(FinalTechItemStacks.STORAGE_CARD, ItemFlag.HIDE_ATTRIBUTES);