diff --git a/src/main/java/net/momirealms/customcrops/Crops/TimeCheck.java b/src/main/java/net/momirealms/customcrops/Crops/TimeCheck.java index 5e3e508..19529cd 100644 --- a/src/main/java/net/momirealms/customcrops/Crops/TimeCheck.java +++ b/src/main/java/net/momirealms/customcrops/Crops/TimeCheck.java @@ -45,7 +45,8 @@ public class TimeCheck extends BukkitRunnable { if (CustomBlock.byAlreadyPlaced(world.getBlockAt(seedLocation)).getNamespacedID().equalsIgnoreCase(config.getString("config.dead-crop"))){ return; } - String[] cropNameList = CustomBlock.byAlreadyPlaced(world.getBlockAt(seedLocation)).getNamespacedID().split("_"); + String namespace = CustomBlock.byAlreadyPlaced(world.getBlockAt(seedLocation)).getNamespacedID().split(":")[0]; + String[] cropNameList = CustomBlock.byAlreadyPlaced(world.getBlockAt(seedLocation)).getNamespacedID().split(":")[1].split("_"); Label_out: if(enable_season){ if(enable_greenhouse){ @@ -74,13 +75,13 @@ public class TimeCheck extends BukkitRunnable { } } int nextStage = Integer.parseInt(cropNameList[2]) + 1; - if (CustomBlock.getInstance(cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage) != null) { + if (CustomBlock.getInstance( namespace +":"+cropNameList[0] + "_stage_" + nextStage) != null) { Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, () ->{ CustomBlock.remove(potLocation); CustomBlock.place(config.getString("config.pot"),potLocation); if(Math.random()< config.getDouble("config.grow-success-chance")){ CustomBlock.remove(seedLocation); - CustomBlock.place(cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage,seedLocation); + CustomBlock.place(namespace + ":" + cropNameList[0] + "_stage_" + nextStage,seedLocation); } return null; }); diff --git a/src/main/java/net/momirealms/customcrops/Integrations/PlotSquaredIntegrations.java b/src/main/java/net/momirealms/customcrops/Integrations/PlotSquaredIntegrations.java new file mode 100644 index 0000000..4c9b65d --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/Integrations/PlotSquaredIntegrations.java @@ -0,0 +1,4 @@ +package net.momirealms.customcrops.Integrations; + +public class PlotSquaredIntegrations { +} diff --git a/src/main/java/net/momirealms/customcrops/listener/RightClickCustomBlock.java b/src/main/java/net/momirealms/customcrops/listener/RightClickCustomBlock.java index d1594a9..99cea0f 100644 --- a/src/main/java/net/momirealms/customcrops/listener/RightClickCustomBlock.java +++ b/src/main/java/net/momirealms/customcrops/listener/RightClickCustomBlock.java @@ -57,7 +57,7 @@ public class RightClickCustomBlock implements Listener { String namespace = clickedCustomBlock.getNamespacedID().split(":")[0]; String[] cropNameList = clickedCustomBlock.getNamespacedID().split(":")[1].split("_"); int nextStage = Integer.parseInt(cropNameList[2]) + 1; - if (CustomBlock.getInstance(namespace + ":" + cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage) == null) { + if (CustomBlock.getInstance(namespace + ":" + cropNameList[0] + "_stage_" + nextStage) == null) { clickedCustomBlock.getLoot().forEach(itemStack -> { clickedBlockLocation.getWorld().dropItem(clickedBlockLocation.clone().add(0.5,0.2,0.5),itemStack); }); @@ -107,17 +107,18 @@ public class RightClickCustomBlock implements Listener { if (mainHandItem.getType() == Material.BONE_MEAL){ //植物是否具有stage属性 if (clickedCustomBlock.getNamespacedID().contains("stage")){ - String[] cropNameList = clickedCustomBlock.getNamespacedID().split("_"); + String namespace = clickedCustomBlock.getNamespacedID().split(":")[0]; + String[] cropNameList = clickedCustomBlock.getNamespacedID().split(":")[1].split("_"); int nextStage = Integer.parseInt(cropNameList[2]) + 1; //植物是否存在下一个stage - if (CustomBlock.getInstance(cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage) != null){ + if (CustomBlock.getInstance(namespace+ ":" + cropNameList[0] + "_stage_" + nextStage) != null){ if(player.getGameMode() != GameMode.CREATIVE){ mainHandItem.setAmount(mainHandItem.getAmount() - 1); } //骨粉的成功率 if (Math.random() < config.getDouble("config.bone-meal-chance")){ CustomBlock.remove(clickedBlockLocation); - CustomBlock.place(cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage,clickedBlockLocation); + CustomBlock.place(namespace + ":" + cropNameList[0] + "_stage_" + nextStage,clickedBlockLocation); Particle particleSuccess = Particle.valueOf(config.getString("config.particle.success")); world.spawnParticle(particleSuccess, clickedBlockLocation.clone().add(0.5, 0.1,0.5), 1 ,0,0,0,0); //使用骨粉是否消耗水分 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8665534..2db8749 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: CustomCrops -version: '1.1' +version: '1.2' main: net.momirealms.customcrops.CustomCrops api-version: 1.18 depend: [ ItemsAdder , ProtocolLib ]