mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
1.5.25
This commit is contained in:
@@ -40,6 +40,7 @@ public final class CustomCrops extends JavaPlugin {
|
||||
|
||||
public static JavaPlugin instance;
|
||||
public static BukkitAudiences adventure;
|
||||
public static CustomCrops plugin;
|
||||
|
||||
private CropTimer cropTimer;
|
||||
private CropManager cropManager;
|
||||
@@ -64,6 +65,8 @@ public final class CustomCrops extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
|
||||
instance = this;
|
||||
adventure = BukkitAudiences.create(instance);
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.momirealms.customcrops.api;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.datamanager.SeasonManager;
|
||||
|
||||
public class CustomCropsAPI {
|
||||
|
||||
/**
|
||||
* 获取插件实例
|
||||
* @return 插件实例
|
||||
*/
|
||||
public static CustomCrops getPlugin(){
|
||||
return CustomCrops.plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定世界的季节
|
||||
* @param worldName 世界名
|
||||
* @return 那个世界的季节,若不存在则返回null
|
||||
*/
|
||||
public static String getSeason(String worldName){
|
||||
return SeasonManager.SEASON.get(worldName);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,27 +37,58 @@ public class Completer implements TabCompleter {
|
||||
return null;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
return Arrays.asList("backup", "forcegrow", "forcesave", "forcewater", "reload", "setseason");
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
for (String cmd : Arrays.asList("backup", "forcegrow", "forcesave", "forcewater", "reload", "setseason")) {
|
||||
if (cmd.startsWith(args[0]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("setseason") && args.length == 2){
|
||||
return ConfigReader.Config.worldNames;
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
for (String cmd : ConfigReader.Config.worldNames) {
|
||||
if (cmd.startsWith(args[1]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("forcesave") && args.length == 2){
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
if (ConfigReader.Season.enable){
|
||||
if (ConfigReader.Season.seasonChange){
|
||||
return Arrays.asList("all","crop","pot","sprinkler");
|
||||
for (String cmd : Arrays.asList("all","crop","pot","sprinkler")) {
|
||||
if (cmd.startsWith(args[1]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
}else{
|
||||
return Arrays.asList("all","crop","pot","season","sprinkler");
|
||||
for (String cmd : Arrays.asList("all","crop","pot","season","sprinkler")) {
|
||||
if (cmd.startsWith(args[1]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return Arrays.asList("all","crop","pot","sprinkler");
|
||||
for (String cmd : Arrays.asList("all","crop","pot","sprinkler")) {
|
||||
if (cmd.startsWith(args[1]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("setseason") && args.length == 3){
|
||||
return Arrays.asList("spring","summer","autumn","winter");
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
for (String cmd : Arrays.asList("spring","summer","autumn","winter")) {
|
||||
if (cmd.startsWith(args[2]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("forcegrow") || args[0].equalsIgnoreCase("forcewater")){
|
||||
return ConfigReader.Config.worldNames;
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
for (String cmd : ConfigReader.Config.worldNames) {
|
||||
if (cmd.startsWith(args[1]))
|
||||
arrayList.add(cmd);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ public class Executor implements CommandExecutor {
|
||||
case "cleandata" -> {
|
||||
plugin.getCropManager().cleanData();
|
||||
plugin.getSprinklerManager().cleanData();
|
||||
return true;
|
||||
}
|
||||
case "setseason" -> {
|
||||
if (args.length < 3) {
|
||||
|
||||
Reference in New Issue
Block a user