9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-28 03:19:15 +00:00
This commit is contained in:
Xiao-MoMi
2022-11-20 13:59:41 +08:00
parent fdee051c73
commit d0e0d46a28
3 changed files with 11 additions and 12 deletions

View File

@@ -315,13 +315,15 @@ public abstract class HandlerP extends Function {
}
public boolean hasNextStage(String id) {
int nextStage = Integer.parseInt(id.substring(id.length()-1)) + 1;
return customInterface.doesExist(StringUtils.chop(id) + nextStage);
String[] crop = StringUtils.split(id,"_");
int nextStage = Integer.parseInt(crop[2]) + 1;
return customInterface.doesExist(crop[0] + "_" + crop[1] + "_" + nextStage);
}
public String getNextStage(String id) {
int nextStage = Integer.parseInt(id.substring(id.length()-1)) + 1;
return StringUtils.chop(id) + nextStage;
String[] crop = StringUtils.split(id,"_");
int nextStage = Integer.parseInt(crop[2]) + 1;
return crop[0] + "_" + crop[1] + "_" + nextStage;
}
public boolean fillWaterCan(String id, NBTItem nbtItem, ItemStack itemStack, Player player) {

View File

@@ -78,7 +78,7 @@ public class ItemsAdderWireCropImpl implements CropModeInterface {
Fertilizer fertilizer = cropManager.getFertilizer(potLoc);
boolean certainGrow = potID.equals(BasicItemConfig.wetPot);
int nextStage = Integer.parseInt(cropNameList[2]) + 1;
String temp = StringUtils.chop(blockID);
String temp = blockID.substring(blockID.length() - String.valueOf(nextStage).length());
if (customInterface.doesExist(temp + nextStage)) {
if (MainConfig.enableCrow && cropManager.crowJudge(location)) return true;

View File

@@ -54,18 +54,15 @@ public class OraxenWireCropImpl implements CropModeInterface {
if (crop == null) return true;
if (MainConfig.needSkyLight && location.getBlock().getLightFromSky() < MainConfig.skyLightLevel) {
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
customInterface.placeWire(location, BasicItemConfig.deadCrop);
});
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> customInterface.placeWire(location, BasicItemConfig.deadCrop));
return true;
}
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
customInterface.placeWire(location, BasicItemConfig.deadCrop);
});
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> customInterface.placeWire(location, BasicItemConfig.deadCrop));
return true;
}
Location potLoc = location.clone().subtract(0,1,0);
String potID = customInterface.getBlockID(potLoc);
if (potID == null) return true;
@@ -73,7 +70,7 @@ public class OraxenWireCropImpl implements CropModeInterface {
Fertilizer fertilizer = cropManager.getFertilizer(potLoc);
boolean certainGrow = potID.equals(BasicItemConfig.wetPot);
int nextStage = Integer.parseInt(cropNameList[2]) + 1;
String temp = StringUtils.chop(blockID);
String temp = cropNameList[0] + "_" + cropNameList[1] + "_";
if (customInterface.doesExist(temp + nextStage)) {
if (MainConfig.enableCrow && cropManager.crowJudge(location)) return true;
if (fertilizer instanceof SpeedGrow speedGrow && Math.random() < speedGrow.getChance()) {