mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
nextseason & bug fix
This commit is contained in:
@@ -2,6 +2,7 @@ package net.momirealms.customcrops;
|
||||
|
||||
import net.momirealms.customcrops.DataManager.BackUp;
|
||||
import net.momirealms.customcrops.DataManager.CropManager;
|
||||
import net.momirealms.customcrops.DataManager.NextSeason;
|
||||
import net.momirealms.customcrops.DataManager.SprinklerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -9,6 +10,7 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kingdoms.data.DataManager;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Objects;
|
||||
@@ -91,6 +93,14 @@ public class CommandHandler implements CommandExecutor {
|
||||
MessageManager.consoleMessage(config.getString("messages.prefix") + config.getString("messages.backup"), Bukkit.getConsoleSender());
|
||||
}
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("nextseason")){
|
||||
NextSeason.changeSeason();
|
||||
if(sender instanceof Player){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.nextseason"), (Player) sender);
|
||||
}else {
|
||||
MessageManager.consoleMessage(config.getString("messages.prefix") + config.getString("messages.nextseason"), Bukkit.getConsoleSender());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class CommandTabComplete implements TabCompleter {
|
||||
@ParametersAreNonnullByDefault
|
||||
public @Nullable List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Arrays.asList("backup" , "cleancache", "forcesave", "reload", "setseason");
|
||||
return Arrays.asList("backup" , "cleancache", "forcesave", "reload", "setseason" , "nextseason");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("setseason")){
|
||||
return Arrays.asList("spring","summer","autumn","winter");
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.momirealms.customcrops.DataManager;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class NextSeason {
|
||||
public static void changeSeason(){
|
||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||
String currentSeason = config.getString("current-season");
|
||||
String nextSeason = switch (Objects.requireNonNull(currentSeason)) {
|
||||
case "spring" -> "summer";
|
||||
case "summer" -> "autumn";
|
||||
case "autumn" -> "winter";
|
||||
case "winter" -> "spring";
|
||||
default -> null;
|
||||
};
|
||||
config.set("current-season", nextSeason);
|
||||
CustomCrops.instance.saveConfig();
|
||||
}
|
||||
}
|
||||
@@ -163,6 +163,11 @@ public class RightClickCustomBlock implements Listener {
|
||||
if (CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().endsWith("_seeds")){
|
||||
String namespaced_id = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase();
|
||||
String[] crop = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().replace("_seeds","").split(":");
|
||||
//该种子是否存在于配置文件中
|
||||
if(!config.getConfigurationSection("crops").getKeys(false).contains(crop[1])){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.no-such-seed"),player);
|
||||
return;
|
||||
}
|
||||
//是否超高超低
|
||||
if (clickedBlockLocation.getY() < config.getInt("config.height.min") || clickedBlockLocation.getY() > config.getInt("config.height.max")){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.not-a-good-place"),player);
|
||||
@@ -193,11 +198,7 @@ public class RightClickCustomBlock implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//该种子是否存在于配置文件中
|
||||
if(!config.contains("crops."+crop[1])){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.no-such-seed"),player);
|
||||
return;
|
||||
}
|
||||
|
||||
//是否到达区块上限
|
||||
if(MaxCropsPerChunk.maxCropsPerChunk(clickedBlockLocation)){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.reach-limit-crop").replace("{Max}", config.getString("config.max-crops")),player);
|
||||
|
||||
Reference in New Issue
Block a user