9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-19 23:19:19 +00:00

Fix possible error is crop config has been changed

This commit is contained in:
XiaoMoMi
2024-10-24 20:03:36 +08:00
parent 0941070944
commit c2d36a1f12

View File

@@ -416,12 +416,18 @@ public class CropBlock extends AbstractCustomCropsBlock {
if (ConfigManager.doubleCheck()) { if (ConfigManager.doubleCheck()) {
plugin.getScheduler().sync().run(() -> { plugin.getScheduler().sync().run(() -> {
CropStageConfig nearest = config.stageWithModelByPoint(previousPoint); CropStageConfig nearest = config.stageWithModelByPoint(previousPoint);
if (nearest != null) {
String blockID = plugin.getItemManager().id(location.toLocation(bukkitWorld), nearest.existenceForm()); String blockID = plugin.getItemManager().id(location.toLocation(bukkitWorld), nearest.existenceForm());
if (!config.stageIDs().contains(blockID)) { if (!config.stageIDs().contains(blockID)) {
plugin.getPluginLogger().warn("Crop[" + config.id() + "] is removed at location[" + world.worldName() + "," + location + "] because the id of the block is [" + blockID + "]"); plugin.getPluginLogger().warn("Crop[" + config.id() + "] is removed at location[" + world.worldName() + "," + location + "] because the id of the block is [" + blockID + "]");
world.removeBlockState(location); world.removeBlockState(location);
return; return;
} }
} else {
plugin.getPluginLogger().warn("Crop[" + config.id() + "] is removed at location[" + world.worldName() + "," + location + "] because no model found for point[" + previousPoint + "]");
world.removeBlockState(location);
return;
}
world.scheduler().async().execute(task); world.scheduler().async().execute(task);
}, bukkitLocation); }, bukkitLocation);
} else { } else {