mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
1.4.4
This commit is contained in:
@@ -25,11 +25,13 @@ public class BackUp {
|
||||
BackUp.backUp(crop_data,cropBackUp);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
CustomCrops.instance.getLogger().warning("crop-data.yml备份出错!");
|
||||
}
|
||||
try {
|
||||
BackUp.backUp(sprinkler_data,sprinklerBackUp);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
CustomCrops.instance.getLogger().warning("sprinkler-data.yml备份出错!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ public class ConfigManager {
|
||||
YamlConfiguration cropConfig = getConfig("crops.yml");
|
||||
Set<String> keys = cropConfig.getConfigurationSection("crops").getKeys(false);
|
||||
keys.forEach(key -> {
|
||||
if(cropConfig.getConfigurationSection("crops."+key).contains("grow-chance")){
|
||||
double chance = cropConfig.getDouble("crops."+key+".grow-chance");
|
||||
Crop crop = new Crop(key, chance);
|
||||
if(cropConfig.getConfigurationSection("crops."+key).contains("return")){
|
||||
@@ -192,6 +193,9 @@ public class ConfigManager {
|
||||
crop.setWillGiant(false);
|
||||
}
|
||||
CONFIG.put(key, crop);
|
||||
}else {
|
||||
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的生长概率!", Bukkit.getConsoleSender());
|
||||
}
|
||||
});
|
||||
if(keys.size() == CONFIG.size()){
|
||||
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f成功载入 &a" + CONFIG.size() + " &f种农作物", Bukkit.getConsoleSender());
|
||||
|
||||
@@ -51,7 +51,6 @@ public class CropManager {
|
||||
FileConfiguration data;
|
||||
data = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
//性能更高
|
||||
Set<Map.Entry<Location, String>> en = CROPS.entrySet();
|
||||
for(Map.Entry<Location, String> entry : en){
|
||||
Location loc = entry.getKey();
|
||||
@@ -65,8 +64,6 @@ public class CropManager {
|
||||
CustomCrops.instance.getLogger().warning("农作物数据保存出错");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
生长部分
|
||||
*/
|
||||
@@ -78,7 +75,6 @@ public class CropManager {
|
||||
File file = new File(CustomCrops.instance.getDataFolder(), "crop-data.yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(file);
|
||||
BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
|
||||
|
||||
Set<Map.Entry<Location, String>> en = CROPS.entrySet();
|
||||
for(Map.Entry<Location, String> entry : en){
|
||||
Location key = entry.getKey();
|
||||
@@ -86,7 +82,6 @@ public class CropManager {
|
||||
}
|
||||
long finish1 = System.currentTimeMillis();
|
||||
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7农作物数据更新耗时&a" + (finish1 - start1) + "&fms",Bukkit.getConsoleSender());
|
||||
|
||||
/*
|
||||
阶段2:清理数据内无效的农作物并让有效农作物生长
|
||||
*/
|
||||
@@ -97,10 +92,8 @@ public class CropManager {
|
||||
String[] coordinate = StringUtils.split(key,",");
|
||||
//先判断区块是否加载,未加载则不进行下一步计算
|
||||
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]));
|
||||
CustomBlock seedBlock = CustomBlock.byAlreadyPlaced(sLoc.getBlock());
|
||||
|
||||
if(seedBlock == null){
|
||||
CROPS.remove(sLoc);
|
||||
data.set(worldName+"."+coordinate[0]+","+coordinate[1]+","+coordinate[2], null);
|
||||
@@ -116,22 +109,18 @@ public class CropManager {
|
||||
return;
|
||||
}
|
||||
if(namespacedID.contains("_stage_")){
|
||||
|
||||
Location potLoc = sLoc.clone().subtract(0,1,0);
|
||||
Block potBlock = potLoc.getBlock();
|
||||
CustomBlock pot = CustomBlock.byAlreadyPlaced(potBlock);
|
||||
|
||||
if (pot != null){
|
||||
String potName = pot.getNamespacedID();
|
||||
/*
|
||||
是湿润的种植盆吗
|
||||
*/
|
||||
if (potName.equalsIgnoreCase(ConfigManager.Config.watered_pot)){
|
||||
|
||||
String[] split = StringUtils.split(namespacedID,":");
|
||||
String[] cropNameList = StringUtils.split(split[1],"_");
|
||||
Crop crop = ConfigManager.CONFIG.get(cropNameList[0]);
|
||||
|
||||
//季节判断
|
||||
Label_out:
|
||||
if(ConfigManager.Config.season){
|
||||
@@ -246,7 +235,7 @@ public class CropManager {
|
||||
data.save(file);
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
CustomCrops.instance.getLogger().warning("农作物缓存清理保存出错!");
|
||||
CustomCrops.instance.getLogger().warning("crop-data.yml保存出错!");
|
||||
}
|
||||
long finish3 = System.currentTimeMillis();
|
||||
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7农作物数据保存耗时&a" + (finish3 - start3) + "&fms",Bukkit.getConsoleSender());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class NextSeason {
|
||||
ConfigManager.Config.current = nextSeason;
|
||||
CustomCrops.instance.saveConfig();
|
||||
}else {
|
||||
CustomCrops.instance.getLogger().warning("季节配置文件出错!");
|
||||
CustomCrops.instance.getLogger().warning("季节出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class SprinklerManager {
|
||||
data.save(file);
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
CustomCrops.instance.getLogger().warning("洒水器数据保存出错!");
|
||||
CustomCrops.instance.getLogger().warning("sprinkler-data.yml保存出错!");
|
||||
}
|
||||
long finish3 = System.currentTimeMillis();
|
||||
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &7洒水器数据保存耗时&a" + (finish3-start3) + "&fms",Bukkit.getConsoleSender());
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ResidenceIntegrations {
|
||||
|
||||
public static boolean checkResBuild(Location location, Player player){
|
||||
FlagPermissions.addFlag("build");
|
||||
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||
|
||||
@@ -280,7 +280,6 @@ public class RightClickCustomBlock implements Listener {
|
||||
CustomBlock cb = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
|
||||
if(cb != null){
|
||||
if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)){
|
||||
//同步替换方块
|
||||
CustomBlock.remove(tempLoc);
|
||||
CustomBlock.place(ConfigManager.Config.watered_pot,tempLoc);
|
||||
}
|
||||
@@ -299,7 +298,6 @@ public class RightClickCustomBlock implements Listener {
|
||||
CustomBlock cb = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
|
||||
if(cb != null){
|
||||
if(cb.getNamespacedID().equalsIgnoreCase(ConfigManager.Config.pot)){
|
||||
//同步替换方块
|
||||
CustomBlock.remove(tempLoc);
|
||||
CustomBlock.place(ConfigManager.Config.watered_pot,tempLoc);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.momirealms.customcrops.timer;
|
||||
import net.momirealms.customcrops.datamanager.ConfigManager;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.MessageManager;
|
||||
import net.momirealms.customcrops.datamanager.SprinklerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -14,6 +15,7 @@ public class TimeCheck extends BukkitRunnable {
|
||||
public void run() {
|
||||
ConfigManager.Config.worlds.forEach(world ->{
|
||||
BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
|
||||
if(Bukkit.getWorld(world) != null){
|
||||
long time = Bukkit.getWorld(world).getTime();
|
||||
ConfigManager.Config.cropGrowTimeList.forEach(cropGrowTime -> {
|
||||
if(time == cropGrowTime){
|
||||
@@ -25,6 +27,9 @@ public class TimeCheck extends BukkitRunnable {
|
||||
bukkitScheduler.runTaskAsynchronously(CustomCrops.instance, () -> SprinklerManager.SprinklerWork(world));
|
||||
}
|
||||
});
|
||||
}else {
|
||||
MessageManager.consoleMessage("&c[CustomCrops] 错误! 白名单世界 "+ world +" 不存在!",Bukkit.getConsoleSender());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,8 @@ config:
|
||||
#每个区块最大农作物数量和洒水器数量
|
||||
#是否启用限制
|
||||
enable-limit: true
|
||||
max-crops: 32
|
||||
max-sprinklers: 4
|
||||
max-crops: 64
|
||||
max-sprinklers: 8
|
||||
|
||||
|
||||
#插件兼容
|
||||
@@ -94,11 +94,11 @@ config:
|
||||
messages:
|
||||
prefix: '&#ccfbff-#ef96c5&[CustomCrops] '
|
||||
not-a-good-place: '&f这个地方太高/太低了,请换个地方试试吧!'
|
||||
reload: '&f插件已重载'
|
||||
force-save: '&f成功强制保存缓存信息'
|
||||
reload: '&f插件已重载.'
|
||||
force-save: '&f成功强制保存缓存信息!'
|
||||
no-such-seed: '&f此种子未在配置文件中配置!'
|
||||
wrong-season: '&f这个季节不适合这种农作物生长!'
|
||||
season-set: '&f成功设置季节为{Season}'
|
||||
season-set: '&f成功设置季节为{Season}.'
|
||||
nextseason: '&f已切换到下一季节!'
|
||||
season-disabled: '&f季节系统未启用.'
|
||||
force-grow: '&f已强制生长!'
|
||||
@@ -111,4 +111,4 @@ messages:
|
||||
summer: '&f夏'
|
||||
autumn: '&f秋'
|
||||
winter: '&f冬'
|
||||
noperm: '&f权限不足'
|
||||
noperm: '&f权限不足.'
|
||||
|
||||
Reference in New Issue
Block a user