9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-26 02:19:28 +00:00

sync date

This commit is contained in:
XiaoMoMi
2024-03-22 18:08:07 +08:00
parent f5119b675d
commit b2843b6516
4 changed files with 35 additions and 5 deletions

View File

@@ -50,7 +50,7 @@ public class InBuiltSeason implements SeasonInterface {
return 0;
return worldManager
.getCustomCropsWorld(world)
.map(cropsWorld -> cropsWorld.getInfoData().getDate())
.map(CustomCropsWorld::getDate)
.orElse(0);
}

View File

@@ -126,7 +126,11 @@ public class CommandManager implements Initable {
return new CommandAPICommand("date")
.withSubcommands(
new CommandAPICommand("get")
.withArguments(new StringArgument("world").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> Bukkit.getWorlds().stream().map(WorldInfo::getName).toList().toArray(new String[0]))))
.withArguments(new StringArgument("world").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getWorldManager().getCustomCropsWorlds().stream()
.filter(customCropsWorld -> customCropsWorld.getWorldSetting().isEnableSeason())
.map(CustomCropsWorld::getWorldName)
.toList()
.toArray(new String[0]))))
.executes((sender, args) -> {
String worldName = (String) args.get("world");
World world = Bukkit.getWorld(worldName);
@@ -137,7 +141,11 @@ public class CommandManager implements Initable {
plugin.getAdventure().sendMessageWithPrefix(sender, String.valueOf(plugin.getIntegrationManager().getDate(world)));
}),
new CommandAPICommand("set")
.withArguments(new StringArgument("world").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> Bukkit.getWorlds().stream().map(WorldInfo::getName).toList().toArray(new String[0]))))
.withArguments(new StringArgument("world").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getWorldManager().getCustomCropsWorlds().stream()
.filter(customCropsWorld -> customCropsWorld.getWorldSetting().isEnableSeason())
.map(CustomCropsWorld::getWorldName)
.toList()
.toArray(new String[0]))))
.withArguments(new IntegerArgument("date",1))
.executes((sender, args) -> {
String worldName = (String) args.get("world");
@@ -176,7 +184,11 @@ public class CommandManager implements Initable {
return new CommandAPICommand("season")
.withSubcommands(
new CommandAPICommand("get")
.withArguments(new StringArgument("world").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> Bukkit.getWorlds().stream().map(WorldInfo::getName).toList().toArray(new String[0]))))
.withArguments(new StringArgument("world").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getWorldManager().getCustomCropsWorlds().stream()
.filter(customCropsWorld -> customCropsWorld.getWorldSetting().isEnableSeason())
.map(CustomCropsWorld::getWorldName)
.toList()
.toArray(new String[0]))))
.executes((sender, args) -> {
String worldName = (String) args.get("world");
World world = Bukkit.getWorld(worldName);
@@ -191,7 +203,11 @@ public class CommandManager implements Initable {
if (ConfigManager.syncSeasons()) {
return new String[]{ConfigManager.referenceWorld().getName()};
}
return Bukkit.getWorlds().stream().map(WorldInfo::getName).toList().toArray(new String[0]);
return plugin.getWorldManager().getCustomCropsWorlds().stream()
.filter(customCropsWorld -> customCropsWorld.getWorldSetting().isEnableSeason())
.map(CustomCropsWorld::getWorldName)
.toList()
.toArray(new String[0]);
})))
.withArguments(new StringArgument("season")
.replaceSuggestions(ArgumentSuggestions.stringsWithTooltips(info ->

View File

@@ -259,6 +259,18 @@ public class CWorld implements CustomCropsWorld {
return infoData;
}
@Override
public int getDate() {
if (setting.isEnableSeason()) {
if (ConfigManager.syncSeasons() && ConfigManager.referenceWorld() != world) {
return worldManager.getCustomCropsWorld(ConfigManager.referenceWorld()).map(customCropsWorld -> customCropsWorld.getInfoData().getDate()).orElse(0);
}
return infoData.getDate();
} else {
return 0;
}
}
@Override
@Nullable
public Season getSeason() {