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.BackUp;
|
||||||
import net.momirealms.customcrops.DataManager.CropManager;
|
import net.momirealms.customcrops.DataManager.CropManager;
|
||||||
|
import net.momirealms.customcrops.DataManager.NextSeason;
|
||||||
import net.momirealms.customcrops.DataManager.SprinklerManager;
|
import net.momirealms.customcrops.DataManager.SprinklerManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -9,6 +10,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.kingdoms.data.DataManager;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.Objects;
|
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());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class CommandTabComplete implements TabCompleter {
|
|||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public @Nullable List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public @Nullable List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
if (args.length == 1) {
|
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")){
|
if(args[0].equalsIgnoreCase("setseason")){
|
||||||
return Arrays.asList("spring","summer","autumn","winter");
|
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")){
|
if (CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().endsWith("_seeds")){
|
||||||
String namespaced_id = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase();
|
String namespaced_id = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase();
|
||||||
String[] crop = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().replace("_seeds","").split(":");
|
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")){
|
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);
|
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.not-a-good-place"),player);
|
||||||
@@ -193,11 +198,7 @@ public class RightClickCustomBlock implements Listener {
|
|||||||
return;
|
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)){
|
if(MaxCropsPerChunk.maxCropsPerChunk(clickedBlockLocation)){
|
||||||
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.reach-limit-crop").replace("{Max}", config.getString("config.max-crops")),player);
|
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.reach-limit-crop").replace("{Max}", config.getString("config.max-crops")),player);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ messages:
|
|||||||
no-such-seed: 此种子未在配置文件中配置!
|
no-such-seed: 此种子未在配置文件中配置!
|
||||||
wrong-season: 这个季节不适合这种农作物生长!
|
wrong-season: 这个季节不适合这种农作物生长!
|
||||||
season-set: 成功设置季节为{Season}
|
season-set: 成功设置季节为{Season}
|
||||||
|
nextseason: 已切换到下一季节!
|
||||||
season-disabled: 季节系统未启用.
|
season-disabled: 季节系统未启用.
|
||||||
clean-cache: 无效农作物和洒水器数据清除完毕!
|
clean-cache: 无效农作物和洒水器数据清除完毕!
|
||||||
reach-limit-crop: 农作物已到达最大区块上限{Max}!
|
reach-limit-crop: 农作物已到达最大区块上限{Max}!
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: CustomCrops
|
name: CustomCrops
|
||||||
version: '1.2'
|
version: '1.2.2'
|
||||||
main: net.momirealms.customcrops.CustomCrops
|
main: net.momirealms.customcrops.CustomCrops
|
||||||
api-version: 1.18
|
api-version: 1.18
|
||||||
depend: [ ItemsAdder , ProtocolLib ]
|
depend: [ ItemsAdder , ProtocolLib ]
|
||||||
|
|||||||
Reference in New Issue
Block a user