9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-19 15:09:25 +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,9 +416,15 @@ public class CropBlock extends AbstractCustomCropsBlock {
if (ConfigManager.doubleCheck()) {
plugin.getScheduler().sync().run(() -> {
CropStageConfig nearest = config.stageWithModelByPoint(previousPoint);
String blockID = plugin.getItemManager().id(location.toLocation(bukkitWorld), nearest.existenceForm());
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 + "]");
if (nearest != null) {
String blockID = plugin.getItemManager().id(location.toLocation(bukkitWorld), nearest.existenceForm());
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 + "]");
world.removeBlockState(location);
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;
}