mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
1.5.26.3
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
|||||||
|
|
||||||
|
|
||||||
group = 'net.momirealms'
|
group = 'net.momirealms'
|
||||||
version = '1.5.26.2'
|
version = '1.5.26.3'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
0
libs/CrashClaim(premium).txt
Normal file
0
libs/CrashClaim(premium).txt
Normal file
@@ -17,18 +17,11 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops;
|
package net.momirealms.customcrops;
|
||||||
|
|
||||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
|
||||||
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning;
|
|
||||||
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings;
|
|
||||||
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
|
|
||||||
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
|
|
||||||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
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.helper.Log;
|
|
||||||
import net.momirealms.customcrops.integrations.protection.*;
|
import net.momirealms.customcrops.integrations.protection.*;
|
||||||
import net.momirealms.customcrops.integrations.skill.*;
|
import net.momirealms.customcrops.integrations.skill.*;
|
||||||
import net.momirealms.customcrops.requirements.Biome;
|
import net.momirealms.customcrops.requirements.Biome;
|
||||||
@@ -44,7 +37,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ConfigReader {
|
public class ConfigReader {
|
||||||
@@ -55,9 +47,9 @@ public class ConfigReader {
|
|||||||
public static HashMap<String, Sprinkler> SPRINKLERS = new HashMap<>();
|
public static HashMap<String, Sprinkler> SPRINKLERS = new HashMap<>();
|
||||||
|
|
||||||
public static YamlConfiguration getConfig(String configName) {
|
public static YamlConfiguration getConfig(String configName) {
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), configName);
|
File file = new File(CustomCrops.plugin.getDataFolder(), configName);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
CustomCrops.instance.saveResource(configName, false);
|
CustomCrops.plugin.saveResource(configName, false);
|
||||||
}
|
}
|
||||||
return YamlConfiguration.loadConfiguration(file);
|
return YamlConfiguration.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
@@ -111,26 +103,19 @@ public class ConfigReader {
|
|||||||
public static void loadConfig(){
|
public static void loadConfig(){
|
||||||
|
|
||||||
//存读基本配置文件
|
//存读基本配置文件
|
||||||
CustomCrops.instance.saveDefaultConfig();
|
CustomCrops.plugin.saveDefaultConfig();
|
||||||
CustomCrops.instance.reloadConfig();
|
CustomCrops.plugin.reloadConfig();
|
||||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
FileConfiguration config = CustomCrops.plugin.getConfig();
|
||||||
|
|
||||||
lang = config.getString("config.lang","chinese");
|
lang = config.getString("config.lang","chinese");
|
||||||
|
|
||||||
//农作物生长时间点
|
|
||||||
cropGrowTimeList = config.getLongList("config.grow-time");
|
cropGrowTimeList = config.getLongList("config.grow-time");
|
||||||
cropGrowTimeList.forEach(time -> {
|
cropGrowTimeList.forEach(time -> {if(time < 0 || time > 23999){AdventureManager.consoleMessage("<red>[CustomCrops] Grow time should be between 0 and 23999");}});
|
||||||
if(time < 0 || time > 23999){
|
|
||||||
AdventureManager.consoleMessage("<red>[CustomCrops] Grow time should be between 0 and 23999");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
timeToGrow = config.getInt("config.time-to-grow",60)*20;
|
timeToGrow = config.getInt("config.time-to-grow",60)*20;
|
||||||
timeToWork = config.getInt("config.time-to-work",30)*20;
|
timeToWork = config.getInt("config.time-to-work",30)*20;
|
||||||
asyncCheck = config.getBoolean("config.async-time-check",false);
|
asyncCheck = config.getBoolean("config.async-time-check",false);
|
||||||
logTime = config.getBoolean("config.log-time-consume",false);
|
logTime = config.getBoolean("config.log-time-consume",false);
|
||||||
growMode = config.getInt("config.grow-mode",3);
|
growMode = config.getInt("config.grow-mode",3); if (growMode > 4 || growMode < 1) growMode = 3;
|
||||||
if (growMode > 4 || growMode < 1) growMode = 3;
|
|
||||||
allWorld = config.getBoolean("config.all-world-grow",false);
|
allWorld = config.getBoolean("config.all-world-grow",false);
|
||||||
hasParticle = config.getBoolean("config.water-particles", true);
|
hasParticle = config.getBoolean("config.water-particles", true);
|
||||||
rightClickHarvest = config.getBoolean("config.right-click-harvest", true);
|
rightClickHarvest = config.getBoolean("config.right-click-harvest", true);
|
||||||
@@ -201,7 +186,7 @@ public class ConfigReader {
|
|||||||
integration = new ArrayList<>();
|
integration = new ArrayList<>();
|
||||||
if(config.getBoolean("config.integration.Residence",false)){
|
if(config.getBoolean("config.integration.Residence",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("Residence") == null){
|
if(Bukkit.getPluginManager().getPlugin("Residence") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize Residence!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize Residence!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new Residence());
|
integration.add(new Residence());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Residence <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Residence <color:#FFEBCD>Hooked!");
|
||||||
@@ -209,7 +194,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.Kingdoms",false)){
|
if(config.getBoolean("config.integration.Kingdoms",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("Kingdoms") == null){
|
if(Bukkit.getPluginManager().getPlugin("Kingdoms") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize Kingdoms!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize Kingdoms!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new KingdomsX());
|
integration.add(new KingdomsX());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>KingdomsX <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>KingdomsX <color:#FFEBCD>Hooked!");
|
||||||
@@ -217,7 +202,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.WorldGuard",false)){
|
if(config.getBoolean("config.integration.WorldGuard",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("WorldGuard") == null){
|
if(Bukkit.getPluginManager().getPlugin("WorldGuard") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize WorldGuard!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize WorldGuard!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new WorldGuard());
|
integration.add(new WorldGuard());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>WorldGuard <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>WorldGuard <color:#FFEBCD>Hooked!");
|
||||||
@@ -225,7 +210,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.GriefDefender",false)){
|
if(config.getBoolean("config.integration.GriefDefender",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null){
|
if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize GriefDefender!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize GriefDefender!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new GriefDefender());
|
integration.add(new GriefDefender());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>GriefDefender <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>GriefDefender <color:#FFEBCD>Hooked!");
|
||||||
@@ -233,7 +218,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.PlotSquared",false)){
|
if(config.getBoolean("config.integration.PlotSquared",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null){
|
if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize PlotSquared!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize PlotSquared!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new PlotSquared());
|
integration.add(new PlotSquared());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>PlotSquared <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>PlotSquared <color:#FFEBCD>Hooked!");
|
||||||
@@ -241,7 +226,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.Towny",false)){
|
if(config.getBoolean("config.integration.Towny",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("Towny") == null){
|
if(Bukkit.getPluginManager().getPlugin("Towny") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize Towny!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize Towny!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new Towny());
|
integration.add(new Towny());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Towny <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Towny <color:#FFEBCD>Hooked!");
|
||||||
@@ -249,7 +234,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.Lands",false)){
|
if(config.getBoolean("config.integration.Lands",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("Lands") == null){
|
if(Bukkit.getPluginManager().getPlugin("Lands") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize Lands!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize Lands!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new Lands());
|
integration.add(new Lands());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Lands <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Lands <color:#FFEBCD>Hooked!");
|
||||||
@@ -257,18 +242,26 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.GriefPrevention",false)){
|
if(config.getBoolean("config.integration.GriefPrevention",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("GriefPrevention") == null){
|
if(Bukkit.getPluginManager().getPlugin("GriefPrevention") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize GriefPrevention!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize GriefPrevention!");
|
||||||
}else {
|
}else {
|
||||||
integration.add(new GriefPrevention());
|
integration.add(new GriefPrevention());
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>GriefPrevention <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>GriefPrevention <color:#FFEBCD>Hooked!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(config.getBoolean("config.integration.CrashClaim",false)){
|
||||||
|
if(Bukkit.getPluginManager().getPlugin("CrashClaim") == null){
|
||||||
|
CustomCrops.plugin.getLogger().warning("Failed to initialize CrashClaim!");
|
||||||
|
}else {
|
||||||
|
integration.add(new CrashClaim());
|
||||||
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>CrashClaim <color:#FFEBCD>Hooked!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
skillXP = null;
|
skillXP = null;
|
||||||
|
|
||||||
if(config.getBoolean("config.integration.mcMMO",false)){
|
if(config.getBoolean("config.integration.mcMMO",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("mcMMO") == null){
|
if(Bukkit.getPluginManager().getPlugin("mcMMO") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize mcMMO!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize mcMMO!");
|
||||||
}else {
|
}else {
|
||||||
skillXP = new mcMMO();
|
skillXP = new mcMMO();
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>mcMMO <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>mcMMO <color:#FFEBCD>Hooked!");
|
||||||
@@ -276,7 +269,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.AureliumSkills",false)){
|
if(config.getBoolean("config.integration.AureliumSkills",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("AureliumSkills") == null){
|
if(Bukkit.getPluginManager().getPlugin("AureliumSkills") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize AureliumSkills!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize AureliumSkills!");
|
||||||
}else {
|
}else {
|
||||||
skillXP = new Aurelium();
|
skillXP = new Aurelium();
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>AureliumSkills <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>AureliumSkills <color:#FFEBCD>Hooked!");
|
||||||
@@ -284,7 +277,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.MMOCore",false)){
|
if(config.getBoolean("config.integration.MMOCore",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("MMOCore") == null){
|
if(Bukkit.getPluginManager().getPlugin("MMOCore") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize MMOCore!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize MMOCore!");
|
||||||
}else {
|
}else {
|
||||||
skillXP = new MMOCore();
|
skillXP = new MMOCore();
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>MMOCore <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>MMOCore <color:#FFEBCD>Hooked!");
|
||||||
@@ -292,7 +285,7 @@ public class ConfigReader {
|
|||||||
}
|
}
|
||||||
if(config.getBoolean("config.integration.EcoSkills",false)){
|
if(config.getBoolean("config.integration.EcoSkills",false)){
|
||||||
if(Bukkit.getPluginManager().getPlugin("EcoSkills") == null){
|
if(Bukkit.getPluginManager().getPlugin("EcoSkills") == null){
|
||||||
CustomCrops.instance.getLogger().warning("Failed to initialize EcoSkills!");
|
CustomCrops.plugin.getLogger().warning("Failed to initialize EcoSkills!");
|
||||||
}else {
|
}else {
|
||||||
skillXP = new EcoSkill();
|
skillXP = new EcoSkill();
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>EcoSkills <color:#FFEBCD>Hooked!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>EcoSkills <color:#FFEBCD>Hooked!");
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public final class CustomCrops extends JavaPlugin {
|
public final class CustomCrops extends JavaPlugin {
|
||||||
|
|
||||||
public static JavaPlugin instance;
|
|
||||||
public static BukkitAudiences adventure;
|
public static BukkitAudiences adventure;
|
||||||
public static CustomCrops plugin;
|
public static CustomCrops plugin;
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ public final class CustomCrops extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad(){
|
public void onLoad(){
|
||||||
instance = this;
|
plugin = this;
|
||||||
LibraryLoader.load("redis.clients","jedis","4.2.3","https://repo.maven.apache.org/maven2/");
|
LibraryLoader.load("redis.clients","jedis","4.2.3","https://repo.maven.apache.org/maven2/");
|
||||||
LibraryLoader.load("org.apache.commons","commons-pool2","2.11.1","https://repo.maven.apache.org/maven2/");
|
LibraryLoader.load("org.apache.commons","commons-pool2","2.11.1","https://repo.maven.apache.org/maven2/");
|
||||||
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/");
|
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/");
|
||||||
@@ -62,8 +61,7 @@ public final class CustomCrops extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
instance = this;
|
adventure = BukkitAudiences.create(plugin);
|
||||||
adventure = BukkitAudiences.create(instance);
|
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>Running on " + Bukkit.getVersion());
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>Running on " + Bukkit.getVersion());
|
||||||
ConfigReader.ReloadConfig();
|
ConfigReader.ReloadConfig();
|
||||||
if(Bukkit.getPluginManager().getPlugin("PlaceHolderAPI") != null){
|
if(Bukkit.getPluginManager().getPlugin("PlaceHolderAPI") != null){
|
||||||
@@ -97,7 +95,7 @@ public final class CustomCrops extends JavaPlugin {
|
|||||||
this.potManager.loadData();
|
this.potManager.loadData();
|
||||||
this.cropTimer = new CropTimer(this);
|
this.cropTimer = new CropTimer(this);
|
||||||
checkIAConfig();
|
checkIAConfig();
|
||||||
if (ConfigReader.Config.version != 1){
|
if (ConfigReader.Config.version != 2){
|
||||||
UpdateConfig.update();
|
UpdateConfig.update();
|
||||||
}
|
}
|
||||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#F5DEB3>Plugin Enabled!");
|
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#F5DEB3>Plugin Enabled!");
|
||||||
@@ -125,7 +123,7 @@ public final class CustomCrops extends JavaPlugin {
|
|||||||
this.seasonManager.saveData();
|
this.seasonManager.saveData();
|
||||||
this.seasonManager = null;
|
this.seasonManager = null;
|
||||||
}
|
}
|
||||||
if (this.placeholders != null){
|
if (placeholders != null){
|
||||||
placeholders.unregister();
|
placeholders.unregister();
|
||||||
placeholders = null;
|
placeholders = null;
|
||||||
}
|
}
|
||||||
@@ -140,8 +138,8 @@ public final class CustomCrops extends JavaPlugin {
|
|||||||
if (adventure != null) {
|
if (adventure != null) {
|
||||||
adventure.close();
|
adventure.close();
|
||||||
}
|
}
|
||||||
if (instance != null) {
|
if (plugin != null) {
|
||||||
instance = null;
|
plugin = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class Executor implements CommandExecutor {
|
|||||||
lackArgs(sender);
|
lackArgs(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.plugin, ()-> {
|
||||||
switch (ConfigReader.Config.growMode){
|
switch (ConfigReader.Config.growMode){
|
||||||
case 1 -> plugin.getCropManager().growModeOne(args[1]);
|
case 1 -> plugin.getCropManager().growModeOne(args[1]);
|
||||||
case 2 -> plugin.getCropManager().growModeTwo(args[1]);
|
case 2 -> plugin.getCropManager().growModeTwo(args[1]);
|
||||||
@@ -86,7 +86,7 @@ public class Executor implements CommandExecutor {
|
|||||||
lackArgs(sender);
|
lackArgs(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.plugin, ()-> {
|
||||||
switch (ConfigReader.Config.growMode){
|
switch (ConfigReader.Config.growMode){
|
||||||
case 1 -> plugin.getSprinklerManager().workModeOne(args[1]);
|
case 1 -> plugin.getSprinklerManager().workModeOne(args[1]);
|
||||||
case 2 -> plugin.getSprinklerManager().workModeTwo(args[1]);
|
case 2 -> plugin.getSprinklerManager().workModeTwo(args[1]);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class CropManager {
|
|||||||
* 载入数据
|
* 载入数据
|
||||||
*/
|
*/
|
||||||
public void loadData() {
|
public void loadData() {
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "crop.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "crop.yml");
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
try {
|
try {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
@@ -72,7 +72,7 @@ public class CropManager {
|
|||||||
* 保存数据
|
* 保存数据
|
||||||
*/
|
*/
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "crop.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "crop.yml");
|
||||||
try{
|
try{
|
||||||
data.save(file);
|
data.save(file);
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
@@ -271,7 +271,7 @@ public class CropManager {
|
|||||||
List<World> worlds = Bukkit.getWorlds();
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
for (int i = 0; i < worlds.size(); i++){
|
for (int i = 0; i < worlds.size(); i++){
|
||||||
String worldName = worlds.get(i).getName();
|
String worldName = worlds.get(i).getName();
|
||||||
bukkitScheduler.runTaskLaterAsynchronously(CustomCrops.instance, () -> {
|
bukkitScheduler.runTaskLaterAsynchronously(CustomCrops.plugin, () -> {
|
||||||
switch (ConfigReader.Config.growMode){
|
switch (ConfigReader.Config.growMode){
|
||||||
case 1 -> growModeOne(worldName);
|
case 1 -> growModeOne(worldName);
|
||||||
case 2 -> growModeTwo(worldName);
|
case 2 -> growModeTwo(worldName);
|
||||||
@@ -321,7 +321,7 @@ public class CropManager {
|
|||||||
if (ConfigReader.Season.enable && cropInstance.getSeasons() != null){
|
if (ConfigReader.Season.enable && cropInstance.getSeasons() != null){
|
||||||
if (isWrongSeason(seedLocation, cropInstance.getSeasons(), worldName)){
|
if (isWrongSeason(seedLocation, cropInstance.getSeasons(), worldName)){
|
||||||
|
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () -> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () -> {
|
||||||
CustomBlock.remove(seedLocation);
|
CustomBlock.remove(seedLocation);
|
||||||
CustomBlock.place(ConfigReader.Basic.dead, seedLocation);
|
CustomBlock.place(ConfigReader.Basic.dead, seedLocation);
|
||||||
}, random);
|
}, random);
|
||||||
@@ -415,7 +415,7 @@ public class CropManager {
|
|||||||
//巨大化判定
|
//巨大化判定
|
||||||
if (cropInstance.getGiantChance() > Math.random()){
|
if (cropInstance.getGiantChance() > Math.random()){
|
||||||
//成功巨大化,移除数据
|
//成功巨大化,移除数据
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () ->{
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () ->{
|
||||||
CustomBlock.remove(seedLocation);
|
CustomBlock.remove(seedLocation);
|
||||||
CustomBlock.place(cropInstance.getGiant(), seedLocation);
|
CustomBlock.place(cropInstance.getGiant(), seedLocation);
|
||||||
CustomBlock.remove(potLocation);
|
CustomBlock.remove(potLocation);
|
||||||
@@ -424,7 +424,7 @@ public class CropManager {
|
|||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
//失败,转湿为干
|
//失败,转湿为干
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () ->{
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () ->{
|
||||||
CustomBlock.remove(potLocation);
|
CustomBlock.remove(potLocation);
|
||||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||||
}, random);
|
}, random);
|
||||||
@@ -433,7 +433,7 @@ public class CropManager {
|
|||||||
}else {
|
}else {
|
||||||
//若无下一阶段,无巨大化,未启用季节,则移除无用数据
|
//若无下一阶段,无巨大化,未启用季节,则移除无用数据
|
||||||
if (!ConfigReader.Season.enable) return true;
|
if (!ConfigReader.Season.enable) return true;
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () -> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () -> {
|
||||||
CustomBlock.remove(potLocation);
|
CustomBlock.remove(potLocation);
|
||||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||||
}, random);
|
}, random);
|
||||||
@@ -448,7 +448,7 @@ public class CropManager {
|
|||||||
if(seasons == null) return false;
|
if(seasons == null) return false;
|
||||||
//错误季节
|
//错误季节
|
||||||
if(isWrongSeason(seedLocation, seasons, worldName)){
|
if(isWrongSeason(seedLocation, seasons, worldName)){
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () -> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () -> {
|
||||||
CustomBlock.remove(seedLocation);
|
CustomBlock.remove(seedLocation);
|
||||||
CustomBlock.place(ConfigReader.Basic.dead, seedLocation);
|
CustomBlock.place(ConfigReader.Basic.dead, seedLocation);
|
||||||
}, new Random().nextInt(ConfigReader.Config.timeToGrow));
|
}, new Random().nextInt(ConfigReader.Config.timeToGrow));
|
||||||
@@ -505,7 +505,7 @@ public class CropManager {
|
|||||||
*/
|
*/
|
||||||
private void addStage(Location potLocation, Location seedLocation, String namespacedID, int nextStage, int random){
|
private void addStage(Location potLocation, Location seedLocation, String namespacedID, int nextStage, int random){
|
||||||
String stage = StringUtils.chop(namespacedID) + nextStage;
|
String stage = StringUtils.chop(namespacedID) + nextStage;
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () ->{
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () ->{
|
||||||
CustomBlock.remove(potLocation);
|
CustomBlock.remove(potLocation);
|
||||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||||
CustomBlock.remove(seedLocation);
|
CustomBlock.remove(seedLocation);
|
||||||
@@ -522,7 +522,7 @@ public class CropManager {
|
|||||||
*/
|
*/
|
||||||
private void addStage(Location seedLocation, String namespacedID, int nextStage, int random){
|
private void addStage(Location seedLocation, String namespacedID, int nextStage, int random){
|
||||||
String stage = StringUtils.chop(namespacedID) + nextStage;
|
String stage = StringUtils.chop(namespacedID) + nextStage;
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () ->{
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () ->{
|
||||||
CustomBlock.remove(seedLocation);
|
CustomBlock.remove(seedLocation);
|
||||||
CustomBlock.place(stage, seedLocation);
|
CustomBlock.place(stage, seedLocation);
|
||||||
}, random);
|
}, random);
|
||||||
@@ -534,7 +534,7 @@ public class CropManager {
|
|||||||
* @param random 随机生长时间
|
* @param random 随机生长时间
|
||||||
*/
|
*/
|
||||||
private void notAddStage(Location potLocation, int random){
|
private void notAddStage(Location potLocation, int random){
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () ->{
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, () ->{
|
||||||
CustomBlock.remove(potLocation);
|
CustomBlock.remove(potLocation);
|
||||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||||
}, random);
|
}, random);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class PotManager {
|
|||||||
* 载入数据
|
* 载入数据
|
||||||
*/
|
*/
|
||||||
public void loadData(){
|
public void loadData(){
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "pot.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "pot.yml");
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
try {
|
try {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
@@ -79,7 +79,7 @@ public class PotManager {
|
|||||||
* 保存数据
|
* 保存数据
|
||||||
*/
|
*/
|
||||||
public void saveData(){
|
public void saveData(){
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "pot.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "pot.yml");
|
||||||
YamlConfiguration data = new YamlConfiguration();
|
YamlConfiguration data = new YamlConfiguration();
|
||||||
Cache.forEach(((location, fertilizer) -> {
|
Cache.forEach(((location, fertilizer) -> {
|
||||||
String world = location.getWorldName();
|
String world = location.getWorldName();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class SeasonManager{
|
|||||||
*/
|
*/
|
||||||
public void loadData() {
|
public void loadData() {
|
||||||
SEASON.clear();
|
SEASON.clear();
|
||||||
YamlConfiguration data = readData(new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "season.yml"));
|
YamlConfiguration data = readData(new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "season.yml"));
|
||||||
if (ConfigReader.Season.seasonChange) {
|
if (ConfigReader.Season.seasonChange) {
|
||||||
autoSeason();
|
autoSeason();
|
||||||
} else {
|
} else {
|
||||||
@@ -95,7 +95,7 @@ public class SeasonManager{
|
|||||||
*/
|
*/
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
SEASON.forEach((key, value) -> {
|
SEASON.forEach((key, value) -> {
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "season.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "season.yml");
|
||||||
YamlConfiguration data = readData(file);
|
YamlConfiguration data = readData(file);
|
||||||
data.set(key, value);
|
data.set(key, value);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class SprinklerManager {
|
|||||||
* 载入数据
|
* 载入数据
|
||||||
*/
|
*/
|
||||||
public void loadData() {
|
public void loadData() {
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "sprinkler.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "sprinkler.yml");
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
try {
|
try {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
@@ -67,7 +67,7 @@ public class SprinklerManager {
|
|||||||
* 保存数据
|
* 保存数据
|
||||||
*/
|
*/
|
||||||
public void saveData(){
|
public void saveData(){
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "sprinkler.yml");
|
File file = new File(CustomCrops.plugin.getDataFolder(), "data" + File.separator + "sprinkler.yml");
|
||||||
try{
|
try{
|
||||||
data.save(file);
|
data.save(file);
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
@@ -133,7 +133,7 @@ public class SprinklerManager {
|
|||||||
if (value instanceof MemorySection map){
|
if (value instanceof MemorySection map){
|
||||||
String[] coordinate = StringUtils.split(key, ",");
|
String[] coordinate = StringUtils.split(key, ",");
|
||||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||||
bukkitScheduler.runTask(CustomCrops.instance, ()->{
|
bukkitScheduler.runTask(CustomCrops.plugin, ()->{
|
||||||
int water = (int) map.get("water");
|
int water = (int) map.get("water");
|
||||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||||
if(!IAFurniture.getFromLocation(location, world)){
|
if(!IAFurniture.getFromLocation(location, world)){
|
||||||
@@ -142,7 +142,7 @@ public class SprinklerManager {
|
|||||||
}
|
}
|
||||||
if (water > 0){
|
if (water > 0){
|
||||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, ()-> {
|
||||||
for(int i = -range; i <= range; i++){
|
for(int i = -range; i <= range; i++){
|
||||||
for (int j = -range; j <= range; j++){
|
for (int j = -range; j <= range; j++){
|
||||||
waterPot(location.clone().add(i,-1,j));
|
waterPot(location.clone().add(i,-1,j));
|
||||||
@@ -192,12 +192,12 @@ public class SprinklerManager {
|
|||||||
if (!players.contains(player)) return;
|
if (!players.contains(player)) return;
|
||||||
String[] coordinate = StringUtils.split(key, ",");
|
String[] coordinate = StringUtils.split(key, ",");
|
||||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||||
bukkitScheduler.callSyncMethod(CustomCrops.instance, ()->{
|
bukkitScheduler.callSyncMethod(CustomCrops.plugin, ()->{
|
||||||
int water = (int) map.get("water");
|
int water = (int) map.get("water");
|
||||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||||
if (water > 0){
|
if (water > 0){
|
||||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, ()-> {
|
||||||
for(int i = -range; i <= range; i++){
|
for(int i = -range; i <= range; i++){
|
||||||
for (int j = -range; j <= range; j++){
|
for (int j = -range; j <= range; j++){
|
||||||
waterPot(location.clone().add(i,-1,j));
|
waterPot(location.clone().add(i,-1,j));
|
||||||
@@ -245,14 +245,14 @@ public class SprinklerManager {
|
|||||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||||
String[] coordinate = StringUtils.split(key, ",");
|
String[] coordinate = StringUtils.split(key, ",");
|
||||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||||
bukkitScheduler.runTask(CustomCrops.instance, ()->{
|
bukkitScheduler.runTask(CustomCrops.plugin, ()->{
|
||||||
if(!IAFurniture.getFromLocation(location, world)){
|
if(!IAFurniture.getFromLocation(location, world)){
|
||||||
data.set(worldName + "." + chunk + "." + key, null);
|
data.set(worldName + "." + chunk + "." + key, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (water > 0){
|
if (water > 0){
|
||||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, ()-> {
|
||||||
for(int i = -range; i <= range; i++){
|
for(int i = -range; i <= range; i++){
|
||||||
for (int j = -range; j <= range; j++){
|
for (int j = -range; j <= range; j++){
|
||||||
waterPot(location.clone().add(i,-1,j));
|
waterPot(location.clone().add(i,-1,j));
|
||||||
@@ -280,7 +280,7 @@ public class SprinklerManager {
|
|||||||
String[] coordinate = StringUtils.split(key, ",");
|
String[] coordinate = StringUtils.split(key, ",");
|
||||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, ()-> {
|
||||||
for(int i = -range; i <= range; i++){
|
for(int i = -range; i <= range; i++){
|
||||||
for (int j = -range; j <= range; j++){
|
for (int j = -range; j <= range; j++){
|
||||||
waterPot(location.clone().add(i,-1,j));
|
waterPot(location.clone().add(i,-1,j));
|
||||||
@@ -325,7 +325,7 @@ public class SprinklerManager {
|
|||||||
String[] coordinate = StringUtils.split(key, ",");
|
String[] coordinate = StringUtils.split(key, ",");
|
||||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
bukkitScheduler.runTaskLater(CustomCrops.plugin, ()-> {
|
||||||
for(int i = -range; i <= range; i++){
|
for(int i = -range; i <= range; i++){
|
||||||
for (int j = -range; j <= range; j++){
|
for (int j = -range; j <= range; j++){
|
||||||
waterPot(location.clone().add(i,-1,j));
|
waterPot(location.clone().add(i,-1,j));
|
||||||
@@ -356,7 +356,7 @@ public class SprinklerManager {
|
|||||||
List<World> worlds = Bukkit.getWorlds();
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
for (int i = 0; i < worlds.size(); i++){
|
for (int i = 0; i < worlds.size(); i++){
|
||||||
String worldName = worlds.get(i).getName();
|
String worldName = worlds.get(i).getName();
|
||||||
bukkitScheduler.runTaskLaterAsynchronously(CustomCrops.instance, () -> {
|
bukkitScheduler.runTaskLaterAsynchronously(CustomCrops.plugin, () -> {
|
||||||
switch (ConfigReader.Config.growMode){
|
switch (ConfigReader.Config.growMode){
|
||||||
case 1 -> workModeOne(worldName);
|
case 1 -> workModeOne(worldName);
|
||||||
case 2 -> workModeTwo(worldName);
|
case 2 -> workModeTwo(worldName);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import java.util.Objects;
|
|||||||
public final class LibraryLoader {
|
public final class LibraryLoader {
|
||||||
|
|
||||||
@SuppressWarnings("Guava")
|
@SuppressWarnings("Guava")
|
||||||
private static final Supplier<URLClassLoaderAccess> URL_INJECTOR = Suppliers.memoize(() -> URLClassLoaderAccess.create((URLClassLoader) CustomCrops.instance.getClass().getClassLoader()));
|
private static final Supplier<URLClassLoaderAccess> URL_INJECTOR = Suppliers.memoize(() -> URLClassLoaderAccess.create((URLClassLoader) CustomCrops.plugin.getClass().getClassLoader()));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves all {@link MavenLibrary} annotations on the given object.
|
* Resolves all {@link MavenLibrary} annotations on the given object.
|
||||||
@@ -111,7 +111,7 @@ public final class LibraryLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static File getLibFolder(Dependency dependency) {
|
private static File getLibFolder(Dependency dependency) {
|
||||||
File pluginDataFolder = CustomCrops.instance.getDataFolder();
|
File pluginDataFolder = CustomCrops.plugin.getDataFolder();
|
||||||
File serverDir = pluginDataFolder.getParentFile().getParentFile();
|
File serverDir = pluginDataFolder.getParentFile().getParentFile();
|
||||||
|
|
||||||
File helperDir = new File(serverDir, "libraries");
|
File helperDir = new File(serverDir, "libraries");
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ import javax.annotation.Nonnull;
|
|||||||
public final class Log {
|
public final class Log {
|
||||||
|
|
||||||
public static void info(@Nonnull String s) {
|
public static void info(@Nonnull String s) {
|
||||||
CustomCrops.instance.getLogger().info(s);
|
CustomCrops.plugin.getLogger().info(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(@Nonnull String s) {
|
public static void warn(@Nonnull String s) {
|
||||||
CustomCrops.instance.getLogger().warning(s);
|
CustomCrops.plugin.getLogger().warning(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void severe(@Nonnull String s) {
|
public static void severe(@Nonnull String s) {
|
||||||
CustomCrops.instance.getLogger().severe(s);
|
CustomCrops.plugin.getLogger().severe(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(@Nonnull String s, Throwable t) {
|
public static void warn(@Nonnull String s, Throwable t) {
|
||||||
CustomCrops.instance.getLogger().log(Level.WARNING, s, t);
|
CustomCrops.plugin.getLogger().log(Level.WARNING, s, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void severe(@Nonnull String s, Throwable t) {
|
public static void severe(@Nonnull String s, Throwable t) {
|
||||||
CustomCrops.instance.getLogger().log(Level.SEVERE, s, t);
|
CustomCrops.plugin.getLogger().log(Level.SEVERE, s, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Log() {
|
private Log() {
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.protection;
|
||||||
|
|
||||||
|
import net.crashcraft.crashclaim.api.CrashClaimAPI;
|
||||||
|
import net.crashcraft.crashclaim.permissions.PermissionRoute;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CrashClaim implements Integration{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBreak(Location location, Player player) {
|
||||||
|
CrashClaimAPI crashClaimAPI = net.crashcraft.crashclaim.CrashClaim.getPlugin().getApi();
|
||||||
|
return crashClaimAPI.getPermissionHelper().hasPermission(player.getUniqueId(), location, PermissionRoute.BUILD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlace(Location location, Player player) {
|
||||||
|
CrashClaimAPI crashClaimAPI = net.crashcraft.crashclaim.CrashClaim.getPlugin().getApi();
|
||||||
|
return crashClaimAPI.getPermissionHelper().hasPermission(player.getUniqueId(), location, PermissionRoute.BUILD);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@ public class Lands implements Integration{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreak(Location location, Player player) {
|
public boolean canBreak(Location location, Player player) {
|
||||||
Area area = new LandsIntegration(CustomCrops.instance).getAreaByLoc(location);
|
Area area = new LandsIntegration(CustomCrops.plugin).getAreaByLoc(location);
|
||||||
if (area != null){
|
if (area != null){
|
||||||
return area.hasFlag(player, Flags.BLOCK_BREAK, false);
|
return area.hasFlag(player, Flags.BLOCK_BREAK, false);
|
||||||
}else {
|
}else {
|
||||||
@@ -38,7 +38,7 @@ public class Lands implements Integration{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlace(Location location, Player player) {
|
public boolean canPlace(Location location, Player player) {
|
||||||
Area area = new LandsIntegration(CustomCrops.instance).getAreaByLoc(location);
|
Area area = new LandsIntegration(CustomCrops.plugin).getAreaByLoc(location);
|
||||||
if (area != null){
|
if (area != null){
|
||||||
return area.hasFlag(player, Flags.BLOCK_PLACE, false);
|
return area.hasFlag(player, Flags.BLOCK_PLACE, false);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class BreakBlock implements Listener {
|
|||||||
String[] cropNameList = StringUtils.split(StringUtils.split(namespacedId, ":")[1], "_");
|
String[] cropNameList = StringUtils.split(StringUtils.split(namespacedId, ":")[1], "_");
|
||||||
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) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.plugin, ()-> {
|
||||||
if (location.getBlock().getType() != Material.AIR) return;
|
if (location.getBlock().getType() != Material.AIR) return;
|
||||||
CropInstance cropInstance = ConfigReader.CROPS.get(cropNameList[0]);
|
CropInstance cropInstance = ConfigReader.CROPS.get(cropNameList[0]);
|
||||||
ThreadLocalRandom current = ThreadLocalRandom.current();
|
ThreadLocalRandom current = ThreadLocalRandom.current();
|
||||||
@@ -77,7 +77,7 @@ public class BreakBlock implements Listener {
|
|||||||
Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(location.clone().subtract(0,1,0)));
|
Fertilizer fertilizer = PotManager.Cache.get(SimpleLocation.fromLocation(location.clone().subtract(0,1,0)));
|
||||||
List<String> commands = cropInstance.getCommands();
|
List<String> commands = cropInstance.getCommands();
|
||||||
if (commands != null){
|
if (commands != null){
|
||||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().callSyncMethod(CustomCrops.plugin, ()-> {
|
||||||
for (String command : commands){
|
for (String command : commands){
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()));
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()));
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class BreakBlock implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ConfigReader.Config.skillXP != null && cropInstance.getSkillXP() != 0){
|
if (ConfigReader.Config.skillXP != null && cropInstance.getSkillXP() != 0){
|
||||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().callSyncMethod(CustomCrops.plugin, ()-> {
|
||||||
ConfigReader.Config.skillXP.addXp(player, cropInstance.getSkillXP());
|
ConfigReader.Config.skillXP.addXp(player, cropInstance.getSkillXP());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -96,7 +96,7 @@ public class BreakBlock implements Listener {
|
|||||||
double weightTotal = weights[0] + weights[1] + weights[2];
|
double weightTotal = weights[0] + weights[1] + weights[2];
|
||||||
double rank_1 = weights[0]/(weightTotal);
|
double rank_1 = weights[0]/(weightTotal);
|
||||||
double rank_2 = 1 - weights[1]/(weightTotal);
|
double rank_2 = 1 - weights[1]/(weightTotal);
|
||||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().callSyncMethod(CustomCrops.plugin, ()-> {
|
||||||
for (int i = 0; i < random; i++){
|
for (int i = 0; i < random; i++){
|
||||||
double ran = Math.random();
|
double ran = Math.random();
|
||||||
if (ran < rank_1){
|
if (ran < rank_1){
|
||||||
@@ -111,13 +111,13 @@ public class BreakBlock implements Listener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().callSyncMethod(CustomCrops.plugin, ()-> {
|
||||||
normalDrop(cropInstance, random, itemLoc, world);
|
normalDrop(cropInstance, random, itemLoc, world);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.instance, ()-> {
|
Bukkit.getScheduler().callSyncMethod(CustomCrops.plugin, ()-> {
|
||||||
normalDrop(cropInstance, random, itemLoc, world);
|
normalDrop(cropInstance, random, itemLoc, world);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ public class CropTimer {
|
|||||||
TimeCheck tc = new TimeCheck(plugin);
|
TimeCheck tc = new TimeCheck(plugin);
|
||||||
BukkitTask task;
|
BukkitTask task;
|
||||||
if (ConfigReader.Config.asyncCheck){
|
if (ConfigReader.Config.asyncCheck){
|
||||||
task = tc.runTaskTimerAsynchronously(CustomCrops.instance, 1,1);
|
task = tc.runTaskTimerAsynchronously(CustomCrops.plugin, 1,1);
|
||||||
}else {
|
}else {
|
||||||
task = tc.runTaskTimer(CustomCrops.instance, 1,1);
|
task = tc.runTaskTimer(CustomCrops.plugin, 1,1);
|
||||||
}
|
}
|
||||||
this.taskID = task.getTaskId();
|
this.taskID = task.getTaskId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ public class TimeCheck extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
if(time == cropGrowTime){
|
if(time == cropGrowTime){
|
||||||
if (ConfigReader.Config.allWorld){
|
if (ConfigReader.Config.allWorld){
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.instance, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.plugin, () -> {
|
||||||
plugin.getCropManager().cropGrowAll();
|
plugin.getCropManager().cropGrowAll();
|
||||||
});
|
});
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.instance, ()->{
|
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.plugin, ()->{
|
||||||
plugin.getSprinklerManager().sprinklerWorkAll();
|
plugin.getSprinklerManager().sprinklerWorkAll();
|
||||||
}, ConfigReader.Config.timeToGrow);
|
}, ConfigReader.Config.timeToGrow);
|
||||||
}else {
|
}else {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.instance, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.plugin, () -> {
|
||||||
switch (ConfigReader.Config.growMode){
|
switch (ConfigReader.Config.growMode){
|
||||||
case 1 -> plugin.getCropManager().growModeOne(world.getName());
|
case 1 -> plugin.getCropManager().growModeOne(world.getName());
|
||||||
case 2 -> plugin.getCropManager().growModeTwo(world.getName());
|
case 2 -> plugin.getCropManager().growModeTwo(world.getName());
|
||||||
@@ -56,7 +56,7 @@ public class TimeCheck extends BukkitRunnable {
|
|||||||
case 4 -> plugin.getCropManager().growModeFour(world.getName());
|
case 4 -> plugin.getCropManager().growModeFour(world.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.instance, ()->{
|
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.plugin, ()->{
|
||||||
switch (ConfigReader.Config.growMode){
|
switch (ConfigReader.Config.growMode){
|
||||||
case 1 -> plugin.getSprinklerManager().workModeOne(world.getName());
|
case 1 -> plugin.getSprinklerManager().workModeOne(world.getName());
|
||||||
case 2 -> plugin.getSprinklerManager().workModeTwo(world.getName());
|
case 2 -> plugin.getSprinklerManager().workModeTwo(world.getName());
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ public class BackUp {
|
|||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||||
|
|
||||||
files.forEach(fileName -> {
|
files.forEach(fileName -> {
|
||||||
File data = new File(CustomCrops.instance.getDataFolder(), "data"+ File.separatorChar + fileName + ".yml");
|
File data = new File(CustomCrops.plugin.getDataFolder(), "data"+ File.separatorChar + fileName + ".yml");
|
||||||
File backUp = new File(CustomCrops.instance.getDataFolder(), "backups"+ File.separatorChar + format.format(date) + File.separatorChar + fileName + ".yml");
|
File backUp = new File(CustomCrops.plugin.getDataFolder(), "backups"+ File.separatorChar + format.format(date) + File.separatorChar + fileName + ".yml");
|
||||||
try {
|
try {
|
||||||
BackUp.backUp(data, backUp);
|
BackUp.backUp(data, backUp);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
CustomCrops.instance.getLogger().warning(fileName + ".yml备份出错!");
|
CustomCrops.plugin.getLogger().warning(fileName + ".yml备份出错!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class HoloUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(CustomCrops.instance, ()->{
|
Bukkit.getScheduler().runTaskLater(CustomCrops.plugin, ()->{
|
||||||
removeHolo(player, id);
|
removeHolo(player, id);
|
||||||
cache.remove(location);
|
cache.remove(location);
|
||||||
}, duration * 20L);
|
}, duration * 20L);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class JedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void addPlayer(String player){
|
public static void addPlayer(String player){
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.instance, ()->{
|
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.plugin, ()->{
|
||||||
Jedis jedis = getJedis();
|
Jedis jedis = getJedis();
|
||||||
jedis.sadd("cc_players", player);
|
jedis.sadd("cc_players", player);
|
||||||
jedis.close();
|
jedis.close();
|
||||||
@@ -69,7 +69,7 @@ public class JedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void remPlayer(String player){
|
public static void remPlayer(String player){
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.instance, ()->{
|
Bukkit.getScheduler().runTaskAsynchronously(CustomCrops.plugin, ()->{
|
||||||
Jedis jedis = getJedis();
|
Jedis jedis = getJedis();
|
||||||
jedis.srem("cc_players", player);
|
jedis.srem("cc_players", player);
|
||||||
jedis.close();
|
jedis.close();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Don't change
|
#Don't change
|
||||||
config-version: 1
|
config-version: 2
|
||||||
config:
|
config:
|
||||||
#=============================================================#
|
#=============================================================#
|
||||||
#english spanish chinese
|
#english spanish chinese
|
||||||
@@ -15,6 +15,7 @@ config:
|
|||||||
Towny: false
|
Towny: false
|
||||||
Lands: false
|
Lands: false
|
||||||
GriefPrevention: false
|
GriefPrevention: false
|
||||||
|
CrashClaim: false
|
||||||
#integration to add players' farming skill xp
|
#integration to add players' farming skill xp
|
||||||
AureliumSkills: false
|
AureliumSkills: false
|
||||||
mcMMO: false
|
mcMMO: false
|
||||||
@@ -26,10 +27,11 @@ config:
|
|||||||
#Mode 2:
|
#Mode 2:
|
||||||
# Online players' crops will grow
|
# Online players' crops will grow
|
||||||
#Mode 3:
|
#Mode 3:
|
||||||
|
# Recommended
|
||||||
# Mode 1 + Mode 2
|
# Mode 1 + Mode 2
|
||||||
#Mode 4:
|
#Mode 4:
|
||||||
# No support in this mode! Please disable season in this mode!
|
# Please disable season in this mode!
|
||||||
# All the crops will grow (May cause lag)
|
# All the crops will grow
|
||||||
grow-mode: 3
|
grow-mode: 3
|
||||||
#The time to start growing(ticks)
|
#The time to start growing(ticks)
|
||||||
#1000ticks is 7am in game. (0-23999)
|
#1000ticks is 7am in game. (0-23999)
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ softdepend:
|
|||||||
- AureliumSkills
|
- AureliumSkills
|
||||||
- MMOCore
|
- MMOCore
|
||||||
- EcoSkills
|
- EcoSkills
|
||||||
|
- CrashClaim
|
||||||
commands:
|
commands:
|
||||||
customcrops:
|
customcrops:
|
||||||
usage: /customcrops <args>
|
usage: /customcrops <args>
|
||||||
permission: customcrops.admin
|
permission: customcrops.admin
|
||||||
|
aliases:
|
||||||
|
- ccrops
|
||||||
Reference in New Issue
Block a user