9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 16:39:36 +00:00
This commit is contained in:
Xiao-MoMi
2022-06-14 14:51:37 +08:00
parent a1f53c4ad7
commit bea7e823b6
9 changed files with 142 additions and 145 deletions

View File

@@ -25,11 +25,13 @@ public class BackUp {
BackUp.backUp(crop_data,cropBackUp); BackUp.backUp(crop_data,cropBackUp);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
CustomCrops.instance.getLogger().warning("crop-data.yml备份出错!");
} }
try { try {
BackUp.backUp(sprinkler_data,sprinklerBackUp); BackUp.backUp(sprinkler_data,sprinklerBackUp);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
CustomCrops.instance.getLogger().warning("sprinkler-data.yml备份出错!");
} }
} }

View File

@@ -163,35 +163,39 @@ public class ConfigManager {
YamlConfiguration cropConfig = getConfig("crops.yml"); YamlConfiguration cropConfig = getConfig("crops.yml");
Set<String> keys = cropConfig.getConfigurationSection("crops").getKeys(false); Set<String> keys = cropConfig.getConfigurationSection("crops").getKeys(false);
keys.forEach(key -> { keys.forEach(key -> {
double chance = cropConfig.getDouble("crops."+key+".grow-chance"); if(cropConfig.getConfigurationSection("crops."+key).contains("grow-chance")){
Crop crop = new Crop(key, chance); double chance = cropConfig.getDouble("crops."+key+".grow-chance");
if(cropConfig.getConfigurationSection("crops."+key).contains("return")){ Crop crop = new Crop(key, chance);
crop.setWillReturn(true); if(cropConfig.getConfigurationSection("crops."+key).contains("return")){
crop.setReturnStage(cropConfig.getString("crops."+key+".return")); crop.setWillReturn(true);
}else { crop.setReturnStage(cropConfig.getString("crops."+key+".return"));
crop.setWillReturn(false);
}
if(Config.season){
if(cropConfig.getConfigurationSection("crops."+key).contains("season")){
crop.setSeasons(StringUtils.split( cropConfig.getString("crops."+key+".season"), ","));
}else { }else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!在启用季节模式的情况下未设置农作物 &f"+ key +" &c的生长季节!", Bukkit.getConsoleSender()); crop.setWillReturn(false);
return;
} }
} if(Config.season){
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic")){ if(cropConfig.getConfigurationSection("crops."+key).contains("season")){
crop.setWillGiant(true); crop.setSeasons(StringUtils.split( cropConfig.getString("crops."+key+".season"), ","));
crop.setGiant(cropConfig.getString("crops."+key+".gigantic")); }else {
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic-chance")){ MessageManager.consoleMessage("&c[CustomCrops] 错误!在启用季节模式的情况下未设置农作物 &f"+ key +" &c的生长季节!", Bukkit.getConsoleSender());
crop.setGiantChance(cropConfig.getDouble("crops."+key+".gigantic-chance")); return;
}
}
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic")){
crop.setWillGiant(true);
crop.setGiant(cropConfig.getString("crops."+key+".gigantic"));
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic-chance")){
crop.setGiantChance(cropConfig.getDouble("crops."+key+".gigantic-chance"));
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的巨大化概率!", Bukkit.getConsoleSender());
return;
}
}else { }else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的巨大化概率!", Bukkit.getConsoleSender()); crop.setWillGiant(false);
return;
} }
CONFIG.put(key, crop);
}else { }else {
crop.setWillGiant(false); MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的生长概率!", Bukkit.getConsoleSender());
} }
CONFIG.put(key, crop);
}); });
if(keys.size() == CONFIG.size()){ if(keys.size() == CONFIG.size()){
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f成功载入 &a" + CONFIG.size() + " &f种农作物", Bukkit.getConsoleSender()); MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f成功载入 &a" + CONFIG.size() + " &f种农作物", Bukkit.getConsoleSender());

View File

@@ -51,7 +51,6 @@ public class CropManager {
FileConfiguration data; FileConfiguration data;
data = YamlConfiguration.loadConfiguration(file); data = YamlConfiguration.loadConfiguration(file);
//性能更高
Set<Map.Entry<Location, String>> en = CROPS.entrySet(); Set<Map.Entry<Location, String>> en = CROPS.entrySet();
for(Map.Entry<Location, String> entry : en){ for(Map.Entry<Location, String> entry : en){
Location loc = entry.getKey(); Location loc = entry.getKey();
@@ -65,8 +64,6 @@ public class CropManager {
CustomCrops.instance.getLogger().warning("农作物数据保存出错"); CustomCrops.instance.getLogger().warning("农作物数据保存出错");
} }
} }
/* /*
生长部分 生长部分
*/ */
@@ -78,7 +75,6 @@ public class CropManager {
File file = new File(CustomCrops.instance.getDataFolder(), "crop-data.yml"); File file = new File(CustomCrops.instance.getDataFolder(), "crop-data.yml");
FileConfiguration data = YamlConfiguration.loadConfiguration(file); FileConfiguration data = YamlConfiguration.loadConfiguration(file);
BukkitScheduler bukkitScheduler = Bukkit.getScheduler(); BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
Set<Map.Entry<Location, String>> en = CROPS.entrySet(); Set<Map.Entry<Location, String>> en = CROPS.entrySet();
for(Map.Entry<Location, String> entry : en){ for(Map.Entry<Location, String> entry : en){
Location key = entry.getKey(); Location key = entry.getKey();
@@ -86,7 +82,6 @@ public class CropManager {
} }
long finish1 = System.currentTimeMillis(); long finish1 = System.currentTimeMillis();
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7农作物数据更新耗时&a" + (finish1 - start1) + "&fms",Bukkit.getConsoleSender()); MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7农作物数据更新耗时&a" + (finish1 - start1) + "&fms",Bukkit.getConsoleSender());
/* /*
阶段2清理数据内无效的农作物并让有效农作物生长 阶段2清理数据内无效的农作物并让有效农作物生长
*/ */
@@ -97,10 +92,8 @@ public class CropManager {
String[] coordinate = StringUtils.split(key,","); String[] coordinate = StringUtils.split(key,",");
//先判断区块是否加载,未加载则不进行下一步计算 //先判断区块是否加载,未加载则不进行下一步计算
if (world.isChunkLoaded(Integer.parseInt(coordinate[0])/16, Integer.parseInt(coordinate[2])/16)){ if (world.isChunkLoaded(Integer.parseInt(coordinate[0])/16, Integer.parseInt(coordinate[2])/16)){
Location sLoc = new Location(world,Double.parseDouble(coordinate[0]),Double.parseDouble(coordinate[1]),Double.parseDouble(coordinate[2])); Location sLoc = new Location(world,Double.parseDouble(coordinate[0]),Double.parseDouble(coordinate[1]),Double.parseDouble(coordinate[2]));
CustomBlock seedBlock = CustomBlock.byAlreadyPlaced(sLoc.getBlock()); CustomBlock seedBlock = CustomBlock.byAlreadyPlaced(sLoc.getBlock());
if(seedBlock == null){ if(seedBlock == null){
CROPS.remove(sLoc); CROPS.remove(sLoc);
data.set(worldName+"."+coordinate[0]+","+coordinate[1]+","+coordinate[2], null); data.set(worldName+"."+coordinate[0]+","+coordinate[1]+","+coordinate[2], null);
@@ -116,22 +109,18 @@ public class CropManager {
return; return;
} }
if(namespacedID.contains("_stage_")){ if(namespacedID.contains("_stage_")){
Location potLoc = sLoc.clone().subtract(0,1,0); Location potLoc = sLoc.clone().subtract(0,1,0);
Block potBlock = potLoc.getBlock(); Block potBlock = potLoc.getBlock();
CustomBlock pot = CustomBlock.byAlreadyPlaced(potBlock); CustomBlock pot = CustomBlock.byAlreadyPlaced(potBlock);
if (pot != null){ if (pot != null){
String potName = pot.getNamespacedID(); String potName = pot.getNamespacedID();
/* /*
是湿润的种植盆吗 是湿润的种植盆吗
*/ */
if (potName.equalsIgnoreCase(ConfigManager.Config.watered_pot)){ if (potName.equalsIgnoreCase(ConfigManager.Config.watered_pot)){
String[] split = StringUtils.split(namespacedID,":"); String[] split = StringUtils.split(namespacedID,":");
String[] cropNameList = StringUtils.split(split[1],"_"); String[] cropNameList = StringUtils.split(split[1],"_");
Crop crop = ConfigManager.CONFIG.get(cropNameList[0]); Crop crop = ConfigManager.CONFIG.get(cropNameList[0]);
//季节判断 //季节判断
Label_out: Label_out:
if(ConfigManager.Config.season){ if(ConfigManager.Config.season){
@@ -246,7 +235,7 @@ public class CropManager {
data.save(file); data.save(file);
}catch (IOException e){ }catch (IOException e){
e.printStackTrace(); e.printStackTrace();
CustomCrops.instance.getLogger().warning("农作物缓存清理保存出错!"); CustomCrops.instance.getLogger().warning("crop-data.yml保存出错!");
} }
long finish3 = System.currentTimeMillis(); long finish3 = System.currentTimeMillis();
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7农作物数据保存耗时&a" + (finish3 - start3) + "&fms",Bukkit.getConsoleSender()); MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7农作物数据保存耗时&a" + (finish3 - start3) + "&fms",Bukkit.getConsoleSender());

View File

@@ -22,7 +22,7 @@ public class NextSeason {
ConfigManager.Config.current = nextSeason; ConfigManager.Config.current = nextSeason;
CustomCrops.instance.saveConfig(); CustomCrops.instance.saveConfig();
}else { }else {
CustomCrops.instance.getLogger().warning("季节配置文件出错!"); CustomCrops.instance.getLogger().warning("季节出错!");
} }
} }
} }

View File

@@ -129,7 +129,7 @@ public class SprinklerManager {
data.save(file); data.save(file);
}catch (IOException e){ }catch (IOException e){
e.printStackTrace(); e.printStackTrace();
CustomCrops.instance.getLogger().warning("洒水器数据保存出错!"); CustomCrops.instance.getLogger().warning("sprinkler-data.yml保存出错!");
} }
long finish3 = System.currentTimeMillis(); long finish3 = System.currentTimeMillis();
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7洒水器数据保存耗时&a" + (finish3-start3) + "&fms",Bukkit.getConsoleSender()); MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7洒水器数据保存耗时&a" + (finish3-start3) + "&fms",Bukkit.getConsoleSender());

View File

@@ -8,7 +8,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class ResidenceIntegrations { public class ResidenceIntegrations {
public static boolean checkResBuild(Location location, Player player){ public static boolean checkResBuild(Location location, Player player){
FlagPermissions.addFlag("build"); FlagPermissions.addFlag("build");
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location); ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);

View File

@@ -70,115 +70,115 @@ public class RightClickCustomBlock implements Listener {
右键的是特殊作物吗 右键的是特殊作物吗
*/ */
if (namespacedId.contains("stage")) { if (namespacedId.contains("stage")) {
//下方方块不是自定义方块则返回 //下方方块不是自定义方块则返回
Player player = event.getPlayer(); Player player = event.getPlayer();
Block blockUnder = clickedBlockLocation.clone().subtract(0,1,0).getBlock(); Block blockUnder = clickedBlockLocation.clone().subtract(0,1,0).getBlock();
CustomBlock cb = CustomBlock.byAlreadyPlaced(blockUnder); CustomBlock cb = CustomBlock.byAlreadyPlaced(blockUnder);
if (cb == null) return; if (cb == null) return;
//检测右键的方块下方是否为干燥的种植盆方块 //检测右键的方块下方是否为干燥的种植盆方块
if (cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)) { if (cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)) {
//获取手中的物品 //获取手中的物品
ItemStack mainHandItem = player.getInventory().getItemInMainHand(); ItemStack mainHandItem = player.getInventory().getItemInMainHand();
Location locUnder = clickedBlockLocation.clone().subtract(0,1,0); Location locUnder = clickedBlockLocation.clone().subtract(0,1,0);
//如果手中的是水桶,那么转干为湿 //如果手中的是水桶,那么转干为湿
if (mainHandItem.getType() == Material.WATER_BUCKET) { if (mainHandItem.getType() == Material.WATER_BUCKET) {
//扣除水桶 //扣除水桶
if (player.getGameMode() != GameMode.CREATIVE) { if (player.getGameMode() != GameMode.CREATIVE) {
mainHandItem.setAmount(mainHandItem.getAmount() - 1); mainHandItem.setAmount(mainHandItem.getAmount() - 1);
player.getInventory().addItem(new ItemStack(Material.BUCKET)); player.getInventory().addItem(new ItemStack(Material.BUCKET));
}
CustomBlock.remove(locUnder);
CustomBlock.place(ConfigManager.Config.watered_pot, locUnder);
} else if (mainHandItem.getType() == Material.WOODEN_SWORD) {
waterPot(mainHandItem, player, locUnder);
} }
CustomBlock.remove(locUnder);
CustomBlock.place(ConfigManager.Config.watered_pot, locUnder);
} else if (mainHandItem.getType() == Material.WOODEN_SWORD) {
waterPot(mainHandItem, player, locUnder);
} }
//检测右键的方块下方是否为湿润的种植盆方块 }
else if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.watered_pot)){ //检测右键的方块下方是否为湿润的种植盆方块
//获取手中的物品 else if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.watered_pot)){
ItemStack mainHandItem = player.getInventory().getItemInMainHand(); //获取手中的物品
//如果是骨粉 ItemStack mainHandItem = player.getInventory().getItemInMainHand();
if (mainHandItem.getType() == Material.BONE_MEAL){ //如果是骨粉
//植物是否具有stage属性 if (mainHandItem.getType() == Material.BONE_MEAL){
if (namespacedId.contains("_stage_")){ //植物是否具有stage属性
String[] split = StringUtils.split(namespacedId,":"); if (namespacedId.contains("_stage_")){
String[] cropNameList = StringUtils.split(split[1],"_"); String[] split = StringUtils.split(namespacedId,":");
//下一生长阶段 String[] cropNameList = StringUtils.split(split[1],"_");
int nextStage = Integer.parseInt(cropNameList[2]) + 1; //下一生长阶段
//植物是否存在下一个stage int nextStage = Integer.parseInt(cropNameList[2]) + 1;
if (CustomBlock.getInstance(split[0]+ ":" + cropNameList[0] + "_stage_" + nextStage) != null){ //植物是否存在下一个stage
if(player.getGameMode() != GameMode.CREATIVE){ if (CustomBlock.getInstance(split[0]+ ":" + cropNameList[0] + "_stage_" + nextStage) != null){
mainHandItem.setAmount(mainHandItem.getAmount() - 1); if(player.getGameMode() != GameMode.CREATIVE){
} mainHandItem.setAmount(mainHandItem.getAmount() - 1);
World world = player.getWorld(); }
//骨粉的成功率 World world = player.getWorld();
if (Math.random() < ConfigManager.Config.bone_chance){ //骨粉的成功率
CustomBlock.remove(clickedBlockLocation); if (Math.random() < ConfigManager.Config.bone_chance){
CustomBlock.place(split[0] + ":" + cropNameList[0] + "_stage_" + nextStage,clickedBlockLocation); CustomBlock.remove(clickedBlockLocation);
Particle particleSuccess = Particle.valueOf(ConfigManager.Config.success); CustomBlock.place(split[0] + ":" + cropNameList[0] + "_stage_" + nextStage,clickedBlockLocation);
world.spawnParticle(particleSuccess, clickedBlockLocation.clone().add(0.5, 0.1,0.5), 1 ,0,0,0,0); Particle particleSuccess = Particle.valueOf(ConfigManager.Config.success);
//使用骨粉是否消耗水分 world.spawnParticle(particleSuccess, clickedBlockLocation.clone().add(0.5, 0.1,0.5), 1 ,0,0,0,0);
if(ConfigManager.Config.need_water){ //使用骨粉是否消耗水分
CustomBlock.remove(clickedBlockLocation.clone().subtract(0,1,0)); if(ConfigManager.Config.need_water){
CustomBlock.place(ConfigManager.Config.pot, clickedBlockLocation.clone().subtract(0,1,0)); CustomBlock.remove(clickedBlockLocation.clone().subtract(0,1,0));
} CustomBlock.place(ConfigManager.Config.pot, clickedBlockLocation.clone().subtract(0,1,0));
}else {
Particle particleFailure = Particle.valueOf(ConfigManager.Config.failure);
world.spawnParticle(particleFailure, clickedBlockLocation.clone().add(0.5, 0.1,0.5), 1 ,0,0,0,0);
} }
}else {
Particle particleFailure = Particle.valueOf(ConfigManager.Config.failure);
world.spawnParticle(particleFailure, clickedBlockLocation.clone().add(0.5, 0.1,0.5), 1 ,0,0,0,0);
} }
} }
} }
} }
}
} }
/* /*
右键的是种植盆吗 右键的是种植盆吗
*/ */
else if (event.getBlockFace() == BlockFace.UP){ else if (event.getBlockFace() == BlockFace.UP){
//获取手中的物品 //获取手中的物品
ItemStack item = event.getItem(); ItemStack item = event.getItem();
Player player = event.getPlayer(); Player player = event.getPlayer();
//检测右键的方块是否为干燥的种植盆方块 //检测右键的方块是否为干燥的种植盆方块
if (namespacedId.equalsIgnoreCase(ConfigManager.Config.pot)){ if (namespacedId.equalsIgnoreCase(ConfigManager.Config.pot)){
//如果手中的是水桶,那么转干为湿 //如果手中的是水桶,那么转干为湿
if (item.getType() == Material.WATER_BUCKET){ if (item.getType() == Material.WATER_BUCKET){
//扣除水桶 //扣除水桶
if(player.getGameMode() != GameMode.CREATIVE){ if(player.getGameMode() != GameMode.CREATIVE){
item.setAmount(item.getAmount() - 1); item.setAmount(item.getAmount() - 1);
player.getInventory().addItem(new ItemStack(Material.BUCKET)); player.getInventory().addItem(new ItemStack(Material.BUCKET));
}
CustomBlock.remove(clickedBlockLocation);
CustomBlock.place(ConfigManager.Config.watered_pot,clickedBlockLocation);
return;
} }
CustomStack customStack = CustomStack.byItemStack(item); CustomBlock.remove(clickedBlockLocation);
if (customStack != null){ CustomBlock.place(ConfigManager.Config.watered_pot,clickedBlockLocation);
String namespacedID = customStack.getNamespacedID(); return;
if (namespacedID.endsWith("_seeds")){ }
if(tryPlantSeed(clickedBlockLocation, namespacedID, player)){ CustomStack customStack = CustomStack.byItemStack(item);
if(player.getGameMode() != GameMode.CREATIVE){ if (customStack != null){
item.setAmount(item.getAmount() -1); String namespacedID = customStack.getNamespacedID();
} if (namespacedID.endsWith("_seeds")){
if(tryPlantSeed(clickedBlockLocation, namespacedID, player)){
if(player.getGameMode() != GameMode.CREATIVE){
item.setAmount(item.getAmount() -1);
} }
}else {
waterPot(item, player, clickedBlockLocation);
} }
}else {
waterPot(item, player, clickedBlockLocation);
} }
} }
//检测右键的方块是否为湿润的种植盆方块 }
else if(namespacedId.equalsIgnoreCase(ConfigManager.Config.watered_pot)){ //检测右键的方块是否为湿润的种植盆方块
CustomStack customStack = CustomStack.byItemStack(item); else if(namespacedId.equalsIgnoreCase(ConfigManager.Config.watered_pot)){
if (customStack != null){ CustomStack customStack = CustomStack.byItemStack(item);
String namespacedID = customStack.getNamespacedID(); if (customStack != null){
if (namespacedID.endsWith("_seeds")){ String namespacedID = customStack.getNamespacedID();
if(tryPlantSeed(clickedBlockLocation, namespacedID, player)){ if (namespacedID.endsWith("_seeds")){
if(player.getGameMode() != GameMode.CREATIVE){ if(tryPlantSeed(clickedBlockLocation, namespacedID, player)){
item.setAmount(item.getAmount() -1); if(player.getGameMode() != GameMode.CREATIVE){
} item.setAmount(item.getAmount() -1);
} }
} }
} }
} }
}
} }
} }
} }
@@ -280,7 +280,6 @@ public class RightClickCustomBlock implements Listener {
CustomBlock cb = CustomBlock.byAlreadyPlaced(tempLoc.getBlock()); CustomBlock cb = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
if(cb != null){ if(cb != null){
if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)){ if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)){
//同步替换方块
CustomBlock.remove(tempLoc); CustomBlock.remove(tempLoc);
CustomBlock.place(ConfigManager.Config.watered_pot,tempLoc); CustomBlock.place(ConfigManager.Config.watered_pot,tempLoc);
} }
@@ -299,7 +298,6 @@ public class RightClickCustomBlock implements Listener {
CustomBlock cb = CustomBlock.byAlreadyPlaced(tempLoc.getBlock()); CustomBlock cb = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
if(cb != null){ if(cb != null){
if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)){ if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)){
//同步替换方块
CustomBlock.remove(tempLoc); CustomBlock.remove(tempLoc);
CustomBlock.place(ConfigManager.Config.watered_pot,tempLoc); CustomBlock.place(ConfigManager.Config.watered_pot,tempLoc);
} }

View File

@@ -3,6 +3,7 @@ package net.momirealms.customcrops.timer;
import net.momirealms.customcrops.datamanager.ConfigManager; import net.momirealms.customcrops.datamanager.ConfigManager;
import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.CustomCrops;
import net.momirealms.customcrops.datamanager.CropManager; import net.momirealms.customcrops.datamanager.CropManager;
import net.momirealms.customcrops.datamanager.MessageManager;
import net.momirealms.customcrops.datamanager.SprinklerManager; import net.momirealms.customcrops.datamanager.SprinklerManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@@ -14,17 +15,21 @@ public class TimeCheck extends BukkitRunnable {
public void run() { public void run() {
ConfigManager.Config.worlds.forEach(world ->{ ConfigManager.Config.worlds.forEach(world ->{
BukkitScheduler bukkitScheduler = Bukkit.getScheduler(); BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
long time = Bukkit.getWorld(world).getTime(); if(Bukkit.getWorld(world) != null){
ConfigManager.Config.cropGrowTimeList.forEach(cropGrowTime -> { long time = Bukkit.getWorld(world).getTime();
if(time == cropGrowTime){ ConfigManager.Config.cropGrowTimeList.forEach(cropGrowTime -> {
bukkitScheduler.runTaskAsynchronously(CustomCrops.instance, () -> CropManager.CropGrow(world)); if(time == cropGrowTime){
} bukkitScheduler.runTaskAsynchronously(CustomCrops.instance, () -> CropManager.CropGrow(world));
}); }
ConfigManager.Config.sprinklerWorkTimeList.forEach(sprinklerTime -> { });
if(time == sprinklerTime){ ConfigManager.Config.sprinklerWorkTimeList.forEach(sprinklerTime -> {
bukkitScheduler.runTaskAsynchronously(CustomCrops.instance, () -> SprinklerManager.SprinklerWork(world)); if(time == sprinklerTime){
} bukkitScheduler.runTaskAsynchronously(CustomCrops.instance, () -> SprinklerManager.SprinklerWork(world));
}); }
});
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误! 白名单世界 "+ world +" 不存在!",Bukkit.getConsoleSender());
}
}); });
} }
} }

View File

@@ -75,8 +75,8 @@ config:
#每个区块最大农作物数量和洒水器数量 #每个区块最大农作物数量和洒水器数量
#是否启用限制 #是否启用限制
enable-limit: true enable-limit: true
max-crops: 32 max-crops: 64
max-sprinklers: 4 max-sprinklers: 8
#插件兼容 #插件兼容
@@ -94,11 +94,11 @@ config:
messages: messages:
prefix: '&#ccfbff-#ef96c5&[CustomCrops] ' prefix: '&#ccfbff-#ef96c5&[CustomCrops] '
not-a-good-place: '&f这个地方太高/太低了,请换个地方试试吧!' not-a-good-place: '&f这个地方太高/太低了,请换个地方试试吧!'
reload: '&f插件已重载' reload: '&f插件已重载.'
force-save: '&f成功强制保存缓存信息' force-save: '&f成功强制保存缓存信息!'
no-such-seed: '&f此种子未在配置文件中配置!' no-such-seed: '&f此种子未在配置文件中配置!'
wrong-season: '&f这个季节不适合这种农作物生长!' wrong-season: '&f这个季节不适合这种农作物生长!'
season-set: '&f成功设置季节为{Season}' season-set: '&f成功设置季节为{Season}.'
nextseason: '&f已切换到下一季节' nextseason: '&f已切换到下一季节'
season-disabled: '&f季节系统未启用.' season-disabled: '&f季节系统未启用.'
force-grow: '&f已强制生长!' force-grow: '&f已强制生长!'
@@ -111,4 +111,4 @@ messages:
summer: '&f夏' summer: '&f夏'
autumn: '&f秋' autumn: '&f秋'
winter: '&f冬' winter: '&f冬'
noperm: '&f权限不足' noperm: '&f权限不足.'