9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 08:29:35 +00:00
1、可以同时使用勘测器查看多个种植盆肥料信息

2、新增实验特性

  #是否所有加载中的世界都要进行生长判断
  #本选项适用于使用玩家独立世界的服务器
  #因为有大量世界所以无法通过添加白名单世界的方式生长
  #在此选项开启的状态下,白名单世界只能填写一个
  #作为所有世界农作物生长的时间、季节判断依据
  all-world-grow: false

3、修复了右键农作物施肥无法生效的bug
This commit is contained in:
Xiao-MoMi
2022-07-16 17:46:19 +08:00
parent cc4eaa5825
commit 7a33dcfd0a
46 changed files with 930 additions and 68 deletions

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops; package net.momirealms.customcrops;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
@@ -51,6 +68,7 @@ public class ConfigReader {
public static List<String> worldNames; public static List<String> worldNames;
public static List<Long> cropGrowTimeList; public static List<Long> cropGrowTimeList;
public static List<Integration> integration; public static List<Integration> integration;
public static String referenceWorld;
public static boolean asyncCheck; public static boolean asyncCheck;
public static boolean enableLimit; public static boolean enableLimit;
public static int cropLimit; public static int cropLimit;
@@ -124,17 +142,26 @@ public class ConfigReader {
waterCanRefill = config.getInt("config.water-can-refill",1); waterCanRefill = config.getInt("config.water-can-refill",1);
canAddWater = config.getBoolean("config.water-can-add-water-to-sprinkler",true); canAddWater = config.getBoolean("config.water-can-add-water-to-sprinkler",true);
//农作物生长的白名单世界 if (allWorld){
worlds = new ArrayList<>(); if (config.getStringList("config.whitelist-worlds").size() > 1){
worldNames = config.getStringList("config.whitelist-worlds"); referenceWorld = config.getStringList("config.whitelist-worlds").get(0);
worldNames.forEach(worldName -> { AdventureManager.consoleMessage("<red>[CustomCrops] 全世界生长模式下只能填写一个白名单世界!");
World world = Bukkit.getWorld(worldName);
if (world == null){
AdventureManager.consoleMessage("<red>[CustomCrops] 世界" + worldName + "" + "不存在");
}else { }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("<red>[CustomCrops] 世界" + worldName + "" + "不存在");
}else {
worlds.add(world);
}
});
}
//处理插件兼容性 //处理插件兼容性
integration = new ArrayList<>(); integration = new ArrayList<>();

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops; package net.momirealms.customcrops;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
@@ -100,7 +117,9 @@ public final class CustomCrops extends JavaPlugin {
public void onDisable() { public void onDisable() {
//保存数据 //保存数据
this.cropManager.cleanData();
this.cropManager.saveData(); this.cropManager.saveData();
this.sprinklerManager.cleanData();
this.sprinklerManager.saveData(); this.sprinklerManager.saveData();
this.potManager.saveData(); this.potManager.saveData();
if (ConfigReader.Season.enable && !ConfigReader.Season.seasonChange){ if (ConfigReader.Season.enable && !ConfigReader.Season.seasonChange){
@@ -113,8 +132,8 @@ public final class CustomCrops extends JavaPlugin {
getLogger().info("备份已完成..."); getLogger().info("备份已完成...");
//清除悬浮展示实体 //清除悬浮展示实体
HoloUtil.cache.keySet().forEach(player -> { HoloUtil.cache.keySet().forEach(location -> {
HoloUtil.cache.get(player).remove(); HoloUtil.cache.get(location).remove();
}); });
//关闭计时器 //关闭计时器

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.commands; package net.momirealms.customcrops.commands;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.commands; package net.momirealms.customcrops.commands;
import net.momirealms.customcrops.utils.AdventureManager; import net.momirealms.customcrops.utils.AdventureManager;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.datamanager; package net.momirealms.customcrops.datamanager;
import dev.lone.itemsadder.api.CustomBlock; 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.RetainingSoil;
import net.momirealms.customcrops.fertilizer.SpeedGrow; import net.momirealms.customcrops.fertilizer.SpeedGrow;
import net.momirealms.customcrops.utils.CropInstance; import net.momirealms.customcrops.utils.CropInstance;
import net.momirealms.customcrops.utils.SimpleLocation;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@@ -137,7 +155,7 @@ public class CropManager {
} }
int nextStage = Integer.parseInt(cropNameList[2]) + 1; int nextStage = Integer.parseInt(cropNameList[2]) + 1;
if (CustomBlock.getInstance(StringUtils.chop(namespacedID) + nextStage) != null) { 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){ if (fertilizer != null){
int times = fertilizer.getTimes(); int times = fertilizer.getTimes();
if (times > 0){ if (times > 0){
@@ -158,10 +176,10 @@ public class CropManager {
addStage(potLocation, seedLocation, namespacedID, nextStage, random); addStage(potLocation, seedLocation, namespacedID, nextStage, random);
}else { }else {
AdventureManager.consoleMessage("<red>[CustomCrops] 发现未知类型肥料,已自动清除错误数据!</red>"); AdventureManager.consoleMessage("<red>[CustomCrops] 发现未知类型肥料,已自动清除错误数据!</red>");
PotManager.Cache.remove(potLocation); PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation));
} }
}else { }else {
PotManager.Cache.remove(potLocation); PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation));
} }
} }
else { else {
@@ -265,7 +283,7 @@ public class CropManager {
} }
int nextStage = Integer.parseInt(cropNameList[2]) + 1; int nextStage = Integer.parseInt(cropNameList[2]) + 1;
if (CustomBlock.getInstance(StringUtils.chop(namespacedID) + nextStage) != null) { 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){ if (fertilizer != null){
int times = fertilizer.getTimes(); int times = fertilizer.getTimes();
if (times > 0){ if (times > 0){
@@ -286,10 +304,10 @@ public class CropManager {
addStage(potLocation, seedLocation, namespacedID, nextStage, random); addStage(potLocation, seedLocation, namespacedID, nextStage, random);
}else { }else {
AdventureManager.consoleMessage("<red>[CustomCrops] 发现未知类型肥料,已自动清除错误数据!</red>"); AdventureManager.consoleMessage("<red>[CustomCrops] 发现未知类型肥料,已自动清除错误数据!</red>");
PotManager.Cache.remove(potLocation); PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation));
} }
}else { }else {
PotManager.Cache.remove(potLocation); PotManager.Cache.remove(SimpleLocation.fromLocation(potLocation));
} }
} }
else { else {
@@ -350,9 +368,17 @@ public class CropManager {
} }
} }
} }
for(String season : seasons){ if (!ConfigReader.Config.allWorld){
if (season.equals(SeasonManager.SEASON.get(worldName))) { for(String season : seasons){
return false; 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; return true;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.datamanager; package net.momirealms.customcrops.datamanager;
import net.momirealms.customcrops.utils.AdventureManager; 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.QualityCrop;
import net.momirealms.customcrops.fertilizer.RetainingSoil; import net.momirealms.customcrops.fertilizer.RetainingSoil;
import net.momirealms.customcrops.fertilizer.SpeedGrow; import net.momirealms.customcrops.fertilizer.SpeedGrow;
import net.momirealms.customcrops.utils.SimpleLocation;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@@ -20,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class PotManager { public class PotManager {
private CustomCrops plugin; private CustomCrops plugin;
public static ConcurrentHashMap<Location, Fertilizer> Cache = new ConcurrentHashMap<>(); public static ConcurrentHashMap<SimpleLocation, Fertilizer> Cache = new ConcurrentHashMap<>();
public PotManager(CustomCrops plugin){ public PotManager(CustomCrops plugin){
this.plugin = plugin; this.plugin = plugin;
@@ -39,36 +57,38 @@ public class PotManager {
} }
YamlConfiguration data = YamlConfiguration.loadConfiguration(file); YamlConfiguration data = YamlConfiguration.loadConfiguration(file);
data.getKeys(false).forEach(worldName -> { data.getKeys(false).forEach(worldName -> {
if (ConfigReader.Config.worldNames.contains(worldName)){ data.getConfigurationSection(worldName).getValues(false).forEach((key, value) ->{
data.getConfigurationSection(worldName).getValues(false).forEach((key, value) ->{ String[] split = StringUtils.split(key, ",");
String[] split = StringUtils.split(key, ","); if (value instanceof MemorySection map){
if (value instanceof MemorySection map){ String name = (String) map.get("fertilizer");
String name = (String) map.get("fertilizer"); Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(name);
Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(name); if (fertilizer == null) return;
if (fertilizer == null) return; if (fertilizer instanceof SpeedGrow speedGrow){
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())); //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){ }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())); 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()));
}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 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 RetainingSoil(name, (int) map.get("times"), retainingSoil.getChance(), retainingSoil.isBefore())); }else if (fertilizer instanceof RetainingSoil retainingSoil){
}else { 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()));
AdventureManager.consoleMessage("<red>[CustomCrops] 未知肥料类型错误!</red>"); //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("<red>[CustomCrops] 未知肥料类型错误!</red>");
} }
}); }
} });
}); });
} }
public void saveData(){ public void saveData(){
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "pot.yml"); File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "pot.yml");
System.out.println(Cache.size());
YamlConfiguration data = new YamlConfiguration(); YamlConfiguration data = new YamlConfiguration();
Cache.forEach(((location, fertilizer) -> { Cache.forEach(((location, fertilizer) -> {
String world = location.getWorld().getName(); String world = location.getWorldName();
int x = location.getBlockX(); int x = location.getX();
int y = location.getBlockY(); int y = location.getY();
int z = location.getBlockZ(); int z = location.getZ();
data.set(world + "." + x + "," + y + "," + z + ".fertilizer", fertilizer.getKey()); data.set(world + "." + x + "," + y + "," + z + ".fertilizer", fertilizer.getKey());
data.set(world + "." + x + "," + y + "," + z + ".times", fertilizer.getTimes()); data.set(world + "." + x + "," + y + "," + z + ".times", fertilizer.getTimes());
})); }));

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.datamanager; package net.momirealms.customcrops.datamanager;
import net.momirealms.customcrops.utils.AdventureManager; import net.momirealms.customcrops.utils.AdventureManager;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.datamanager; package net.momirealms.customcrops.datamanager;
import dev.lone.itemsadder.api.CustomBlock; import dev.lone.itemsadder.api.CustomBlock;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.fertilizer; package net.momirealms.customcrops.fertilizer;
public interface Fertilizer { public interface Fertilizer {

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.fertilizer; package net.momirealms.customcrops.fertilizer;
public class QualityCrop implements Fertilizer{ public class QualityCrop implements Fertilizer{

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.fertilizer; package net.momirealms.customcrops.fertilizer;
public class RetainingSoil implements Fertilizer{ public class RetainingSoil implements Fertilizer{

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.fertilizer; package net.momirealms.customcrops.fertilizer;
public class SpeedGrow implements Fertilizer{ public class SpeedGrow implements Fertilizer{

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import me.angeschossen.lands.api.flags.Flags; import me.angeschossen.lands.api.flags.Flags;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import com.bekvon.bukkit.residence.containers.Flags; import com.bekvon.bukkit.residence.containers.Flags;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import com.palmergames.bukkit.towny.object.TownyPermission; import com.palmergames.bukkit.towny.object.TownyPermission;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.integrations; package net.momirealms.customcrops.integrations;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.limits; package net.momirealms.customcrops.limits;
import dev.lone.itemsadder.api.CustomBlock; import dev.lone.itemsadder.api.CustomBlock;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.limits; package net.momirealms.customcrops.limits;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.listener; package net.momirealms.customcrops.listener;
import dev.lone.itemsadder.api.CustomBlock; 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.fertilizer.QualityCrop;
import net.momirealms.customcrops.integrations.Integration; import net.momirealms.customcrops.integrations.Integration;
import net.momirealms.customcrops.utils.CropInstance; import net.momirealms.customcrops.utils.CropInstance;
import net.momirealms.customcrops.utils.SimpleLocation;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@@ -51,7 +69,7 @@ public class BreakBlock implements Listener {
int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1); int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1);
Location itemLoc = location.clone().add(0.5,0.2,0.5); Location itemLoc = location.clone().add(0.5,0.2,0.5);
World world = location.getWorld(); 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 != null){
if (fertilizer instanceof QualityCrop qualityCrop){ if (fertilizer instanceof QualityCrop qualityCrop){
int[] weights = qualityCrop.getChance(); 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)){ else if(namespacedId.equalsIgnoreCase(ConfigReader.Basic.watered_pot) || namespacedId.equalsIgnoreCase(ConfigReader.Basic.pot)){
Location location = event.getBlock().getLocation(); Location location = event.getBlock().getLocation();
PotManager.Cache.remove(location); PotManager.Cache.remove(SimpleLocation.fromLocation(location));
World world = location.getWorld(); World world = location.getWorld();
Block blockUp = location.add(0,1,0).getBlock(); Block blockUp = location.add(0,1,0).getBlock();
for (Integration integration : ConfigReader.Config.integration){ for (Integration integration : ConfigReader.Config.integration){
@@ -99,7 +117,7 @@ public class BreakBlock implements Listener {
ThreadLocalRandom current = ThreadLocalRandom.current(); ThreadLocalRandom current = ThreadLocalRandom.current();
int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1); int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1);
Location itemLoc = location.clone().add(0.5,0.2,0.5); 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 != null){
if (fertilizer instanceof QualityCrop qualityCrop){ if (fertilizer instanceof QualityCrop qualityCrop){
int[] weights = qualityCrop.getChance(); int[] weights = qualityCrop.getChance();

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.listener; package net.momirealms.customcrops.listener;
import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTCompound;
@@ -134,8 +151,8 @@ public class InteractEntity implements Listener {
if (ConfigReader.Message.hasSprinklerInfo){ if (ConfigReader.Message.hasSprinklerInfo){
String string = ConfigReader.Message.sprinklerLeft + ConfigReader.Message.sprinklerFull.repeat(currentWater) + String string = ConfigReader.Message.sprinklerLeft + ConfigReader.Message.sprinklerFull.repeat(currentWater) +
ConfigReader.Message.sprinklerEmpty.repeat(maxWater - currentWater) + ConfigReader.Message.sprinklerRight; ConfigReader.Message.sprinklerEmpty.repeat(maxWater - currentWater) + ConfigReader.Message.sprinklerRight;
if(HoloUtil.cache.get(player) == null) { 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.add(0, ConfigReader.Message.sprinklerOffset,0), ConfigReader.Message.sprinklerTime); HoloUtil.showHolo(string.replace("{max_water}", String.valueOf(maxWater)).replace("{water}", String.valueOf(currentWater)), player, location, ConfigReader.Message.sprinklerTime);
} }
} }
} }

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.listener; package net.momirealms.customcrops.listener;
import dev.lone.itemsadder.api.CustomStack; import dev.lone.itemsadder.api.CustomStack;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.listener; package net.momirealms.customcrops.listener;
import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTCompound;
@@ -84,9 +101,17 @@ public class RightClick implements Listener {
} }
Label_out: Label_out:
if (ConfigReader.Season.enable && cropInstance.getSeasons() != null){ if (ConfigReader.Season.enable && cropInstance.getSeasons() != null){
for (String season : cropInstance.getSeasons()) { if (!ConfigReader.Config.allWorld){
if (season.equals(SeasonManager.SEASON.get(location.getWorld().getName()))){ for (String season : cropInstance.getSeasons()) {
break Label_out; 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){ if(ConfigReader.Season.greenhouse){
@@ -216,17 +241,17 @@ public class RightClick implements Listener {
}else { }else {
itemStack.setAmount(itemStack.getAmount() - 1); itemStack.setAmount(itemStack.getAmount() - 1);
AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey); AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey);
addFertilizer(fertilizerConfig, block); addFertilizer(fertilizerConfig, block.getLocation());
} }
}else { }else {
itemStack.setAmount(itemStack.getAmount() - 1); itemStack.setAmount(itemStack.getAmount() - 1);
AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey); AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey);
addFertilizer(fertilizerConfig, block); addFertilizer(fertilizerConfig, block.getLocation());
} }
}else if (namespacedID.contains("_stage_")){ }else if (namespacedID.contains("_stage_")){
if (!fertilizerConfig.isBefore()){ if (!fertilizerConfig.isBefore()){
itemStack.setAmount(itemStack.getAmount() - 1); 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); AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey);
}else { }else {
AdventureManager.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.beforePlant); AdventureManager.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.beforePlant);
@@ -265,24 +290,24 @@ public class RightClick implements Listener {
String namespacedID = customBlock.getNamespacedID(); String namespacedID = customBlock.getNamespacedID();
if (namespacedID.contains("_stage_")){ if (namespacedID.contains("_stage_")){
Location location = block.getLocation().subtract(0,1,0); 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){ if (fertilizer != null){
Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey()); Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
String name = config.getName(); String name = config.getName();
int max_times = config.getTimes(); int max_times = config.getTimes();
if(HoloUtil.cache.get(player) == null) { 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.add(0.5, ConfigReader.Message.cropOffset, 0.5), ConfigReader.Message.cropTime); 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)){ }else if(namespacedID.equals(ConfigReader.Basic.pot) || namespacedID.equals(ConfigReader.Basic.watered_pot)){
Location location = block.getLocation(); Location location = block.getLocation();
Fertilizer fertilizer = PotManager.Cache.get(block.getLocation()); Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(block.getLocation()));
if (fertilizer != null){ if (fertilizer != null){
Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey()); Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
String name = config.getName(); String name = config.getName();
int max_times = config.getTimes(); int max_times = config.getTimes();
if(HoloUtil.cache.get(player) == null){ 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.add(0.5,ConfigReader.Message.cropOffset,0.5), ConfigReader.Message.cropTime); 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()); coolDown.remove(event.getPlayer());
} }
private void addFertilizer(Fertilizer fertilizerConfig, Block block) { private void addFertilizer(Fertilizer fertilizerConfig, Location location) {
if (fertilizerConfig instanceof QualityCrop config){ if (fertilizerConfig instanceof QualityCrop config){
QualityCrop qualityCrop = new QualityCrop(config.getKey(), config.getTimes(), config.getChance(), config.isBefore()); 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){ }else if (fertilizerConfig instanceof SpeedGrow config){
SpeedGrow speedGrow = new SpeedGrow(config.getKey(), config.getTimes(),config.getChance(), config.isBefore()); 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){ }else if (fertilizerConfig instanceof RetainingSoil config){
RetainingSoil retainingSoil = new RetainingSoil(config.getKey(), config.getTimes(),config.getChance(), config.isBefore()); 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);
} }
} }

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.requirements; package net.momirealms.customcrops.requirements;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.requirements; package net.momirealms.customcrops.requirements;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.requirements; package net.momirealms.customcrops.requirements;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.requirements; package net.momirealms.customcrops.requirements;
public interface Requirement { public interface Requirement {

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.requirements; package net.momirealms.customcrops.requirements;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.requirements; package net.momirealms.customcrops.requirements;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.timer; package net.momirealms.customcrops.timer;
import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.CustomCrops;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.timer; package net.momirealms.customcrops.timer;
import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.CustomCrops;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.timer; package net.momirealms.customcrops.timer;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.CustomCrops;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import net.momirealms.customcrops.requirements.Requirement; import net.momirealms.customcrops.requirements.Requirement;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
@@ -20,7 +37,7 @@ import java.util.Optional;
public class HoloUtil { public class HoloUtil {
public static HashMap<Player, Entity> cache = new HashMap<>(); public static HashMap<Location, Entity> cache = new HashMap<>();
public static void showHolo(String text, Player player, Location location, int duration){ public static void showHolo(String text, Player player, Location location, int duration){
@@ -33,7 +50,7 @@ public class HoloUtil {
a.setSmall(true); a.setSmall(true);
a.setGravity(false); a.setGravity(false);
}); });
cache.put(player, entity); cache.put(location, entity);
Component component = MiniMessage.miniMessage().deserialize(text); Component component = MiniMessage.miniMessage().deserialize(text);
@@ -56,7 +73,7 @@ public class HoloUtil {
Bukkit.getScheduler().runTaskLater(CustomCrops.instance, ()->{ Bukkit.getScheduler().runTaskLater(CustomCrops.instance, ()->{
entity.remove(); entity.remove();
cache.remove(player); cache.remove(location);
}, duration * 20L); }, duration * 20L);
} }
} }

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import dev.lone.itemsadder.api.CustomFurniture; import dev.lone.itemsadder.api.CustomFurniture;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTCompound;

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;

View File

@@ -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;
}
}

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
public class Sprinkler { public class Sprinkler {

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.utils; package net.momirealms.customcrops.utils;
public record WateringCan(int max, int width, int length) { public record WateringCan(int max, int width, int length) {

View File

@@ -66,4 +66,11 @@ config:
#如果你使用上述三个特性中的任意一个请不要设置为false #如果你使用上述三个特性中的任意一个请不要设置为false
#否则农作物生长到最后一阶段不会从数据中清除,过大的数据量 #否则农作物生长到最后一阶段不会从数据中清除,过大的数据量
#可能会导致服务器严重卡顿 #可能会导致服务器严重卡顿
only-grow-in-loaded-chunks: true only-grow-in-loaded-chunks: true
#是否所有加载中的世界都要进行生长判断
#本选项适用于使用玩家独立世界的服务器
#因为有大量世界所以无法通过添加白名单世界的方式生长
#在此选项开启的状态下,白名单世界只能填写一个
#作为所有世界农作物生长的时间、季节判断依据
all-world-grow: false