From 5a7bb86112d6262904d51e711a98dd23056bf3ec Mon Sep 17 00:00:00 2001 From: XiaoMoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:13:57 +0800 Subject: [PATCH] fix some bugs --- .../customcrops/api/core/block/PotBlock.java | 1 + .../command/feature/DebugInsightCommand.java | 22 ++++++++++++++++++- plugin/src/main/resources/config.yml | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) 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 c813221..7b42047 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 @@ -377,6 +377,7 @@ public class PotBlock extends AbstractCustomCropsBlock { waterChanged = true; } hasNaturalWater = true; + break; } } } diff --git a/plugin/src/main/java/net/momirealms/customcrops/bukkit/command/feature/DebugInsightCommand.java b/plugin/src/main/java/net/momirealms/customcrops/bukkit/command/feature/DebugInsightCommand.java index 3adc88c..0cc9229 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/bukkit/command/feature/DebugInsightCommand.java +++ b/plugin/src/main/java/net/momirealms/customcrops/bukkit/command/feature/DebugInsightCommand.java @@ -33,6 +33,10 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.metadata.FixedMetadataValue; import org.incendo.cloud.Command; import org.incendo.cloud.CommandManager; @@ -40,7 +44,7 @@ import org.incendo.cloud.CommandManager; import java.util.*; import java.util.concurrent.TimeUnit; -public class DebugInsightCommand extends BukkitCommandFeature { +public class DebugInsightCommand extends BukkitCommandFeature implements Listener { public DebugInsightCommand(CustomCropsCommandManager commandManager) { super(commandManager); @@ -71,6 +75,22 @@ public class DebugInsightCommand extends BukkitCommandFeature { return "debug_insight"; } + @Override + public void unregisterRelatedFunctions() { + HandlerList.unregisterAll(this); + } + + @Override + public void registerRelatedFunctions() { + Bukkit.getPluginManager().registerEvents(this, BukkitCustomCropsPlugin.getInstance().getBoostrap()); + } + + @EventHandler + public void onQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + player.removeMetadata("customcrops:insight", BukkitCustomCropsPlugin.getInstance().getBoostrap()); + } + public static class InsightPlayer implements Runnable { private final SchedulerTask task; diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index 71601ee..7fc7d2e 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -41,7 +41,7 @@ worlds: # 300s means that a crop would be certainly ticked once in 300s # For crops, under the same conditions, the growth rate of crops is basically the same # For sprinklers and pots, they would work periodically. - min-tick-unit: 300 + min-tick-unit: 180 # Offline tick settings # This option allows crops to grow even if the world is unloaded or the server is closed # This may lead to some issues caused by timeliness conditions for instance seasons