diff --git a/pom.xml b/pom.xml index 083ffbf..b541c48 100644 --- a/pom.xml +++ b/pom.xml @@ -108,9 +108,9 @@ provided - com.github.Slimefun + com.github.StarWishsama Slimefun4 - b1aae439f3 + 2023.06 provided @@ -141,7 +141,7 @@ net.guizhanss GuizhanLibPlugin - 1.1.0 + 1.2.1 provided diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/NetherPlant.java b/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/NetherPlant.java index 863e34a..f2ba60e 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/NetherPlant.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/NetherPlant.java @@ -1,12 +1,12 @@ package dev.sefiraat.netheopoiesis.api.interfaces; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import dev.sefiraat.netheopoiesis.api.items.NetherCrux; import dev.sefiraat.netheopoiesis.api.items.NetherSeed; import dev.sefiraat.netheopoiesis.api.plant.GrowthStages; import dev.sefiraat.netheopoiesis.utils.Skulls; import dev.sefiraat.netheopoiesis.utils.Theme; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import org.bukkit.Location; import org.bukkit.inventory.ItemStack; @@ -26,10 +26,10 @@ public interface NetherPlant extends PurifyingObject { * * @param location The location of the plant being ticked * @param seed The {@link SlimefunItem} being ticked - * @param data The {@link Config} from BlockStorage for the location + * @param data The {@link SlimefunBlockData} from BlockStorage for the location */ @ParametersAreNonnullByDefault - default void onTickAlways(Location location, NetherSeed seed, Config data) { + default void onTickAlways(Location location, NetherSeed seed, SlimefunBlockData data) { } @@ -38,10 +38,10 @@ default void onTickAlways(Location location, NetherSeed seed, Config data) { * * @param location The location of the plant being ticked * @param seed The {@link SlimefunItem} being ticked - * @param data The {@link Config} from BlockStorage for the location + * @param data The {@link SlimefunBlockData} from BlockStorage for the location */ @ParametersAreNonnullByDefault - default void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + default void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { } @@ -50,10 +50,10 @@ default void onTickFullyGrown(Location location, NetherSeed seed, Config data) { * * @param location The location of the plant being ticked * @param seed The {@link SlimefunItem} being ticked - * @param data The {@link Config} from BlockStorage for the location + * @param data The {@link SlimefunBlockData} from BlockStorage for the location */ @ParametersAreNonnullByDefault - default void onGrowthStep(Location location, NetherSeed seed, Config data) { + default void onGrowthStep(Location location, NetherSeed seed, SlimefunBlockData data) { } @@ -62,10 +62,10 @@ default void onGrowthStep(Location location, NetherSeed seed, Config data) { * * @param location The location of the plant being ticked * @param seed The {@link SlimefunItem} being ticked - * @param data The {@link Config} from BlockStorage for the location + * @param data The {@link SlimefunBlockData} from BlockStorage for the location */ @ParametersAreNonnullByDefault - default void onFullyMatures(Location location, NetherSeed seed, Config data) { + default void onFullyMatures(Location location, NetherSeed seed, SlimefunBlockData data) { } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/SpreadingPlant.java b/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/SpreadingPlant.java index 12abe4b..05a3df2 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/SpreadingPlant.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/interfaces/SpreadingPlant.java @@ -1,8 +1,8 @@ package dev.sefiraat.netheopoiesis.api.interfaces; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import dev.sefiraat.netheopoiesis.api.items.CruxSpreadingSeed; import dev.sefiraat.netheopoiesis.api.items.NetherSeed; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import org.bukkit.Location; import org.bukkit.block.Block; @@ -16,10 +16,10 @@ public interface SpreadingPlant { @ParametersAreNonnullByDefault - void spread(Location sourceLocation, NetherSeed seed, Config data); + void spread(Location sourceLocation, NetherSeed seed, SlimefunBlockData data); @ParametersAreNonnullByDefault - default void afterSpread(Location sourceLocation, NetherSeed seed, Config data, Block spreadTo) { + default void afterSpread(Location sourceLocation, NetherSeed seed, SlimefunBlockData data, Block spreadTo) { } } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java index 43f9ae5..9a186a7 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java @@ -1,8 +1,9 @@ package dev.sefiraat.netheopoiesis.api.items; import com.google.common.base.Preconditions; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Purification; -import dev.sefiraat.netheopoiesis.api.interfaces.CustomPlacementBlock; import dev.sefiraat.netheopoiesis.api.interfaces.PurificationDrain; import dev.sefiraat.netheopoiesis.listeners.CustomPlacementListener; import dev.sefiraat.netheopoiesis.utils.Keys; @@ -13,9 +14,9 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -40,7 +41,7 @@ * It will also post its location to the Registry and draw additional power from other SiphoningBlocks * below it so long as it's a tier higher. */ -public class BeaconSiphoningBlock extends SlimefunItem implements PurificationDrain, CustomPlacementBlock { +public class BeaconSiphoningBlock extends SlimefunItem implements PurificationDrain { @Nonnull private static final Map POWER_MAP = new HashMap<>(); @@ -79,7 +80,7 @@ public boolean isSynchronized() { } @Override - public void tick(Block block, SlimefunItem item, Config data) { + public void tick(Block block, SlimefunItem item, SlimefunBlockData data) { onTick(block, item, data); } @@ -88,6 +89,13 @@ public void uniqueTick() { onUniqueTick(); } }, + new BlockPlaceHandler(false) { + @Override + @ParametersAreNonnullByDefault + public void onPlayerPlace(BlockPlaceEvent e) { + whenPlaced(e); + } + }, new BlockBreakHandler(false, false) { @Override public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) { @@ -99,7 +107,7 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro @ParametersAreNonnullByDefault @OverridingMethodsMustInvokeSuper - protected boolean onTick(Block block, SlimefunItem item, Config data) { + protected boolean onTick(Block block, SlimefunItem item, SlimefunBlockData data) { // We do not want to operate every single tick if (currentTick != TICKS_PER_OPERATION) { @@ -122,7 +130,7 @@ protected boolean onTick(Block block, SlimefunItem item, Config data) { for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { final Block blockBelow = block.getRelative(x, -1, z); - final SlimefunItem slimefunItem = BlockStorage.check(blockBelow); + final SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(blockBelow.getLocation()); if (slimefunItem instanceof BeaconSiphoningBlock siphon && siphon.tier == this.tier + 1 ) { @@ -158,12 +166,13 @@ public void whenPlaced(@Nonnull BlockPlaceEvent event) { if (WorldUtils.inNether(block.getWorld())) { final UUID uuid = event.getPlayer().getUniqueId(); - BlockStorage.addBlockInfo(location, Keys.BLOCK_OWNER, uuid.toString()); + StorageCacheUtils.setData(location, Keys.BLOCK_OWNER, uuid.toString()); ownerCache.put(location, uuid); return; } // Wasn't placable, so cancel the event event.setCancelled(true); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location); } @Override @@ -178,7 +187,7 @@ public void init() { @Override public void newInstance(@Nonnull BlockMenu menu, @Nonnull Block block) { - final String ownerUuidString = BlockStorage.getLocationInfo(block.getLocation(), Keys.BLOCK_OWNER); + final String ownerUuidString = StorageCacheUtils.getData(block.getLocation(), Keys.BLOCK_OWNER); if (ownerUuidString != null) { final UUID ownerUuid = UUID.fromString(ownerUuidString); addOwner(block.getLocation(), ownerUuid); diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/BiomeSpreadingSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/BiomeSpreadingSeed.java index ef49c0c..a36f783 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/BiomeSpreadingSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/BiomeSpreadingSeed.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.api.items; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import dev.sefiraat.netheopoiesis.Netheopoiesis; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; @@ -28,13 +29,13 @@ public BiomeSpreadingSeed(@Nonnull SlimefunItemStack item) { @Override @ParametersAreNonnullByDefault - public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + public void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { spread(location, seed, data); } @Override @ParametersAreNonnullByDefault - public void afterSpread(Location sourceLocation, NetherSeed seed, Config data, Block spreadTo) { + public void afterSpread(Location sourceLocation, NetherSeed seed, SlimefunBlockData data, Block spreadTo) { if (this.biome != null) { for (int i = spreadTo.getY() - 2; i < spreadTo.getY() + 5; i++) { spreadTo.getWorld().setBiome(spreadTo.getX(), i, spreadTo.getZ(), this.biome); diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/CruxSpreadingSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/CruxSpreadingSeed.java index 8c88450..202114b 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/CruxSpreadingSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/CruxSpreadingSeed.java @@ -1,6 +1,8 @@ package dev.sefiraat.netheopoiesis.api.items; import com.google.common.base.Preconditions; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Netheopoiesis; import dev.sefiraat.netheopoiesis.Purification; import dev.sefiraat.netheopoiesis.api.events.CruxSpreadEvent; @@ -9,9 +11,8 @@ import dev.sefiraat.netheopoiesis.utils.ProtectionUtils; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; @@ -37,13 +38,13 @@ public CruxSpreadingSeed(@Nonnull SlimefunItemStack item) { @Override @ParametersAreNonnullByDefault - public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + public void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { spread(location, seed, data); } @Override @ParametersAreNonnullByDefault - public void spread(Location sourceLocation, NetherSeed seed, Config data) { + public void spread(Location sourceLocation, NetherSeed seed, SlimefunBlockData data) { double randomChance = ThreadLocalRandom.current().nextDouble(); if (randomChance <= (this.spreadChance * Netheopoiesis.CRUX_SPREAD_MULTIPLIER)) { @@ -57,7 +58,7 @@ public void spread(Location sourceLocation, NetherSeed seed, Config data) { // For loop to make sure the purification can creep up and down. final Block block = sourceLocation.clone().add(randomX, randomY, randomZ).getBlock(); - final SlimefunItem possibleCrux = BlockStorage.check(block); + final SlimefunItem possibleCrux = StorageCacheUtils.getSfItem(block.getLocation()); if (possibleCrux instanceof NetherCrux currentCrux && getPlacements().contains(currentCrux.getId()) && ProtectionUtils.hasPermission(getOwner(sourceLocation), block, Interaction.BREAK_BLOCK) @@ -76,7 +77,7 @@ && getPlacements().contains(currentCrux.getId()) // Event cancelled - lets not spread return; } - BlockStorage.clearBlockInfo(block); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(block.getLocation()); Purification.removeValue(block); // Schedule a task to ensure the new block storage happens only AFTER deletion UpdateCruxTask task = new UpdateCruxTask(block, convertTo); diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/DroppingSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/DroppingSeed.java index cde6450..c3dbb55 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/DroppingSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/DroppingSeed.java @@ -1,10 +1,11 @@ package dev.sefiraat.netheopoiesis.api.items; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Netheopoiesis; import io.github.bakedlibs.dough.collections.RandomizedSet; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -33,21 +34,21 @@ public DroppingSeed(@Nonnull SlimefunItemStack item) { @Override @ParametersAreNonnullByDefault - public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + public void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { double randomChance = ThreadLocalRandom.current().nextDouble(); if (randomChance <= chance) { location.getWorld().dropItem(location, this.stacksToDrop.getRandom()); updateGrowthStage(location, 1); - final String currentChance = BlockStorage.getLocationInfo(location, WITHER_KEY); + final String currentChance = StorageCacheUtils.getData(location, WITHER_KEY); if (currentChance == null) { - BlockStorage.addBlockInfo(location, WITHER_KEY, String.valueOf(WITHER_CHANCE)); + StorageCacheUtils.setData(location, WITHER_KEY, String.valueOf(WITHER_CHANCE)); } else { final int currentChanceInt = Integer.parseInt(currentChance); if (ThreadLocalRandom.current().nextInt(101) < currentChanceInt) { location.getBlock().setType(Material.AIR); - BlockStorage.clearBlockInfo(location); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location); } else { - BlockStorage.addBlockInfo(location, WITHER_KEY, String.valueOf(currentChanceInt + WITHER_CHANCE)); + StorageCacheUtils.setData(location, WITHER_KEY, String.valueOf(currentChanceInt + WITHER_CHANCE)); } } } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/EntitySpawningSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/EntitySpawningSeed.java index 4ec3f6b..f532483 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/EntitySpawningSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/EntitySpawningSeed.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.api.items; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import dev.sefiraat.netheopoiesis.Netheopoiesis; import dev.sefiraat.netheopoiesis.utils.WorldUtils; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; @@ -35,7 +36,7 @@ public EntitySpawningSeed(@Nonnull SlimefunItemStack item) { @Override @ParametersAreNonnullByDefault - public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + public void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { double randomChance = ThreadLocalRandom.current().nextDouble(); if (randomChance <= 0.05) { final Block block = WorldUtils.randomLocation(location, 4).getBlock(); diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/GenericTickingSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/GenericTickingSeed.java index 8488d12..0ddae3a 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/GenericTickingSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/GenericTickingSeed.java @@ -1,6 +1,7 @@ package dev.sefiraat.netheopoiesis.api.items; import com.google.common.base.Preconditions; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import dev.sefiraat.netheopoiesis.Netheopoiesis; import dev.sefiraat.netheopoiesis.implementation.GenericTickingMethods; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; @@ -29,7 +30,7 @@ public GenericTickingSeed(@Nonnull SlimefunItemStack item) { @Override @ParametersAreNonnullByDefault - public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + public void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { final GenericTickingMethods.TickParameters tickParameters = new GenericTickingMethods.TickParameters( location, seed, diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherCrux.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherCrux.java index 483a4de..4e5a1db 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherCrux.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherCrux.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.api.items; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import dev.sefiraat.netheopoiesis.api.RecipeTypes; import dev.sefiraat.netheopoiesis.api.interfaces.PurifyingObject; import dev.sefiraat.netheopoiesis.implementation.Stacks; @@ -8,9 +9,8 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.block.BlockBreakEvent; @@ -53,7 +53,7 @@ public void onPlayerBreak(BlockBreakEvent event, ItemStack item, List if (slimefunItem == null || !slimefunItem.getId().equals(Stacks.CRUX_GATHERER.getItemId())) { event.setCancelled(true); block.setType(Material.AIR); - BlockStorage.clearBlockInfo(block); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(block.getLocation()); } removePurificationRegistry(block); } @@ -65,7 +65,7 @@ public boolean isSynchronized() { } @Override - public void tick(Block block, SlimefunItem item, Config data) { + public void tick(Block block, SlimefunItem item, SlimefunBlockData data) { if (NetherCrux.this.tick >= TICKS_REQUIRED) { registerPurificationValue(block); } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java index 815f8bc..4afb1c1 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java @@ -1,11 +1,12 @@ package dev.sefiraat.netheopoiesis.api.items; import com.google.common.base.Preconditions; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Netheopoiesis; import dev.sefiraat.netheopoiesis.Registry; import dev.sefiraat.netheopoiesis.api.RecipeTypes; import dev.sefiraat.netheopoiesis.api.events.PlantBeforeGrowthEvent; -import dev.sefiraat.netheopoiesis.api.interfaces.CustomPlacementBlock; import dev.sefiraat.netheopoiesis.api.interfaces.NetherPlant; import dev.sefiraat.netheopoiesis.api.interfaces.SeedPaste; import dev.sefiraat.netheopoiesis.api.plant.Growth; @@ -32,11 +33,11 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.papermc.lib.PaperLib; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -69,7 +70,7 @@ /** * This class is used to define a Seed item that will grow as a {@link NetherPlant} */ -public abstract class NetherSeed extends SlimefunItem implements NetherPlant, SeedPaste, CustomPlacementBlock { +public abstract class NetherSeed extends SlimefunItem implements NetherPlant, SeedPaste { @Nonnull public static final Set BREEDING_DIRECTIONS = Set.of( @@ -125,12 +126,19 @@ public boolean isSynchronized() { } @Override - public void tick(Block block, SlimefunItem item, Config data) { + public void tick(Block block, SlimefunItem item, SlimefunBlockData data) { if (item instanceof NetherSeed seed) { onTick(block, seed, data); } } }, + new BlockPlaceHandler(false) { + @Override + @ParametersAreNonnullByDefault + public void onPlayerPlace(BlockPlaceEvent e) { + whenPlaced(e); + } + }, new BlockBreakHandler(false, false) { @Override @ParametersAreNonnullByDefault @@ -152,9 +160,9 @@ protected void onBlockUse(@Nonnull PlayerRightClickEvent event) { } @ParametersAreNonnullByDefault - private void onTick(Block block, NetherSeed seed, Config data) { + private void onTick(Block block, NetherSeed seed, SlimefunBlockData data) { final Location location = block.getLocation(); - int growthStage = Integer.parseInt(data.getString(Keys.SEED_GROWTH_STAGE)); + int growthStage = Integer.parseInt(data.getData(Keys.SEED_GROWTH_STAGE)); onTickAlways(location, seed, data); if (growthStage >= getGrowthStages().stages()) { onTickFullyGrown(location, seed, data); @@ -166,7 +174,7 @@ private void onTick(Block block, NetherSeed seed, Config data) { } @ParametersAreNonnullByDefault - private void tryGrow(Block block, NetherSeed seed, Config data, Location location, int growthStage) { + private void tryGrow(Block block, NetherSeed seed, SlimefunBlockData data, Location location, int growthStage) { final double growthRandom = ThreadLocalRandom.current().nextDouble(); if (growthRandom <= getGrowthRate() && getGrowthStages().stages() > growthStage) { PlantBeforeGrowthEvent event = new PlantBeforeGrowthEvent(location, seed, growthStage); @@ -196,7 +204,7 @@ private void tryBreed(@Nonnull Block motherBlock, @Nonnull NetherSeed mother) { return; } final Block potentialMate = middleBlock.getRelative(face); - final SlimefunItem mateItem = BlockStorage.check(potentialMate); + final SlimefunItem mateItem = StorageCacheUtils.getSfItem(potentialMate.getLocation()); if (mateItem instanceof NetherSeed mate) { final BreedResult result = Registry.getInstance().getBreedResult(mother.getId(), mate.getId()); @@ -219,12 +227,13 @@ private void tryBreed(@Nonnull Block motherBlock, @Nonnull NetherSeed mother) { @ParametersAreNonnullByDefault private void trySetChildSeed(Location motherLocation, Block cloneBlock, NetherSeed childSeed) { + final Location cloneBlockLocation = cloneBlock.getLocation(); cloneBlock.setType(Material.PLAYER_HEAD); PlayerHead.setSkin(cloneBlock, childSeed.getGrowthStages().get(0).getPlayerSkin(), false); PaperLib.getBlockState(cloneBlock, false).getState().update(true, false); - BlockStorage.store(cloneBlock, childSeed.getId()); - BlockStorage.addBlockInfo(cloneBlock, Keys.SEED_GROWTH_STAGE, "0"); - BlockStorage.addBlockInfo(cloneBlock, Keys.BLOCK_OWNER, getOwner(motherLocation).toString()); + Slimefun.getDatabaseManager().getBlockDataController().createBlock(cloneBlockLocation, childSeed.getId()); + StorageCacheUtils.setData(cloneBlockLocation, Keys.SEED_GROWTH_STAGE, "0"); + StorageCacheUtils.setData(cloneBlockLocation, Keys.BLOCK_OWNER, getOwner(motherLocation).toString()); breedSuccess(cloneBlock.getLocation()); } @@ -240,7 +249,7 @@ public void init() { @Override public void newInstance(@Nonnull BlockMenu menu, @Nonnull Block block) { - final String ownerUuidString = BlockStorage.getLocationInfo(block.getLocation(), Keys.BLOCK_OWNER); + final String ownerUuidString = StorageCacheUtils.getData(block.getLocation(), Keys.BLOCK_OWNER); if (ownerUuidString != null) { final UUID ownerUuid = UUID.fromString(ownerUuidString); addOwner(block.getLocation(), ownerUuid); @@ -276,7 +285,7 @@ public boolean isMature(@Nonnull Block block) { } public boolean isMature(@Nonnull Location location) { - final String stageString = BlockStorage.getLocationInfo(location, Keys.SEED_GROWTH_STAGE); + final String stageString = StorageCacheUtils.getData(location, Keys.SEED_GROWTH_STAGE); if (stageString == null) { return false; } @@ -293,7 +302,7 @@ public void updateGrowthStage(@Nonnull Block block, int growthStage) { final Skulls nextTexture = getGrowthStages().get(growthStage - 1); PlayerHead.setSkin(block, nextTexture.getPlayerSkin(), false); PaperLib.getBlockState(block, false).getState().update(true, false); - BlockStorage.addBlockInfo(block, Keys.SEED_GROWTH_STAGE, String.valueOf(growthStage)); + StorageCacheUtils.setData(block.getLocation(), Keys.SEED_GROWTH_STAGE, String.valueOf(growthStage)); growthDisplay(block.getLocation()); } } @@ -308,20 +317,21 @@ public void whenPlaced(@Nonnull BlockPlaceEvent event) { final Block block = event.getBlock(); final Block blockBelow = block.getRelative(BlockFace.DOWN); final Location location = block.getLocation(); - final SlimefunItem itemBelow = BlockStorage.check(blockBelow); + final SlimefunItem itemBelow = StorageCacheUtils.getSfItem(blockBelow.getLocation()); if (itemBelow instanceof NetherCrux crux && WorldUtils.inNether(block.getWorld()) && getPlacements().contains(crux.getId()) ) { final UUID uuid = event.getPlayer().getUniqueId(); - BlockStorage.addBlockInfo(location, Keys.SEED_GROWTH_STAGE, "0"); - BlockStorage.addBlockInfo(location, Keys.BLOCK_OWNER, uuid.toString()); + StorageCacheUtils.setData(location, Keys.SEED_GROWTH_STAGE, "0"); + StorageCacheUtils.setData(location, Keys.BLOCK_OWNER, uuid.toString()); ownerCache.put(location, uuid); return; } // Wasn't placable, so cancel the event event.setCancelled(true); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location); } /** diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/GenericTickingMethods.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/GenericTickingMethods.java index 8ac8d0e..3477f21 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/GenericTickingMethods.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/GenericTickingMethods.java @@ -1,13 +1,13 @@ package dev.sefiraat.netheopoiesis.implementation; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.api.items.GenericTickingSeed; import dev.sefiraat.netheopoiesis.api.items.NetherCrux; import dev.sefiraat.netheopoiesis.api.items.NetherSeed; import dev.sefiraat.netheopoiesis.utils.Theme; import dev.sefiraat.netheopoiesis.utils.WorldUtils; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.TreeType; @@ -75,7 +75,7 @@ public static void onTickSpindleSeed(@Nonnull TickParameters params) { } final Block blockBelow = block.getRelative(BlockFace.DOWN); - final SlimefunItem possibleCrux = BlockStorage.check(blockBelow); + final SlimefunItem possibleCrux = StorageCacheUtils.getSfItem(blockBelow.getLocation()); // And the block below must be a valid crux if (possibleCrux instanceof NetherCrux crux @@ -97,7 +97,7 @@ public static void onTickSweetSeed(@Nonnull TickParameters params) { } final Block blockBelow = block.getRelative(BlockFace.DOWN); - final SlimefunItem possibleCrux = BlockStorage.check(blockBelow); + final SlimefunItem possibleCrux = StorageCacheUtils.getSfItem(blockBelow.getLocation()); // And the block below must be a valid crux if (blockBelow.getType() == Material.SAND @@ -120,7 +120,7 @@ public static void onTickSpineySeed(@Nonnull TickParameters params) { } final Block blockBelow = block.getRelative(BlockFace.DOWN); - final SlimefunItem possibleCrux = BlockStorage.check(blockBelow); + final SlimefunItem possibleCrux = StorageCacheUtils.getSfItem(blockBelow.getLocation()); // And the block below must be a valid crux if (possibleCrux instanceof NetherCrux crux @@ -142,7 +142,7 @@ public static void onTickOakendranSeed(@Nonnull TickParameters params) { } final Block blockBelow = block.getRelative(BlockFace.DOWN); - final SlimefunItem possibleCrux = BlockStorage.check(blockBelow); + final SlimefunItem possibleCrux = StorageCacheUtils.getSfItem(blockBelow.getLocation()); // And the block below must be a valid crux if (possibleCrux instanceof NetherCrux crux @@ -198,10 +198,10 @@ private static void tryBroadcastRandomMessage(Location location, Theme theme, Se public static class TickParameters { private final Location location; private final NetherSeed seed; - private final Config data; + private final SlimefunBlockData data; @ParametersAreNonnullByDefault - public TickParameters(Location location, NetherSeed seed, Config data) { + public TickParameters(Location location, NetherSeed seed, SlimefunBlockData data) { this.location = location; this.seed = seed; this.data = data; @@ -215,7 +215,7 @@ public NetherSeed getSeed() { return seed; } - public Config getData() { + public SlimefunBlockData getData() { return data; } } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/blocks/NetherBeacon.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/blocks/NetherBeacon.java index 5c1ec63..75cadeb 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/blocks/NetherBeacon.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/blocks/NetherBeacon.java @@ -1,5 +1,7 @@ package dev.sefiraat.netheopoiesis.implementation.blocks; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.api.items.BeaconSiphoningBlock; import dev.sefiraat.netheopoiesis.utils.Keys; import dev.sefiraat.netheopoiesis.utils.ParticleUtils; @@ -10,8 +12,6 @@ import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI; import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -44,7 +44,7 @@ public NetherBeacon(ItemGroup itemGroup, @Override @ParametersAreNonnullByDefault - protected boolean onTick(Block block, SlimefunItem item, Config data) { + protected boolean onTick(Block block, SlimefunItem item, SlimefunBlockData data) { // Call super to ensure the tick is valid if (!super.onTick(block, item, data)) { return false; @@ -77,7 +77,7 @@ protected boolean onTick(Block block, SlimefunItem item, Config data) { // If player doesn't have permission to break block or if it's an SF block, skip this one if (!ProtectionUtils.hasPermission(getOwner(block.getLocation()), testBlockBelow, Interaction.BREAK_BLOCK) - || BlockStorage.check(testBlock) != null + || StorageCacheUtils.getSfItem(testBlock.getLocation()) != null ) { continue; } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/CrystallineCrux.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/CrystallineCrux.java index 8ff4b8e..260f4c9 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/CrystallineCrux.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/CrystallineCrux.java @@ -1,5 +1,7 @@ package dev.sefiraat.netheopoiesis.implementation.flora; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Netheopoiesis; import dev.sefiraat.netheopoiesis.Purification; import dev.sefiraat.netheopoiesis.api.items.NetherCrux; @@ -10,9 +12,8 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -66,7 +67,7 @@ public void onPlayerBreak(BlockBreakEvent event, ItemStack item, List event.setCancelled(true); block.setType(Material.AIR); } - BlockStorage.clearBlockInfo(block); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(block.getLocation()); removePurificationRegistry(block); } }, @@ -77,7 +78,7 @@ public boolean isSynchronized() { } @Override - public void tick(Block block, SlimefunItem item, Config data) { + public void tick(Block block, SlimefunItem item, SlimefunBlockData data) { onTick(block); } } @@ -90,7 +91,7 @@ private void onTick(@Nonnull Block block) { // If no steps left, kill off the block to stop ticking if (stepsLeft == 0) { block.setType(Material.WATER, true); - BlockStorage.clearBlockInfo(block); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(block.getLocation()); Purification.removeValue(block); return; } @@ -104,7 +105,7 @@ private void onTick(@Nonnull Block block) { canTransform = false; if (chance <= required) { - BlockStorage.clearBlockInfo(testBlock); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(testBlock.getLocation()); Purification.removeValue(testBlock); // Schedule a task to ensure the new block storage happens only AFTER deletion final UpdateCruxTask task = new UpdateCruxTask( @@ -119,17 +120,17 @@ private void onTick(@Nonnull Block block) { // We can only transform when there is no lava around, to stop turning to cobble if (canTransform) { block.setType(Material.WATER, true); - BlockStorage.clearBlockInfo(block); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(block.getLocation()); Purification.removeValue(block); } } public void setRemainingSteps(@Nonnull Block block, int steps) { - BlockStorage.addBlockInfo(block, Keys.CRYSTALLINE_STEPS_REMAINING, String.valueOf(steps)); + StorageCacheUtils.setData(block.getLocation(), Keys.CRYSTALLINE_STEPS_REMAINING, String.valueOf(steps)); } public int getRemainingSteps(@Nonnull Block block) { - final String steps = BlockStorage.getLocationInfo(block.getLocation(), Keys.CRYSTALLINE_STEPS_REMAINING); + final String steps = StorageCacheUtils.getData(block.getLocation(), Keys.CRYSTALLINE_STEPS_REMAINING); return steps == null ? 0 : Integer.parseInt(steps); } } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/PurificationSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/PurificationSeed.java index 65545d4..47d96b2 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/PurificationSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/flora/PurificationSeed.java @@ -1,5 +1,7 @@ package dev.sefiraat.netheopoiesis.implementation.flora; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Netheopoiesis; import dev.sefiraat.netheopoiesis.Purification; import dev.sefiraat.netheopoiesis.api.RecipeTypes; @@ -13,9 +15,8 @@ import dev.sefiraat.netheopoiesis.utils.WorldUtils; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -52,7 +53,7 @@ public PurificationSeed(SlimefunItemStack item, ItemStack[] recipe) { @Override @ParametersAreNonnullByDefault - public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { + public void onTickFullyGrown(Location location, NetherSeed seed, SlimefunBlockData data) { double randomChance = ThreadLocalRandom.current().nextDouble(); if (randomChance > 0.25) { @@ -83,7 +84,7 @@ public void onTickFullyGrown(Location location, NetherSeed seed, Config data) { // Event cancelled - lets not spread return; } - BlockStorage.clearBlockInfo(block); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(block.getLocation()); Purification.removeValue(block); // Schedule a task to ensure the new block storage happens only AFTER deletion UpdateCruxTask task = new UpdateCruxTask(block, Stacks.BASIC_PURIFIED_NETHERRACK); @@ -96,7 +97,7 @@ public void whenPlaced(@Nonnull BlockPlaceEvent event) { // We override this as this is the only one able to be placed on both vanilla and crux' final Block block = event.getBlock(); final Block blockBelow = block.getRelative(BlockFace.DOWN); - final SlimefunItem possibleCrux = BlockStorage.check(blockBelow); + final SlimefunItem possibleCrux = StorageCacheUtils.getSfItem(blockBelow.getLocation()); final Location location = block.getLocation(); if (location.getWorld() != null @@ -104,11 +105,12 @@ public void whenPlaced(@Nonnull BlockPlaceEvent event) { && (materials.contains(blockBelow.getType()) || possibleCrux instanceof NetherCrux) ) { final UUID uuid = event.getPlayer().getUniqueId(); - BlockStorage.addBlockInfo(location, Keys.SEED_GROWTH_STAGE, "0"); - BlockStorage.addBlockInfo(location, Keys.BLOCK_OWNER, uuid.toString()); + StorageCacheUtils.setData(location, Keys.SEED_GROWTH_STAGE, "0"); + StorageCacheUtils.setData(location, Keys.BLOCK_OWNER, uuid.toString()); ownerCache.put(location, uuid); } else { event.setCancelled(true); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location); } } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tasks/UpdateCruxTask.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tasks/UpdateCruxTask.java index f2bb3fd..e23fede 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tasks/UpdateCruxTask.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tasks/UpdateCruxTask.java @@ -1,9 +1,9 @@ package dev.sefiraat.netheopoiesis.implementation.tasks; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.utils.Keys; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.block.Block; import org.bukkit.scheduler.BukkitRunnable; @@ -35,15 +35,15 @@ public UpdateCruxTask(@Nonnull Block block, @Nonnull SlimefunItemStack crux, int @Override public void run() { - if (Slimefun.getTickerTask().isDeletedSoon(block.getLocation())) { - // BlockStorage still has not been cleared - return; - } +// if (Slimefun.getTickerTask().isDeletedSoon(block.getLocation())) { +// // BlockStorage still has not been cleared +// return; +// } // Store the new data then cancel task block.setType(crux.getType()); - BlockStorage.store(block, crux.getItemId()); + Slimefun.getDatabaseManager().getBlockDataController().createBlock(block.getLocation(), crux.getItemId()); if (steps > -1) { - BlockStorage.addBlockInfo(block, Keys.CRYSTALLINE_STEPS_REMAINING, String.valueOf(this.steps)); + StorageCacheUtils.setData(block.getLocation(), Keys.CRYSTALLINE_STEPS_REMAINING, String.valueOf(this.steps)); } cancel(); } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/Analyser.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/Analyser.java index d6c14fd..9ced9c3 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/Analyser.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/Analyser.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.implementation.tools; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.api.items.BeaconSiphoningBlock; import dev.sefiraat.netheopoiesis.api.items.NetherSeed; import dev.sefiraat.netheopoiesis.utils.ItemStackUtils; @@ -60,7 +61,7 @@ private void onUse(@Nonnull PlayerRightClickEvent event) { return; } - final SlimefunItem slimefunItem = BlockStorage.check(block); + final SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(block.getLocation()); if (slimefunItem instanceof NetherSeed plant && types.contains(AnalyserType.SEED)) { onUseSeed(block, plant, player); @@ -75,8 +76,8 @@ private void onUse(@Nonnull PlayerRightClickEvent event) { @ParametersAreNonnullByDefault private void onUseSeed(Block block, NetherSeed plant, Player player) { - final String growthStage = BlockStorage.getLocationInfo(block.getLocation(), Keys.SEED_GROWTH_STAGE); - final String ownerString = BlockStorage.getLocationInfo(block.getLocation(), Keys.BLOCK_OWNER); + final String growthStage = StorageCacheUtils.getData(block.getLocation(), Keys.SEED_GROWTH_STAGE); + final String ownerString = StorageCacheUtils.getData(block.getLocation(), Keys.BLOCK_OWNER); final UUID uuid = UUID.fromString(ownerString); final OfflinePlayer ownerPlayer = Bukkit.getOfflinePlayer(uuid); diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/HarvestingTool.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/HarvestingTool.java index aa19c1e..bd99c3e 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/HarvestingTool.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/HarvestingTool.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.implementation.tools; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.api.items.HarvestableSeed; import dev.sefiraat.netheopoiesis.api.items.NetherSeed; import dev.sefiraat.netheopoiesis.utils.Keys; @@ -50,7 +51,7 @@ private void onUse(@Nonnull PlayerRightClickEvent e) { final Optional optional = e.getClickedBlock(); if (optional.isPresent()) { final Block block = optional.get(); - final SlimefunItem slimefunItem = BlockStorage.check(block); + final SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(block.getLocation()); if (slimefunItem instanceof HarvestableSeed seed && canHarvest(seed, block, e.getPlayer())) { final ItemStack stackToDrop = seed.getHarvestingResult(); seed.updateGrowthStage(block, 1); diff --git a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/PurificationScanner.java b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/PurificationScanner.java index 9d5a09c..681fab4 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/PurificationScanner.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/implementation/tools/PurificationScanner.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.implementation.tools; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.api.interfaces.PurifyingObject; import dev.sefiraat.netheopoiesis.utils.ItemStackUtils; import dev.sefiraat.netheopoiesis.utils.ProtectionUtils; @@ -48,7 +49,7 @@ private void onUse(@Nonnull PlayerRightClickEvent event) { return; } - final SlimefunItem slimefunItem = BlockStorage.check(block); + final SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(block.getLocation()); if (slimefunItem instanceof PurifyingObject object && ProtectionUtils.hasPermission(player, block, Interaction.INTERACT_BLOCK) diff --git a/src/main/java/dev/sefiraat/netheopoiesis/listeners/BlockProtectionListener.java b/src/main/java/dev/sefiraat/netheopoiesis/listeners/BlockProtectionListener.java index 4b1aa5e..f4fcc4e 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/listeners/BlockProtectionListener.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/listeners/BlockProtectionListener.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.listeners; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.api.items.NetherCrux; import dev.sefiraat.netheopoiesis.api.items.NetherSeed; import dev.sefiraat.netheopoiesis.utils.WorldUtils; @@ -24,7 +25,7 @@ public class BlockProtectionListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockChange(@Nonnull EntityChangeBlockEvent event) { if (WorldUtils.inNether(event.getEntity())) { - final SlimefunItem slimefunItem = BlockStorage.check(event.getBlock()); + final SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(event.getBlock().getLocation()); if (slimefunItem instanceof NetherSeed || slimefunItem instanceof NetherCrux) { event.setCancelled(true); } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/listeners/CrystallineSeedListener.java b/src/main/java/dev/sefiraat/netheopoiesis/listeners/CrystallineSeedListener.java index c64f47f..6fcc6f5 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/listeners/CrystallineSeedListener.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/listeners/CrystallineSeedListener.java @@ -1,5 +1,6 @@ package dev.sefiraat.netheopoiesis.listeners; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.implementation.Stacks; import dev.sefiraat.netheopoiesis.implementation.flora.CrystallineCrux; import dev.sefiraat.netheopoiesis.utils.Keys; @@ -47,7 +48,7 @@ public void onSeedEntersLava(@Nonnull EntityDamageEvent event) { final SlimefunItemStack crux = Stacks.CRYSTALLINE_CRUX; block.setType(crux.getType()); BlockStorage.store(block, crux.getItemId()); - BlockStorage.addBlockInfo(block, Keys.CRYSTALLINE_STEPS_REMAINING, String.valueOf(CrystallineCrux.STEPS)); + StorageCacheUtils.setData(block.getLocation(), Keys.CRYSTALLINE_STEPS_REMAINING, String.valueOf(CrystallineCrux.STEPS)); event.getEntity().remove(); } }