diff --git a/src/main/java/net/momirealms/customcrops/ConfigReader.java b/src/main/java/net/momirealms/customcrops/ConfigReader.java index a1105a2..85479a6 100644 --- a/src/main/java/net/momirealms/customcrops/ConfigReader.java +++ b/src/main/java/net/momirealms/customcrops/ConfigReader.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops; import net.kyori.adventure.key.Key; @@ -51,6 +68,7 @@ public class ConfigReader { public static List worldNames; public static List cropGrowTimeList; public static List integration; + public static String referenceWorld; public static boolean asyncCheck; public static boolean enableLimit; public static int cropLimit; @@ -124,17 +142,26 @@ public class ConfigReader { waterCanRefill = config.getInt("config.water-can-refill",1); canAddWater = config.getBoolean("config.water-can-add-water-to-sprinkler",true); - //农作物生长的白名单世界 - worlds = new ArrayList<>(); - worldNames = config.getStringList("config.whitelist-worlds"); - worldNames.forEach(worldName -> { - World world = Bukkit.getWorld(worldName); - if (world == null){ - AdventureManager.consoleMessage("[CustomCrops] 世界" + worldName + "" + "不存在"); + if (allWorld){ + if (config.getStringList("config.whitelist-worlds").size() > 1){ + referenceWorld = config.getStringList("config.whitelist-worlds").get(0); + AdventureManager.consoleMessage("[CustomCrops] 全世界生长模式下只能填写一个白名单世界!"); }else { - worlds.add(world); + referenceWorld = config.getStringList("config.whitelist-worlds").get(0); } - }); + }else { + //农作物生长的白名单世界 + worlds = new ArrayList<>(); + worldNames = config.getStringList("config.whitelist-worlds"); + worldNames.forEach(worldName -> { + World world = Bukkit.getWorld(worldName); + if (world == null){ + AdventureManager.consoleMessage("[CustomCrops] 世界" + worldName + "" + "不存在"); + }else { + worlds.add(world); + } + }); + } //处理插件兼容性 integration = new ArrayList<>(); diff --git a/src/main/java/net/momirealms/customcrops/CustomCrops.java b/src/main/java/net/momirealms/customcrops/CustomCrops.java index 26a6dd7..bff2f6a 100644 --- a/src/main/java/net/momirealms/customcrops/CustomCrops.java +++ b/src/main/java/net/momirealms/customcrops/CustomCrops.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops; import net.kyori.adventure.platform.bukkit.BukkitAudiences; @@ -100,7 +117,9 @@ public final class CustomCrops extends JavaPlugin { public void onDisable() { //保存数据 + this.cropManager.cleanData(); this.cropManager.saveData(); + this.sprinklerManager.cleanData(); this.sprinklerManager.saveData(); this.potManager.saveData(); if (ConfigReader.Season.enable && !ConfigReader.Season.seasonChange){ @@ -113,8 +132,8 @@ public final class CustomCrops extends JavaPlugin { getLogger().info("备份已完成..."); //清除悬浮展示实体 - HoloUtil.cache.keySet().forEach(player -> { - HoloUtil.cache.get(player).remove(); + HoloUtil.cache.keySet().forEach(location -> { + HoloUtil.cache.get(location).remove(); }); //关闭计时器 diff --git a/src/main/java/net/momirealms/customcrops/commands/Completer.java b/src/main/java/net/momirealms/customcrops/commands/Completer.java index 3b0359c..d25037c 100644 --- a/src/main/java/net/momirealms/customcrops/commands/Completer.java +++ b/src/main/java/net/momirealms/customcrops/commands/Completer.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.commands; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/commands/Executor.java b/src/main/java/net/momirealms/customcrops/commands/Executor.java index 1a1cc57..1e3f5bf 100644 --- a/src/main/java/net/momirealms/customcrops/commands/Executor.java +++ b/src/main/java/net/momirealms/customcrops/commands/Executor.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.commands; import net.momirealms.customcrops.utils.AdventureManager; diff --git a/src/main/java/net/momirealms/customcrops/datamanager/CropManager.java b/src/main/java/net/momirealms/customcrops/datamanager/CropManager.java index 3a77f81..30795fa 100644 --- a/src/main/java/net/momirealms/customcrops/datamanager/CropManager.java +++ b/src/main/java/net/momirealms/customcrops/datamanager/CropManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.datamanager; import dev.lone.itemsadder.api.CustomBlock; @@ -9,6 +26,7 @@ import net.momirealms.customcrops.fertilizer.Fertilizer; import net.momirealms.customcrops.fertilizer.RetainingSoil; import net.momirealms.customcrops.fertilizer.SpeedGrow; import net.momirealms.customcrops.utils.CropInstance; +import net.momirealms.customcrops.utils.SimpleLocation; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -137,7 +155,7 @@ public class CropManager { } int nextStage = Integer.parseInt(cropNameList[2]) + 1; if (CustomBlock.getInstance(StringUtils.chop(namespacedID) + nextStage) != null) { - Fertilizer fertilizer = PotManager.Cache.get(potLocation); + Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(potLocation)); if (fertilizer != null){ int times = fertilizer.getTimes(); if (times > 0){ @@ -158,10 +176,10 @@ public class CropManager { addStage(potLocation, seedLocation, namespacedID, nextStage, random); }else { AdventureManager.consoleMessage("[CustomCrops] 发现未知类型肥料,已自动清除错误数据!"); - PotManager.Cache.remove(potLocation); + PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation)); } }else { - PotManager.Cache.remove(potLocation); + PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation)); } } else { @@ -265,7 +283,7 @@ public class CropManager { } int nextStage = Integer.parseInt(cropNameList[2]) + 1; if (CustomBlock.getInstance(StringUtils.chop(namespacedID) + nextStage) != null) { - Fertilizer fertilizer = PotManager.Cache.get(potLocation); + Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(potLocation)); if (fertilizer != null){ int times = fertilizer.getTimes(); if (times > 0){ @@ -286,10 +304,10 @@ public class CropManager { addStage(potLocation, seedLocation, namespacedID, nextStage, random); }else { AdventureManager.consoleMessage("[CustomCrops] 发现未知类型肥料,已自动清除错误数据!"); - PotManager.Cache.remove(potLocation); + PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation)); } }else { - PotManager.Cache.remove(potLocation); + PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation)); } } else { @@ -350,9 +368,17 @@ public class CropManager { } } } - for(String season : seasons){ - if (season.equals(SeasonManager.SEASON.get(worldName))) { - return false; + if (!ConfigReader.Config.allWorld){ + for(String season : seasons){ + if (season.equals(SeasonManager.SEASON.get(worldName))) { + return false; + } + } + }else { + for(String season : seasons){ + if (season.equals(SeasonManager.SEASON.get(ConfigReader.Config.referenceWorld))) { + return false; + } } } return true; diff --git a/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java b/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java index 44e7124..3de2582 100644 --- a/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java +++ b/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.datamanager; import net.momirealms.customcrops.utils.AdventureManager; @@ -7,6 +24,7 @@ import net.momirealms.customcrops.fertilizer.Fertilizer; import net.momirealms.customcrops.fertilizer.QualityCrop; import net.momirealms.customcrops.fertilizer.RetainingSoil; import net.momirealms.customcrops.fertilizer.SpeedGrow; +import net.momirealms.customcrops.utils.SimpleLocation; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -20,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap; public class PotManager { private CustomCrops plugin; - public static ConcurrentHashMap Cache = new ConcurrentHashMap<>(); + public static ConcurrentHashMap Cache = new ConcurrentHashMap<>(); public PotManager(CustomCrops plugin){ this.plugin = plugin; @@ -39,36 +57,38 @@ public class PotManager { } YamlConfiguration data = YamlConfiguration.loadConfiguration(file); data.getKeys(false).forEach(worldName -> { - if (ConfigReader.Config.worldNames.contains(worldName)){ - data.getConfigurationSection(worldName).getValues(false).forEach((key, value) ->{ - String[] split = StringUtils.split(key, ","); - if (value instanceof MemorySection map){ - String name = (String) map.get("fertilizer"); - Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(name); - if (fertilizer == null) return; - if (fertilizer instanceof SpeedGrow speedGrow){ - Cache.put(new Location(Bukkit.getWorld(worldName), Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2])), new SpeedGrow(name, (int) map.get("times"), speedGrow.getChance(), speedGrow.isBefore())); - }else if (fertilizer instanceof QualityCrop qualityCrop){ - Cache.put(new Location(Bukkit.getWorld(worldName), Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2])), new QualityCrop(name, (int) map.get("times"), qualityCrop.getChance(), qualityCrop.isBefore())); - }else if (fertilizer instanceof RetainingSoil retainingSoil){ - Cache.put(new Location(Bukkit.getWorld(worldName), Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2])), new RetainingSoil(name, (int) map.get("times"), retainingSoil.getChance(), retainingSoil.isBefore())); - }else { - AdventureManager.consoleMessage("[CustomCrops] 未知肥料类型错误!"); - } + data.getConfigurationSection(worldName).getValues(false).forEach((key, value) ->{ + String[] split = StringUtils.split(key, ","); + if (value instanceof MemorySection map){ + String name = (String) map.get("fertilizer"); + Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(name); + if (fertilizer == null) return; + if (fertilizer instanceof SpeedGrow speedGrow){ + Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), new SpeedGrow(name, (int) map.get("times"), speedGrow.getChance(), speedGrow.isBefore())); + //Cache.put(new Location(Bukkit.getWorld(worldName), Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2])), new SpeedGrow(name, (int) map.get("times"), speedGrow.getChance(), speedGrow.isBefore())); + }else if (fertilizer instanceof QualityCrop qualityCrop){ + Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), new QualityCrop(name, (int) map.get("times"), qualityCrop.getChance(), qualityCrop.isBefore())); + //Cache.put(new Location(Bukkit.getWorld(worldName), Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2])), new QualityCrop(name, (int) map.get("times"), qualityCrop.getChance(), qualityCrop.isBefore())); + }else if (fertilizer instanceof RetainingSoil retainingSoil){ + Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), new RetainingSoil(name, (int) map.get("times"), retainingSoil.getChance(), retainingSoil.isBefore())); + //Cache.put(new Location(Bukkit.getWorld(worldName), Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2])), new RetainingSoil(name, (int) map.get("times"), retainingSoil.getChance(), retainingSoil.isBefore())); + }else { + AdventureManager.consoleMessage("[CustomCrops] 未知肥料类型错误!"); } - }); - } + } + }); }); } public void saveData(){ File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "pot.yml"); + System.out.println(Cache.size()); YamlConfiguration data = new YamlConfiguration(); Cache.forEach(((location, fertilizer) -> { - String world = location.getWorld().getName(); - int x = location.getBlockX(); - int y = location.getBlockY(); - int z = location.getBlockZ(); + String world = location.getWorldName(); + int x = location.getX(); + int y = location.getY(); + int z = location.getZ(); data.set(world + "." + x + "," + y + "," + z + ".fertilizer", fertilizer.getKey()); data.set(world + "." + x + "," + y + "," + z + ".times", fertilizer.getTimes()); })); diff --git a/src/main/java/net/momirealms/customcrops/datamanager/SeasonManager.java b/src/main/java/net/momirealms/customcrops/datamanager/SeasonManager.java index 33de245..be508ef 100644 --- a/src/main/java/net/momirealms/customcrops/datamanager/SeasonManager.java +++ b/src/main/java/net/momirealms/customcrops/datamanager/SeasonManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.datamanager; import net.momirealms.customcrops.utils.AdventureManager; diff --git a/src/main/java/net/momirealms/customcrops/datamanager/SprinklerManager.java b/src/main/java/net/momirealms/customcrops/datamanager/SprinklerManager.java index 251051c..6004a4d 100644 --- a/src/main/java/net/momirealms/customcrops/datamanager/SprinklerManager.java +++ b/src/main/java/net/momirealms/customcrops/datamanager/SprinklerManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.datamanager; import dev.lone.itemsadder.api.CustomBlock; diff --git a/src/main/java/net/momirealms/customcrops/fertilizer/Fertilizer.java b/src/main/java/net/momirealms/customcrops/fertilizer/Fertilizer.java index e08b836..6778b06 100644 --- a/src/main/java/net/momirealms/customcrops/fertilizer/Fertilizer.java +++ b/src/main/java/net/momirealms/customcrops/fertilizer/Fertilizer.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.fertilizer; public interface Fertilizer { diff --git a/src/main/java/net/momirealms/customcrops/fertilizer/QualityCrop.java b/src/main/java/net/momirealms/customcrops/fertilizer/QualityCrop.java index 3a65ca9..6790d1a 100644 --- a/src/main/java/net/momirealms/customcrops/fertilizer/QualityCrop.java +++ b/src/main/java/net/momirealms/customcrops/fertilizer/QualityCrop.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.fertilizer; public class QualityCrop implements Fertilizer{ diff --git a/src/main/java/net/momirealms/customcrops/fertilizer/RetainingSoil.java b/src/main/java/net/momirealms/customcrops/fertilizer/RetainingSoil.java index 3168cc6..856c14a 100644 --- a/src/main/java/net/momirealms/customcrops/fertilizer/RetainingSoil.java +++ b/src/main/java/net/momirealms/customcrops/fertilizer/RetainingSoil.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.fertilizer; public class RetainingSoil implements Fertilizer{ diff --git a/src/main/java/net/momirealms/customcrops/fertilizer/SpeedGrow.java b/src/main/java/net/momirealms/customcrops/fertilizer/SpeedGrow.java index 885067c..ff93355 100644 --- a/src/main/java/net/momirealms/customcrops/fertilizer/SpeedGrow.java +++ b/src/main/java/net/momirealms/customcrops/fertilizer/SpeedGrow.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.fertilizer; public class SpeedGrow implements Fertilizer{ diff --git a/src/main/java/net/momirealms/customcrops/integrations/GriefDefender.java b/src/main/java/net/momirealms/customcrops/integrations/GriefDefender.java index 6c74c03..31b5982 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/GriefDefender.java +++ b/src/main/java/net/momirealms/customcrops/integrations/GriefDefender.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import org.bukkit.Location; diff --git a/src/main/java/net/momirealms/customcrops/integrations/Integration.java b/src/main/java/net/momirealms/customcrops/integrations/Integration.java index 8fcccde..a76e804 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/Integration.java +++ b/src/main/java/net/momirealms/customcrops/integrations/Integration.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import org.bukkit.Location; diff --git a/src/main/java/net/momirealms/customcrops/integrations/KingdomsX.java b/src/main/java/net/momirealms/customcrops/integrations/KingdomsX.java index e017a26..a995f8f 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/KingdomsX.java +++ b/src/main/java/net/momirealms/customcrops/integrations/KingdomsX.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import org.bukkit.Location; diff --git a/src/main/java/net/momirealms/customcrops/integrations/Lands.java b/src/main/java/net/momirealms/customcrops/integrations/Lands.java index 049e59c..29c8efb 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/Lands.java +++ b/src/main/java/net/momirealms/customcrops/integrations/Lands.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import me.angeschossen.lands.api.flags.Flags; diff --git a/src/main/java/net/momirealms/customcrops/integrations/PlotSquared.java b/src/main/java/net/momirealms/customcrops/integrations/PlotSquared.java index 2e90f2b..077232a 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/PlotSquared.java +++ b/src/main/java/net/momirealms/customcrops/integrations/PlotSquared.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import com.plotsquared.core.location.Location; diff --git a/src/main/java/net/momirealms/customcrops/integrations/Residence.java b/src/main/java/net/momirealms/customcrops/integrations/Residence.java index 3ee2ae6..d8716be 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/Residence.java +++ b/src/main/java/net/momirealms/customcrops/integrations/Residence.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import com.bekvon.bukkit.residence.containers.Flags; diff --git a/src/main/java/net/momirealms/customcrops/integrations/Towny.java b/src/main/java/net/momirealms/customcrops/integrations/Towny.java index 5e5f402..084aa49 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/Towny.java +++ b/src/main/java/net/momirealms/customcrops/integrations/Towny.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import com.palmergames.bukkit.towny.object.TownyPermission; diff --git a/src/main/java/net/momirealms/customcrops/integrations/WorldGuard.java b/src/main/java/net/momirealms/customcrops/integrations/WorldGuard.java index f29ea08..1f39a07 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/WorldGuard.java +++ b/src/main/java/net/momirealms/customcrops/integrations/WorldGuard.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.integrations; import com.sk89q.worldedit.bukkit.BukkitAdapter; diff --git a/src/main/java/net/momirealms/customcrops/limits/CropsPerChunk.java b/src/main/java/net/momirealms/customcrops/limits/CropsPerChunk.java index 26fdd85..8c659b9 100644 --- a/src/main/java/net/momirealms/customcrops/limits/CropsPerChunk.java +++ b/src/main/java/net/momirealms/customcrops/limits/CropsPerChunk.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.limits; import dev.lone.itemsadder.api.CustomBlock; diff --git a/src/main/java/net/momirealms/customcrops/limits/SprinklersPerChunk.java b/src/main/java/net/momirealms/customcrops/limits/SprinklersPerChunk.java index 8267b9e..5aa8061 100644 --- a/src/main/java/net/momirealms/customcrops/limits/SprinklersPerChunk.java +++ b/src/main/java/net/momirealms/customcrops/limits/SprinklersPerChunk.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.limits; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/listener/BreakBlock.java b/src/main/java/net/momirealms/customcrops/listener/BreakBlock.java index 4e4130e..b9f5835 100644 --- a/src/main/java/net/momirealms/customcrops/listener/BreakBlock.java +++ b/src/main/java/net/momirealms/customcrops/listener/BreakBlock.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.listener; import dev.lone.itemsadder.api.CustomBlock; @@ -9,6 +26,7 @@ import net.momirealms.customcrops.fertilizer.Fertilizer; import net.momirealms.customcrops.fertilizer.QualityCrop; import net.momirealms.customcrops.integrations.Integration; import net.momirealms.customcrops.utils.CropInstance; +import net.momirealms.customcrops.utils.SimpleLocation; import org.apache.commons.lang.StringUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -51,7 +69,7 @@ public class BreakBlock implements Listener { int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1); Location itemLoc = location.clone().add(0.5,0.2,0.5); World world = location.getWorld(); - Fertilizer fertilizer = PotManager.Cache.get(location.clone().subtract(0,1,0)); + Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(location.clone().subtract(0,1,0))); if (fertilizer != null){ if (fertilizer instanceof QualityCrop qualityCrop){ int[] weights = qualityCrop.getChance(); @@ -79,7 +97,7 @@ public class BreakBlock implements Listener { } else if(namespacedId.equalsIgnoreCase(ConfigReader.Basic.watered_pot) || namespacedId.equalsIgnoreCase(ConfigReader.Basic.pot)){ Location location = event.getBlock().getLocation(); - PotManager.Cache.remove(location); + PotManager.Cache.remove(SimpleLocation.fromLocation(location)); World world = location.getWorld(); Block blockUp = location.add(0,1,0).getBlock(); for (Integration integration : ConfigReader.Config.integration){ @@ -99,7 +117,7 @@ public class BreakBlock implements Listener { ThreadLocalRandom current = ThreadLocalRandom.current(); int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1); Location itemLoc = location.clone().add(0.5,0.2,0.5); - Fertilizer fertilizer = PotManager.Cache.get(location.clone().subtract(0,1,0)); + Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(location.clone().subtract(0,1,0))); if (fertilizer != null){ if (fertilizer instanceof QualityCrop qualityCrop){ int[] weights = qualityCrop.getChance(); diff --git a/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java b/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java index 830cbac..fc01b99 100644 --- a/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java +++ b/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.listener; import de.tr7zw.changeme.nbtapi.NBTCompound; @@ -134,8 +151,8 @@ public class InteractEntity implements Listener { if (ConfigReader.Message.hasSprinklerInfo){ String string = ConfigReader.Message.sprinklerLeft + ConfigReader.Message.sprinklerFull.repeat(currentWater) + ConfigReader.Message.sprinklerEmpty.repeat(maxWater - currentWater) + ConfigReader.Message.sprinklerRight; - if(HoloUtil.cache.get(player) == null) { - HoloUtil.showHolo(string.replace("{max_water}", String.valueOf(maxWater)).replace("{water}", String.valueOf(currentWater)), player, location.add(0, ConfigReader.Message.sprinklerOffset,0), ConfigReader.Message.sprinklerTime); + if(HoloUtil.cache.get(location.add(0, ConfigReader.Message.sprinklerOffset,0)) == null) { + HoloUtil.showHolo(string.replace("{max_water}", String.valueOf(maxWater)).replace("{water}", String.valueOf(currentWater)), player, location, ConfigReader.Message.sprinklerTime); } } } diff --git a/src/main/java/net/momirealms/customcrops/listener/ItemSpawn.java b/src/main/java/net/momirealms/customcrops/listener/ItemSpawn.java index 1aca263..15677ff 100644 --- a/src/main/java/net/momirealms/customcrops/listener/ItemSpawn.java +++ b/src/main/java/net/momirealms/customcrops/listener/ItemSpawn.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.listener; import dev.lone.itemsadder.api.CustomStack; diff --git a/src/main/java/net/momirealms/customcrops/listener/RightClick.java b/src/main/java/net/momirealms/customcrops/listener/RightClick.java index 0c102af..dc55e53 100644 --- a/src/main/java/net/momirealms/customcrops/listener/RightClick.java +++ b/src/main/java/net/momirealms/customcrops/listener/RightClick.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.listener; import de.tr7zw.changeme.nbtapi.NBTCompound; @@ -84,9 +101,17 @@ public class RightClick implements Listener { } Label_out: if (ConfigReader.Season.enable && cropInstance.getSeasons() != null){ - for (String season : cropInstance.getSeasons()) { - if (season.equals(SeasonManager.SEASON.get(location.getWorld().getName()))){ - break Label_out; + if (!ConfigReader.Config.allWorld){ + for (String season : cropInstance.getSeasons()) { + if (season.equals(SeasonManager.SEASON.get(location.getWorld().getName()))){ + break Label_out; + } + } + }else { + for(String season : cropInstance.getSeasons()){ + if (season.equals(SeasonManager.SEASON.get(ConfigReader.Config.referenceWorld))) { + break Label_out; + } } } if(ConfigReader.Season.greenhouse){ @@ -216,17 +241,17 @@ public class RightClick implements Listener { }else { itemStack.setAmount(itemStack.getAmount() - 1); AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey); - addFertilizer(fertilizerConfig, block); + addFertilizer(fertilizerConfig, block.getLocation()); } }else { itemStack.setAmount(itemStack.getAmount() - 1); AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey); - addFertilizer(fertilizerConfig, block); + addFertilizer(fertilizerConfig, block.getLocation()); } }else if (namespacedID.contains("_stage_")){ if (!fertilizerConfig.isBefore()){ itemStack.setAmount(itemStack.getAmount() - 1); - addFertilizer(fertilizerConfig, block); + addFertilizer(fertilizerConfig, block.getLocation().subtract(0,1,0)); AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey); }else { AdventureManager.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.beforePlant); @@ -265,24 +290,24 @@ public class RightClick implements Listener { String namespacedID = customBlock.getNamespacedID(); if (namespacedID.contains("_stage_")){ Location location = block.getLocation().subtract(0,1,0); - Fertilizer fertilizer = PotManager.Cache.get(location); + Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(location)); if (fertilizer != null){ Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey()); String name = config.getName(); int max_times = config.getTimes(); - if(HoloUtil.cache.get(player) == null) { - HoloUtil.showHolo(ConfigReader.Message.cropText.replace("{fertilizer}", name).replace("{times}", String.valueOf(fertilizer.getTimes())).replace("{max_times}", String.valueOf(max_times)), player, location.add(0.5, ConfigReader.Message.cropOffset, 0.5), ConfigReader.Message.cropTime); + if(HoloUtil.cache.get(location.add(0.5, ConfigReader.Message.cropOffset, 0.5)) == null) { + HoloUtil.showHolo(ConfigReader.Message.cropText.replace("{fertilizer}", name).replace("{times}", String.valueOf(fertilizer.getTimes())).replace("{max_times}", String.valueOf(max_times)), player, location, ConfigReader.Message.cropTime); } } }else if(namespacedID.equals(ConfigReader.Basic.pot) || namespacedID.equals(ConfigReader.Basic.watered_pot)){ Location location = block.getLocation(); - Fertilizer fertilizer = PotManager.Cache.get(block.getLocation()); + Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(block.getLocation())); if (fertilizer != null){ Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey()); String name = config.getName(); int max_times = config.getTimes(); - if(HoloUtil.cache.get(player) == null){ - HoloUtil.showHolo(ConfigReader.Message.cropText.replace("{fertilizer}", name).replace("{times}", String.valueOf(fertilizer.getTimes())).replace("{max_times}", String.valueOf(max_times)), player, location.add(0.5,ConfigReader.Message.cropOffset,0.5), ConfigReader.Message.cropTime); + if(HoloUtil.cache.get(location.add(0.5,ConfigReader.Message.cropOffset,0.5)) == null){ + HoloUtil.showHolo(ConfigReader.Message.cropText.replace("{fertilizer}", name).replace("{times}", String.valueOf(fertilizer.getTimes())).replace("{max_times}", String.valueOf(max_times)), player, location, ConfigReader.Message.cropTime); } } } @@ -352,16 +377,16 @@ public class RightClick implements Listener { coolDown.remove(event.getPlayer()); } - private void addFertilizer(Fertilizer fertilizerConfig, Block block) { + private void addFertilizer(Fertilizer fertilizerConfig, Location location) { if (fertilizerConfig instanceof QualityCrop config){ QualityCrop qualityCrop = new QualityCrop(config.getKey(), config.getTimes(), config.getChance(), config.isBefore()); - PotManager.Cache.put(block.getLocation(), qualityCrop); + PotManager.Cache.put(SimpleLocation.fromLocation(location), qualityCrop); }else if (fertilizerConfig instanceof SpeedGrow config){ SpeedGrow speedGrow = new SpeedGrow(config.getKey(), config.getTimes(),config.getChance(), config.isBefore()); - PotManager.Cache.put(block.getLocation(), speedGrow); + PotManager.Cache.put(SimpleLocation.fromLocation(location), speedGrow); }else if (fertilizerConfig instanceof RetainingSoil config){ RetainingSoil retainingSoil = new RetainingSoil(config.getKey(), config.getTimes(),config.getChance(), config.isBefore()); - PotManager.Cache.put(block.getLocation(), retainingSoil); + PotManager.Cache.put(SimpleLocation.fromLocation(location), retainingSoil); } } diff --git a/src/main/java/net/momirealms/customcrops/requirements/Biome.java b/src/main/java/net/momirealms/customcrops/requirements/Biome.java index a1515ec..8638251 100644 --- a/src/main/java/net/momirealms/customcrops/requirements/Biome.java +++ b/src/main/java/net/momirealms/customcrops/requirements/Biome.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.requirements; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/requirements/Permission.java b/src/main/java/net/momirealms/customcrops/requirements/Permission.java index 8c1a8df..cba114c 100644 --- a/src/main/java/net/momirealms/customcrops/requirements/Permission.java +++ b/src/main/java/net/momirealms/customcrops/requirements/Permission.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.requirements; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/requirements/PlantingCondition.java b/src/main/java/net/momirealms/customcrops/requirements/PlantingCondition.java index c5b28ab..206ec42 100644 --- a/src/main/java/net/momirealms/customcrops/requirements/PlantingCondition.java +++ b/src/main/java/net/momirealms/customcrops/requirements/PlantingCondition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.requirements; import org.bukkit.Location; diff --git a/src/main/java/net/momirealms/customcrops/requirements/Requirement.java b/src/main/java/net/momirealms/customcrops/requirements/Requirement.java index 5195d79..c9c48de 100644 --- a/src/main/java/net/momirealms/customcrops/requirements/Requirement.java +++ b/src/main/java/net/momirealms/customcrops/requirements/Requirement.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.requirements; public interface Requirement { diff --git a/src/main/java/net/momirealms/customcrops/requirements/World.java b/src/main/java/net/momirealms/customcrops/requirements/World.java index 8af73ab..fde2558 100644 --- a/src/main/java/net/momirealms/customcrops/requirements/World.java +++ b/src/main/java/net/momirealms/customcrops/requirements/World.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.requirements; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/requirements/YPos.java b/src/main/java/net/momirealms/customcrops/requirements/YPos.java index 743ef50..f034870 100644 --- a/src/main/java/net/momirealms/customcrops/requirements/YPos.java +++ b/src/main/java/net/momirealms/customcrops/requirements/YPos.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.requirements; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/timer/CropTimer.java b/src/main/java/net/momirealms/customcrops/timer/CropTimer.java index ccaa3a5..b49ccce 100644 --- a/src/main/java/net/momirealms/customcrops/timer/CropTimer.java +++ b/src/main/java/net/momirealms/customcrops/timer/CropTimer.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.timer; import net.momirealms.customcrops.CustomCrops; diff --git a/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java b/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java index 9615e4b..2573035 100644 --- a/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java +++ b/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.timer; import net.momirealms.customcrops.CustomCrops; diff --git a/src/main/java/net/momirealms/customcrops/timer/TimeCheck.java b/src/main/java/net/momirealms/customcrops/timer/TimeCheck.java index 2123d18..1ee50be 100644 --- a/src/main/java/net/momirealms/customcrops/timer/TimeCheck.java +++ b/src/main/java/net/momirealms/customcrops/timer/TimeCheck.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.timer; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/utils/AdventureManager.java b/src/main/java/net/momirealms/customcrops/utils/AdventureManager.java index 52165ff..7538df0 100644 --- a/src/main/java/net/momirealms/customcrops/utils/AdventureManager.java +++ b/src/main/java/net/momirealms/customcrops/utils/AdventureManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import net.kyori.adventure.audience.Audience; diff --git a/src/main/java/net/momirealms/customcrops/utils/BackUp.java b/src/main/java/net/momirealms/customcrops/utils/BackUp.java index 57fa8ff..f60db7e 100644 --- a/src/main/java/net/momirealms/customcrops/utils/BackUp.java +++ b/src/main/java/net/momirealms/customcrops/utils/BackUp.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import net.momirealms.customcrops.CustomCrops; diff --git a/src/main/java/net/momirealms/customcrops/utils/CropInstance.java b/src/main/java/net/momirealms/customcrops/utils/CropInstance.java index 992ef70..988a550 100644 --- a/src/main/java/net/momirealms/customcrops/utils/CropInstance.java +++ b/src/main/java/net/momirealms/customcrops/utils/CropInstance.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import net.momirealms.customcrops.requirements.Requirement; diff --git a/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java b/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java index 00a3e89..3126d16 100644 --- a/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java +++ b/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import com.comphenix.protocol.PacketType; @@ -20,7 +37,7 @@ import java.util.Optional; public class HoloUtil { - public static HashMap cache = new HashMap<>(); + public static HashMap cache = new HashMap<>(); public static void showHolo(String text, Player player, Location location, int duration){ @@ -33,7 +50,7 @@ public class HoloUtil { a.setSmall(true); a.setGravity(false); }); - cache.put(player, entity); + cache.put(location, entity); Component component = MiniMessage.miniMessage().deserialize(text); @@ -56,7 +73,7 @@ public class HoloUtil { Bukkit.getScheduler().runTaskLater(CustomCrops.instance, ()->{ entity.remove(); - cache.remove(player); + cache.remove(location); }, duration * 20L); } } diff --git a/src/main/java/net/momirealms/customcrops/utils/IAFurniture.java b/src/main/java/net/momirealms/customcrops/utils/IAFurniture.java index b5f05d9..35dfd9f 100644 --- a/src/main/java/net/momirealms/customcrops/utils/IAFurniture.java +++ b/src/main/java/net/momirealms/customcrops/utils/IAFurniture.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import dev.lone.itemsadder.api.CustomFurniture; diff --git a/src/main/java/net/momirealms/customcrops/utils/NBTUtil.java b/src/main/java/net/momirealms/customcrops/utils/NBTUtil.java index 8abe4d9..7e325ff 100644 --- a/src/main/java/net/momirealms/customcrops/utils/NBTUtil.java +++ b/src/main/java/net/momirealms/customcrops/utils/NBTUtil.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import de.tr7zw.changeme.nbtapi.NBTCompound; diff --git a/src/main/java/net/momirealms/customcrops/utils/Placeholders.java b/src/main/java/net/momirealms/customcrops/utils/Placeholders.java index fd430d7..9f1b5f2 100644 --- a/src/main/java/net/momirealms/customcrops/utils/Placeholders.java +++ b/src/main/java/net/momirealms/customcrops/utils/Placeholders.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import me.clip.placeholderapi.expansion.PlaceholderExpansion; diff --git a/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java b/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java new file mode 100644 index 0000000..af7340b --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java @@ -0,0 +1,74 @@ +package net.momirealms.customcrops.utils; + +import org.bukkit.Location; + +import java.util.Objects; + +public class SimpleLocation { + + private final int x; + private final int y; + private final int z; + private final String worldName; + + public SimpleLocation(String worldName, int x, int y, int z){ + this.worldName = worldName; + this.x = x; + this.y = y; + this.z = z; + } + + public static SimpleLocation fromLocation(Location location){ + return new SimpleLocation(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + + public int getX() { + return x; + } + + public int getZ() { + return z; + } + + public int getY() { + return y; + } + + public String getWorldName() { + return worldName; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SimpleLocation other = (SimpleLocation) obj; + if (!Objects.equals(worldName, other.getWorldName())) { + return false; + } + if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) { + return false; + } + if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) { + return false; + } + if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 19 * hash + (worldName != null ? worldName.hashCode() : 0); + hash = 19 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32)); + hash = 19 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32)); + hash = 19 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32)); + return hash; + } +} diff --git a/src/main/java/net/momirealms/customcrops/utils/Sprinkler.java b/src/main/java/net/momirealms/customcrops/utils/Sprinkler.java index dd069ef..5b93711 100644 --- a/src/main/java/net/momirealms/customcrops/utils/Sprinkler.java +++ b/src/main/java/net/momirealms/customcrops/utils/Sprinkler.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; public class Sprinkler { diff --git a/src/main/java/net/momirealms/customcrops/utils/WateringCan.java b/src/main/java/net/momirealms/customcrops/utils/WateringCan.java index 648f556..4300b8b 100644 --- a/src/main/java/net/momirealms/customcrops/utils/WateringCan.java +++ b/src/main/java/net/momirealms/customcrops/utils/WateringCan.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; public record WateringCan(int max, int width, int length) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3cdf188..6922b62 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -66,4 +66,11 @@ config: #如果你使用上述三个特性中的任意一个,请不要设置为false #否则农作物生长到最后一阶段不会从数据中清除,过大的数据量 #可能会导致服务器严重卡顿 - only-grow-in-loaded-chunks: true \ No newline at end of file + only-grow-in-loaded-chunks: true + + #是否所有加载中的世界都要进行生长判断 + #本选项适用于使用玩家独立世界的服务器 + #因为有大量世界所以无法通过添加白名单世界的方式生长 + #在此选项开启的状态下,白名单世界只能填写一个 + #作为所有世界农作物生长的时间、季节判断依据 + all-world-grow: false \ No newline at end of file