diff --git a/api/src/main/java/net/momirealms/customcrops/api/core/block/PotBlock.java b/api/src/main/java/net/momirealms/customcrops/api/core/block/PotBlock.java index 203b447..c9f1550 100644 --- a/api/src/main/java/net/momirealms/customcrops/api/core/block/PotBlock.java +++ b/api/src/main/java/net/momirealms/customcrops/api/core/block/PotBlock.java @@ -74,7 +74,7 @@ public class PotBlock extends AbstractCustomCropsBlock { // ignore random tick if (world.setting().tickPotMode() == 1) return; if (canTick(state, world.setting().tickPotInterval())) { - tickPot(state, world, location, offlineTick); + tickPot(state, world, location, offlineTick, false); } } @@ -83,7 +83,7 @@ public class PotBlock extends AbstractCustomCropsBlock { // ignore scheduled tick if (world.setting().tickPotMode() == 2) return; if (canTick(state, world.setting().tickPotInterval())) { - tickPot(state, world, location, offlineTick); + tickPot(state, world, location, offlineTick, true); } } @@ -356,7 +356,7 @@ public class PotBlock extends AbstractCustomCropsBlock { return state; } - private void tickPot(CustomCropsBlockState state, CustomCropsWorld world, Pos3 location, boolean offline) { + private void tickPot(CustomCropsBlockState state, CustomCropsWorld world, Pos3 location, boolean offline, boolean tickMode) { PotConfig config = config(state); BukkitCustomCropsPlugin plugin = BukkitCustomCropsPlugin.getInstance(); if (config == null) { @@ -365,8 +365,10 @@ public class PotBlock extends AbstractCustomCropsBlock { return; } + if (tickMode && config.ignoreRandomTick()) return; + if (!tickMode && config.ignoreScheduledTick()) return; + World bukkitWorld = world.bukkitWorld(); - CompletableFuture future = new CompletableFuture<>(); if (ConfigManager.doubleCheck()) { String blockID = plugin.getItemManager().blockID(location.toLocation(bukkitWorld)); if (!config.blocks().contains(blockID)) { diff --git a/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfig.java b/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfig.java index a619f8d..e10e654 100644 --- a/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfig.java +++ b/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfig.java @@ -70,6 +70,20 @@ public interface PotConfig { */ boolean disablePluginMechanism(); + /** + * Should the pot ignore scheduled tick? + * + * @return ignore or not + */ + boolean ignoreScheduledTick(); + + /** + * Should the pot ignore random tick? + * + * @return ignore or not + */ + boolean ignoreRandomTick(); + /** * Gets the methods available for watering the pot. * @@ -261,6 +275,10 @@ public interface PotConfig { */ Builder isNearbyWaterAccepted(boolean isNearbyWaterAccepted); + Builder ignoreRandomTick(boolean ignoreRandomTick); + + Builder ignoreScheduledTick(boolean ignoreScheduledTick); + /** * Sets the methods available for watering the pot. * diff --git a/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfigImpl.java b/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfigImpl.java index 3bc486c..c370fba 100644 --- a/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfigImpl.java +++ b/api/src/main/java/net/momirealms/customcrops/api/core/mechanic/pot/PotConfigImpl.java @@ -42,6 +42,8 @@ public class PotConfigImpl implements PotConfig { private final int storage; private final boolean isRainDropAccepted; private final boolean isNearbyWaterAccepted; + private final boolean ignoreRandomTick; + private final boolean ignoreScheduledTick; private final WateringMethod[] wateringMethods; private final WaterBar waterBar; private final int maxFertilizers; @@ -65,6 +67,8 @@ public class PotConfigImpl implements PotConfig { int storage, boolean isRainDropAccepted, boolean isNearbyWaterAccepted, + boolean ignoreRandomTick, + boolean ignoreScheduledTick, WateringMethod[] wateringMethods, WaterBar waterBar, int maxFertilizers, @@ -102,6 +106,8 @@ public class PotConfigImpl implements PotConfig { this.addWaterActions = addWaterActions; this.fullWaterActions = fullWaterActions; this.maxFertilizerActions = maxFertilizerActions; + this.ignoreRandomTick = ignoreRandomTick; + this.ignoreScheduledTick = ignoreScheduledTick; this.blocks.add(basicAppearance.left()); this.blocks.add(basicAppearance.right()); this.wetBlocks.add(basicAppearance.right()); @@ -153,6 +159,16 @@ public class PotConfigImpl implements PotConfig { return disablePluginSystem; } + @Override + public boolean ignoreScheduledTick() { + return ignoreScheduledTick; + } + + @Override + public boolean ignoreRandomTick() { + return ignoreRandomTick; + } + @Override public WateringMethod[] wateringMethods() { if (disablePluginMechanism()) return new WateringMethod[0]; @@ -257,6 +273,8 @@ public class PotConfigImpl implements PotConfig { private int storage; private boolean isRainDropAccepted; private boolean isNearbyWaterAccepted; + private boolean ignoreRandomTick; + private boolean ignoreScheduledTick; private WateringMethod[] wateringMethods; private WaterBar waterBar; private int maxFertilizers; @@ -275,7 +293,7 @@ public class PotConfigImpl implements PotConfig { @Override public PotConfig build() { - return new PotConfigImpl(id, vanillaFarmland, basicAppearance, potAppearanceMap, storage, isRainDropAccepted, isNearbyWaterAccepted, wateringMethods, waterBar, maxFertilizers, placeRequirements, breakRequirements, useRequirements, tickActions, reachLimitActions, interactActions, placeActions, breakActions, addWaterActions, fullWaterActions, maxFertilizerActions, vanillaPots); + return new PotConfigImpl(id, vanillaFarmland, basicAppearance, potAppearanceMap, storage, isRainDropAccepted, isNearbyWaterAccepted, ignoreRandomTick, ignoreScheduledTick, wateringMethods, waterBar, maxFertilizers, placeRequirements, breakRequirements, useRequirements, tickActions, reachLimitActions, interactActions, placeActions, breakActions, addWaterActions, fullWaterActions, maxFertilizerActions, vanillaPots); } @Override @@ -314,6 +332,18 @@ public class PotConfigImpl implements PotConfig { return this; } + @Override + public Builder ignoreRandomTick(boolean ignoreRandomTick) { + this.ignoreRandomTick = ignoreRandomTick; + return this; + } + + @Override + public Builder ignoreScheduledTick(boolean ignoreScheduledTick) { + this.ignoreScheduledTick = ignoreScheduledTick; + return this; + } + @Override public Builder wateringMethods(WateringMethod[] wateringMethods) { this.wateringMethods = wateringMethods; diff --git a/compatibility/build.gradle.kts b/compatibility/build.gradle.kts index 1960f0a..6d43721 100644 --- a/compatibility/build.gradle.kts +++ b/compatibility/build.gradle.kts @@ -47,6 +47,8 @@ dependencies { compileOnly("org.betonquest:betonquest:2.1.3") // item compileOnly(files("libs/zaphkiel-2.0.24.jar")) + compileOnly(files("libs/ExecutableItems-7.24.9.29.jar")) + compileOnly(files("libs/SCore-5.24.9.29.jar")) compileOnly("net.Indyuce:MMOItems-API:6.10-SNAPSHOT") compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT") compileOnly("pers.neige.neigeitems:NeigeItems:1.17.13") diff --git a/compatibility/libs/ExecutableItems-7.24.9.29.jar b/compatibility/libs/ExecutableItems-7.24.9.29.jar new file mode 100644 index 0000000..082b2bf Binary files /dev/null and b/compatibility/libs/ExecutableItems-7.24.9.29.jar differ diff --git a/compatibility/libs/SCore-5.24.9.29.jar b/compatibility/libs/SCore-5.24.9.29.jar new file mode 100644 index 0000000..ff7c892 Binary files /dev/null and b/compatibility/libs/SCore-5.24.9.29.jar differ diff --git a/compatibility/src/main/java/net/momirealms/customcrops/bukkit/integration/item/ExecutableItemProvider.java b/compatibility/src/main/java/net/momirealms/customcrops/bukkit/integration/item/ExecutableItemProvider.java new file mode 100644 index 0000000..3273321 --- /dev/null +++ b/compatibility/src/main/java/net/momirealms/customcrops/bukkit/integration/item/ExecutableItemProvider.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) <2024> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customcrops.bukkit.integration.item; + +import com.ssomar.executableitems.executableitems.manager.ExecutableItemsManager; +import com.ssomar.score.api.executableitems.config.ExecutableItemInterface; +import net.momirealms.customcrops.api.integration.ItemProvider; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class ExecutableItemProvider implements ItemProvider { + + @Override + public @NotNull ItemStack buildItem(@NotNull Player player, @NotNull String id) { + return ExecutableItemsManager.getInstance().getExecutableItem(id).get().buildItem(1, Optional.of(player)); + } + + @Nullable + @Override + public String itemID(@NotNull ItemStack itemStack) { + return ExecutableItemsManager.getInstance().getExecutableItem(itemStack).map(ExecutableItemInterface::getId).orElse(null); + } + + @Override + public String identifier() { + return "ExecutableItems"; + } +} diff --git a/gradle.properties b/gradle.properties index 39ee797..346999f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Project settings # Rule: [major update].[feature update].[bug fix] -project_version=3.6.12 +project_version=3.6.13 config_version=41 project_group=net.momirealms diff --git a/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/ConfigType.java b/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/ConfigType.java index 38bbacd..adbabb3 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/ConfigType.java +++ b/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/ConfigType.java @@ -118,6 +118,8 @@ public class ConfigType { .id(id) .vanillaFarmland(section.getBoolean("vanilla-farmland", false)) .vanillaPots(ListUtils.toList(section.get("vanilla-blocks"))) + .ignoreRandomTick(section.getBoolean("ignore-random-tick", false)) + .ignoreScheduledTick(section.getBoolean("ignore-scheduled-tick", false)) .storage(section.getInt("storage", 5)) .isRainDropAccepted(section.getBoolean("absorb-rainwater", false)) .isNearbyWaterAccepted(section.getBoolean("absorb-nearby-water", false)) diff --git a/plugin/src/main/java/net/momirealms/customcrops/bukkit/integration/BukkitIntegrationManager.java b/plugin/src/main/java/net/momirealms/customcrops/bukkit/integration/BukkitIntegrationManager.java index b9a0508..0163edc 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/bukkit/integration/BukkitIntegrationManager.java +++ b/plugin/src/main/java/net/momirealms/customcrops/bukkit/integration/BukkitIntegrationManager.java @@ -69,6 +69,9 @@ public class BukkitIntegrationManager implements IntegrationManager { if (isHooked("Zaphkiel")) { registerItemProvider(new ZaphkielItemProvider()); } + if (isHooked("ExecutableItems")) { + registerItemProvider(new ExecutableItemProvider()); + } if (isHooked("NeigeItems")) { registerItemProvider(new NeigeItemsItemProvider()); }