mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 18:09:28 +00:00
sync date
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user