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

namespace fix

This commit is contained in:
Xiao-MoMi
2022-05-23 01:23:44 +08:00
parent 90ce8cc1cd
commit 69ee532c94
4 changed files with 14 additions and 8 deletions

View File

@@ -45,7 +45,8 @@ public class TimeCheck extends BukkitRunnable {
if (CustomBlock.byAlreadyPlaced(world.getBlockAt(seedLocation)).getNamespacedID().equalsIgnoreCase(config.getString("config.dead-crop"))){ if (CustomBlock.byAlreadyPlaced(world.getBlockAt(seedLocation)).getNamespacedID().equalsIgnoreCase(config.getString("config.dead-crop"))){
return; 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: Label_out:
if(enable_season){ if(enable_season){
if(enable_greenhouse){ if(enable_greenhouse){
@@ -74,13 +75,13 @@ public class TimeCheck extends BukkitRunnable {
} }
} }
int nextStage = Integer.parseInt(cropNameList[2]) + 1; 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, () ->{ Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, () ->{
CustomBlock.remove(potLocation); CustomBlock.remove(potLocation);
CustomBlock.place(config.getString("config.pot"),potLocation); CustomBlock.place(config.getString("config.pot"),potLocation);
if(Math.random()< config.getDouble("config.grow-success-chance")){ if(Math.random()< config.getDouble("config.grow-success-chance")){
CustomBlock.remove(seedLocation); CustomBlock.remove(seedLocation);
CustomBlock.place(cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage,seedLocation); CustomBlock.place(namespace + ":" + cropNameList[0] + "_stage_" + nextStage,seedLocation);
} }
return null; return null;
}); });

View File

@@ -0,0 +1,4 @@
package net.momirealms.customcrops.Integrations;
public class PlotSquaredIntegrations {
}

View File

@@ -57,7 +57,7 @@ public class RightClickCustomBlock implements Listener {
String namespace = clickedCustomBlock.getNamespacedID().split(":")[0]; String namespace = clickedCustomBlock.getNamespacedID().split(":")[0];
String[] cropNameList = clickedCustomBlock.getNamespacedID().split(":")[1].split("_"); String[] cropNameList = clickedCustomBlock.getNamespacedID().split(":")[1].split("_");
int nextStage = Integer.parseInt(cropNameList[2]) + 1; 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 -> { clickedCustomBlock.getLoot().forEach(itemStack -> {
clickedBlockLocation.getWorld().dropItem(clickedBlockLocation.clone().add(0.5,0.2,0.5),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){ if (mainHandItem.getType() == Material.BONE_MEAL){
//植物是否具有stage属性 //植物是否具有stage属性
if (clickedCustomBlock.getNamespacedID().contains("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; int nextStage = Integer.parseInt(cropNameList[2]) + 1;
//植物是否存在下一个stage //植物是否存在下一个stage
if (CustomBlock.getInstance(cropNameList[0] + "_" +cropNameList[1] +"_" + nextStage) != null){ if (CustomBlock.getInstance(namespace+ ":" + cropNameList[0] + "_stage_" + nextStage) != null){
if(player.getGameMode() != GameMode.CREATIVE){ if(player.getGameMode() != GameMode.CREATIVE){
mainHandItem.setAmount(mainHandItem.getAmount() - 1); mainHandItem.setAmount(mainHandItem.getAmount() - 1);
} }
//骨粉的成功率 //骨粉的成功率
if (Math.random() < config.getDouble("config.bone-meal-chance")){ if (Math.random() < config.getDouble("config.bone-meal-chance")){
CustomBlock.remove(clickedBlockLocation); 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")); 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); world.spawnParticle(particleSuccess, clickedBlockLocation.clone().add(0.5, 0.1,0.5), 1 ,0,0,0,0);
//使用骨粉是否消耗水分 //使用骨粉是否消耗水分

View File

@@ -1,5 +1,5 @@
name: CustomCrops name: CustomCrops
version: '1.1' version: '1.2'
main: net.momirealms.customcrops.CustomCrops main: net.momirealms.customcrops.CustomCrops
api-version: 1.18 api-version: 1.18
depend: [ ItemsAdder , ProtocolLib ] depend: [ ItemsAdder , ProtocolLib ]