From a6f4f2d2d5b6f69d50cb3c3d58d32cc64f9d2725 Mon Sep 17 00:00:00 2001 From: Zax71 Date: Sat, 24 Feb 2024 12:26:05 +0000 Subject: [PATCH 01/11] Add /mv who and /mv whoall --- .../multiverse/core/commands/WhoCommand.java | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java new file mode 100644 index 00000000..5eb03131 --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java @@ -0,0 +1,145 @@ +package org.mvplugins.multiverse.core.commands; + +import co.aikar.commands.InvalidCommandArgument; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandCompletion; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Optional; +import co.aikar.commands.annotation.Subcommand; +import co.aikar.commands.annotation.Syntax; +import jakarta.inject.Inject; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jvnet.hk2.annotations.Service; +import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; +import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; +import org.mvplugins.multiverse.core.commandtools.MVCommandManager; +import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag; +import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; +import org.mvplugins.multiverse.core.display.ContentDisplay; +import org.mvplugins.multiverse.core.display.filters.ContentFilter; +import org.mvplugins.multiverse.core.display.filters.DefaultContentFilter; +import org.mvplugins.multiverse.core.display.filters.RegexContentFilter; +import org.mvplugins.multiverse.core.display.handlers.PagedSendHandler; +import org.mvplugins.multiverse.core.display.parsers.MapContentProvider; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.WorldManager; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +@Service +@CommandAlias("mv") +public class WhoCommand extends MultiverseCommand { + + private final WorldManager worldManager; + + private final CommandValueFlag PAGE_FLAG = flag(CommandValueFlag + .builder("--page", Integer.class) + .addAlias("-p") + .context(value -> { + try { + return Integer.parseInt(value); + } catch (NumberFormatException e) { + throw new InvalidCommandArgument("Invalid page number: " + value); + } + }) + .build()); + + private final CommandValueFlag FILTER_FLAG = flag(CommandValueFlag + .builder("--filter", ContentFilter.class) + .addAlias("-f") + .context(value -> { + try { + return RegexContentFilter.fromString(value); + } catch (IllegalArgumentException e) { + throw new InvalidCommandArgument("Invalid filter: " + value); + } + }) + .build()); + + @Inject + WhoCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + super(commandManager); + this.worldManager = worldManager; + } + + @Subcommand("whoall") + @CommandPermission("multiverse.core.list.who.all") + @CommandCompletion("@flags:groupName=mvwhocommand") + @Syntax("[--page ] [--filter ]") + @Description("{@@mv-core.who.all.description}") + void onWhoAllCommand( + MVCommandIssuer issuer, + + @Optional + @Syntax("[--page ] [--filter ]") + @Description("{@@mv-core.who.flags}") + String[] flags) { + ParsedCommandFlags parsedFlags = parseFlags(flags); + + // Send the display + getListDisplay(worldManager.getLoadedWorlds(), parsedFlags.flagValue(PAGE_FLAG, 1), parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())).send(issuer); + + } + + @Subcommand("who") + @CommandPermission("multiverse.core.list.who") + @CommandCompletion("@mvworlds:scope=both @flags:groupName=mvwhocommand") + @Syntax(" [--page ] [--filter ]") + @Description("{@@mv-core.who.description}") + void onWhoCommand( + MVCommandIssuer issuer, + + @Syntax("") + @Description("{@@mv-core.who.world.description}") + LoadedMultiverseWorld inputtedWorld, + + @Optional + @Syntax("[--page ] [--filter ]") + @Description("{@@mv-core.who.flags}") + String[] flags) { + ParsedCommandFlags parsedFlags = parseFlags(flags); + + // Send the display + getListDisplay(inputtedWorld, parsedFlags.flagValue(PAGE_FLAG, 1), parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())).send(issuer); + } + + private String phrasePlayerList(List players) { + return players.stream().map(Player::getName).collect(Collectors.joining(", ")); + } + + private ContentDisplay getListDisplay(LoadedMultiverseWorld world, int page, ContentFilter filter) { + Collection listingWorlds = new ArrayList<>(); + listingWorlds.add(world); + return getListDisplay(listingWorlds, page, filter); + } + + private ContentDisplay getListDisplay(Collection worlds, int page, ContentFilter filter) { + HashMap outMap = new HashMap<>(); + + // Add all the worlds to our hashmap + for (LoadedMultiverseWorld world : worlds) { + List players = world.getPlayers().getOrNull(); + + // If the world has 0 players in it, ignore it + if (players.isEmpty()) { + continue; + } + outMap.put(world.getAlias(), phrasePlayerList(players)); + } + + return ContentDisplay.create() + .addContent(MapContentProvider.forContent(outMap)) + .withSendHandler(PagedSendHandler.create() + .withHeader("%s====[ Multiverse World Players List ]====", ChatColor.AQUA) + .doPagination(true) + .withTargetPage(page) + .withFilter(filter)); + } +} From c640a251b6b321dcce6ce01c35f76b40a46bdbba Mon Sep 17 00:00:00 2001 From: Zax71 Date: Sat, 24 Feb 2024 13:03:12 +0000 Subject: [PATCH 02/11] Add i18n and tell user when a world is empty when using /mv who --- .../multiverse/core/commands/WhoCommand.java | 37 ++++++++++++++----- .../multiverse/core/utils/MVCorei18n.java | 8 ++++ .../resources/multiverse-core_en.properties | 8 ++++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java index 5eb03131..13e80c72 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/WhoCommand.java @@ -8,10 +8,12 @@ import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Optional; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; +import com.dumptruckman.minecraft.util.Logging; import jakarta.inject.Inject; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; @@ -79,12 +81,17 @@ public class WhoCommand extends MultiverseCommand { @Optional @Syntax("[--page ] [--filter ]") - @Description("{@@mv-core.who.flags}") + @Description("{@@mv-core.who.flags.description}") String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); // Send the display - getListDisplay(worldManager.getLoadedWorlds(), parsedFlags.flagValue(PAGE_FLAG, 1), parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())).send(issuer); + getListDisplay( + worldManager.getLoadedWorlds(), + parsedFlags.flagValue(PAGE_FLAG, 1), + parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get()), + true + ).send(issuer); } @@ -102,35 +109,45 @@ public class WhoCommand extends MultiverseCommand { @Optional @Syntax("[--page ] [--filter ]") - @Description("{@@mv-core.who.flags}") + @Description("{@@mv-core.who.flags.description}") String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); // Send the display - getListDisplay(inputtedWorld, parsedFlags.flagValue(PAGE_FLAG, 1), parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())).send(issuer); + getListDisplay( + inputtedWorld, + parsedFlags.flagValue(PAGE_FLAG, 1), + parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get()), + false + ).send(issuer); } private String phrasePlayerList(List players) { return players.stream().map(Player::getName).collect(Collectors.joining(", ")); } - private ContentDisplay getListDisplay(LoadedMultiverseWorld world, int page, ContentFilter filter) { + private ContentDisplay getListDisplay(LoadedMultiverseWorld world, int page, ContentFilter filter, boolean ignoreEmptyWorlds) { Collection listingWorlds = new ArrayList<>(); listingWorlds.add(world); - return getListDisplay(listingWorlds, page, filter); + return getListDisplay(listingWorlds, page, filter, ignoreEmptyWorlds); } - private ContentDisplay getListDisplay(Collection worlds, int page, ContentFilter filter) { + private ContentDisplay getListDisplay(Collection worlds, int page, ContentFilter filter, boolean ignoreEmptyWorlds) { HashMap outMap = new HashMap<>(); // Add all the worlds to our hashmap for (LoadedMultiverseWorld world : worlds) { - List players = world.getPlayers().getOrNull(); + @Nullable List players = world.getPlayers().getOrNull(); - // If the world has 0 players in it, ignore it - if (players.isEmpty()) { + // If the world has 0 players in it, say that it is empty + if ((players == null || players.isEmpty()) && !ignoreEmptyWorlds) { + outMap.put(world.getAlias(), ChatColor.RED + "Empty"); continue; } + if (players == null || players.isEmpty()) { + continue; + } + outMap.put(world.getAlias(), phrasePlayerList(players)); } diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java b/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java index 42d5fab2..9e11b39b 100644 --- a/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java +++ b/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java @@ -101,6 +101,14 @@ public enum MVCorei18n implements MessageKeyProvider { UNLOAD_UNLOADING, UNLOAD_SUCCESS, + // who command + WHO_DESCRIPTION, + WHO_ALL_DESCRIPTION, + WHO_WORLD_DESCRIPTION, + WHO_FLAGS_DESCRIPTION, + WHO_EMPTY, + + // debug command DEBUG_INFO_OFF, DEBUG_INFO_ON, diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index bfb4bcd5..0130a8e9 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -139,6 +139,14 @@ mv-core.unload.success=&aWorld '{world}' unloaded! # /mv usage mv-core.usage.description=Show Multiverse-Core command usage. +# /mv who +# /mv whoall +mv-core.who.description=Lists the players in the world specified +mv-core.who.all.description=Lists the players in all worlds +mv-core.who.world.description=Name of the world you want to list players in +mv-core.who.flags.description=Filter - only shows entries matching this. Page - the page to show +mv-core.who.empty=&rEmpty + # commands error mv-core.commands.error.playersonly=&cThis command can only be used by players mv-core.commands.error.multiverseworldonly=&cThis can only be used in multiverse worlds From c24f198ed0bcbef6f5c182b46707d9d180619a69 Mon Sep 17 00:00:00 2001 From: Zax71 Date: Sat, 24 Feb 2024 13:36:13 +0000 Subject: [PATCH 03/11] Add `/mv version` --- .../core/commands/VersionCommand.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java new file mode 100644 index 00000000..8c71065e --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java @@ -0,0 +1,36 @@ +package org.mvplugins.multiverse.core.commands; + +import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Subcommand; +import jakarta.inject.Inject; +import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; +import org.jvnet.hk2.annotations.Service; +import org.mvplugins.multiverse.core.MultiverseCore; +import org.mvplugins.multiverse.core.commandtools.MVCommandManager; +import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; + +@Service +@CommandAlias("mv") +class VersionCommand extends MultiverseCommand { + + private final MultiverseCore plugin; + + @Inject + VersionCommand(@NotNull MVCommandManager commandManager, MultiverseCore plugin) { + super(commandManager); + this.plugin = plugin; + } + + @Subcommand("version") + @CommandPermission("multiverse.core.version") + @Description("{@@mv-core.version.description}") + void versionCommand(BukkitCommandIssuer issuer) { + issuer.sendMessage("Multiverse Core version: " + ChatColor.WHITE + plugin.getDescription().getVersion()); + issuer.sendMessage("Multiverse Core authors: " + ChatColor.WHITE + String.join(", ", plugin.getDescription().getAuthors())); + issuer.sendMessage("Special Code: " + ChatColor.WHITE + "FRN002"); // An in joke I don't get... + } +} From 90b87291299ef8c19cb9ae5e68e783ad73cfdeed Mon Sep 17 00:00:00 2001 From: Zax71 Date: Sat, 24 Feb 2024 13:37:23 +0000 Subject: [PATCH 04/11] Add Ben and Zax71 to authors --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8a26e307..0ce00df3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Multiverse-Core main: org.mvplugins.multiverse.core.MultiverseCore -authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--'] +authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--', 'Benergy10', 'Zax71'] website: 'https://dev.bukkit.org/projects/multiverse-core' softdepend: ['Vault', 'PlaceholderAPI'] api-version: 1.13 From 7276da766514020af73bdd6a2e420b082533f06d Mon Sep 17 00:00:00 2001 From: Zax71 Date: Sat, 24 Feb 2024 13:48:57 +0000 Subject: [PATCH 05/11] Implement i18n --- .../multiverse/core/commands/VersionCommand.java | 9 +++++---- .../org/mvplugins/multiverse/core/utils/MVCorei18n.java | 5 +++++ src/main/resources/multiverse-core_en.properties | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java index 8c71065e..ea3474dd 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java @@ -1,17 +1,18 @@ package org.mvplugins.multiverse.core.commands; import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.MessageType; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Subcommand; import jakarta.inject.Inject; -import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.MultiverseCore; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; +import org.mvplugins.multiverse.core.utils.MVCorei18n; @Service @CommandAlias("mv") @@ -29,8 +30,8 @@ class VersionCommand extends MultiverseCommand { @CommandPermission("multiverse.core.version") @Description("{@@mv-core.version.description}") void versionCommand(BukkitCommandIssuer issuer) { - issuer.sendMessage("Multiverse Core version: " + ChatColor.WHITE + plugin.getDescription().getVersion()); - issuer.sendMessage("Multiverse Core authors: " + ChatColor.WHITE + String.join(", ", plugin.getDescription().getAuthors())); - issuer.sendMessage("Special Code: " + ChatColor.WHITE + "FRN002"); // An in joke I don't get... + issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_MV, "{version}", plugin.getDescription().getVersion()); + issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_AUTHORS, "{authors}", String.join(", ", plugin.getDescription().getAuthors())); + issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_SECRETCODE); // An in joke I don't get... } } diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java b/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java index 42d5fab2..c257157a 100644 --- a/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java +++ b/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java @@ -101,6 +101,11 @@ public enum MVCorei18n implements MessageKeyProvider { UNLOAD_UNLOADING, UNLOAD_SUCCESS, + // version command + VERSION_MV, + VERSION_AUTHORS, + VERSION_SECRETCODE, + // debug command DEBUG_INFO_OFF, DEBUG_INFO_ON, diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index bfb4bcd5..26a9ab61 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -139,6 +139,12 @@ mv-core.unload.success=&aWorld '{world}' unloaded! # /mv usage mv-core.usage.description=Show Multiverse-Core command usage. +# /mv version +mv-core.version.description=Displays version and authors +mv-core.version.mv=Multiverse Core Version &fv{version} +mv-core.version.authors=Multiverse Core Authors &f{authors} +mv-core.version.secretcode=Special Code: &fFRN002 + # commands error mv-core.commands.error.playersonly=&cThis command can only be used by players mv-core.commands.error.multiverseworldonly=&cThis can only be used in multiverse worlds From caed081f822914ab301aeebc0f41dbe2fefded04 Mon Sep 17 00:00:00 2001 From: Zax71 Date: Fri, 8 Mar 2024 18:03:42 +0000 Subject: [PATCH 06/11] Update Ben's name --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0ce00df3..f4bc2d69 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Multiverse-Core main: org.mvplugins.multiverse.core.MultiverseCore -authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--', 'Benergy10', 'Zax71'] +authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--', 'benwoo1110', 'Zax71'] website: 'https://dev.bukkit.org/projects/multiverse-core' softdepend: ['Vault', 'PlaceholderAPI'] api-version: 1.13 From 62c94973651b6207b72b1320028dee8815ba8379 Mon Sep 17 00:00:00 2001 From: Zax71 Date: Tue, 27 Aug 2024 19:30:41 +0100 Subject: [PATCH 07/11] Fix colouring on `/mv modify` --- .../core/commands/ModifyCommand.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java index 87a58e0b..85b13ef3 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java @@ -10,6 +10,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.dumptruckman.minecraft.util.Logging; import jakarta.inject.Inject; +import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; @@ -60,17 +61,27 @@ class ModifyCommand extends MultiverseCommand { String propertyValue) { StringPropertyHandle worldPropertyHandle = world.getStringPropertyHandle(); worldPropertyHandle.modifyProperty(propertyName, propertyValue, action).onSuccess(ignore -> { - issuer.sendMessage("Property %s set to %s for world %s.".formatted( + issuer.sendMessage("Property %s%s set to %s%s for world %s%s%s.".formatted( propertyName, + ChatColor.BLUE, worldPropertyHandle.getProperty(propertyName).getOrNull(), - world.getName())); + ChatColor.BLUE, + ChatColor.GRAY, + world.getName(), + ChatColor.BLUE + )); worldManager.saveWorldsConfig(); }).onFailure(exception -> { - issuer.sendMessage("Failed to %s property %s to %s for world %s.".formatted( + issuer.sendMessage("Failed to %s%s property %s%s to %s%s for world %s%s.".formatted( action.name().toLowerCase(), + ChatColor.BLUE, propertyName, + ChatColor.BLUE, propertyValue, - world.getName())); + ChatColor.BLUE, + world.getName(), + ChatColor.BLUE + )); issuer.sendMessage(exception.getMessage()); }); } From 949ba46a1627e03c02c1e68609a2d4c705e5044d Mon Sep 17 00:00:00 2001 From: Zax71 Date: Tue, 27 Aug 2024 19:59:21 +0100 Subject: [PATCH 08/11] Add legacy aliases --- .../org/mvplugins/multiverse/core/commands/CheckCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/CloneCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/ConfigCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/ConfirmCommand.java | 2 ++ .../mvplugins/multiverse/core/commands/CoordinatesCommand.java | 2 +- .../org/mvplugins/multiverse/core/commands/CreateCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/DebugCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/DeleteCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/GameruleCommand.java | 1 + .../mvplugins/multiverse/core/commands/GeneratorsCommand.java | 2 +- .../org/mvplugins/multiverse/core/commands/ImportCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/InfoCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/ListCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/LoadCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/ModifyCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/RegenCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/ReloadCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/RemoveCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/UnloadCommand.java | 1 + .../org/mvplugins/multiverse/core/commands/VersionCommand.java | 1 + 20 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java index 0a2f165b..a1283ff0 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java @@ -30,6 +30,7 @@ class CheckCommand extends MultiverseCommand { this.destinationsProvider = destinationsProvider; } + @CommandAlias("mvcheck") @Subcommand("check") @CommandPermission("multiverse.core.check") @CommandCompletion("@players @destinations|@mvworlds") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java index 9493e7ad..5875e110 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java @@ -46,6 +46,7 @@ class CloneCommand extends MultiverseCommand { this.worldManager = worldManager; } + @CommandAlias("mvcl|mvclone") @Subcommand("clone") @CommandPermission("multiverse.core.clone") @CommandCompletion("@mvworlds:scope=loaded @empty @flags:groupName=mvclonecommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ConfigCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ConfigCommand.java index 18ac8b06..ec0d17e1 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ConfigCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ConfigCommand.java @@ -30,6 +30,7 @@ class ConfigCommand extends MultiverseCommand { this.config = config; } + @CommandAlias("mvconfig|mvconf") @Subcommand("config") @CommandPermission("multiverse.core.config") @CommandCompletion("@mvconfigs @mvconfigvalues") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java index b14fd6a6..d0acf236 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java @@ -6,6 +6,7 @@ import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Subcommand; import jakarta.inject.Inject; +import org.checkerframework.checker.units.qual.C; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; @@ -21,6 +22,7 @@ class ConfirmCommand extends MultiverseCommand { super(commandManager); } + @CommandAlias("mvconfirm") @Subcommand("confirm") @CommandPermission("multiverse.core.confirm") @Description("{@@mv-core.confirm.description}") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java index dcf48f2d..71055ba8 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java @@ -30,7 +30,7 @@ class CoordinatesCommand extends MultiverseCommand { super(commandManager); this.locationManipulation = locationManipulation; } - + @CommandAlias("mvcoord|mvco") @Subcommand("coordinates|coords|coord|co") @CommandPermission("multiverse.core.coord") @Description("{@@mv-core.coordinates.description}") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java index e05f6125..824bc554 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java @@ -69,6 +69,7 @@ class CreateCommand extends MultiverseCommand { this.generatorProvider = generatorProvider; } + @CommandAlias("mvcreate|mvc") @Subcommand("create") @CommandPermission("multiverse.core.create") @CommandCompletion("@empty @environments @flags:groupName=mvcreatecommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DebugCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DebugCommand.java index 7a315471..119074eb 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DebugCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DebugCommand.java @@ -36,6 +36,7 @@ class DebugCommand extends MultiverseCommand { this.displayDebugMode(issuer); } + @CommandAlias("mvdebug") @Subcommand("debug") @CommandPermission("multiverse.core.debug") @CommandCompletion("@range:3") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java index db4d448f..3d5a50d9 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java @@ -50,6 +50,7 @@ class DeleteCommand extends MultiverseCommand { this.playerWorldTeleporter = playerWorldTeleporter; } + @CommandAlias("mvdelete") @Subcommand("delete") @CommandPermission("multiverse.core.delete") @CommandCompletion("@mvworlds:scope=loaded @flags:groupName=mvdeletecommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java index b3f68a1d..74c8f769 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java @@ -72,6 +72,7 @@ class GameruleCommand extends MultiverseCommand { super(commandManager); } + @Subcommand("set") @CommandPermission("multiverse.core.gamerule.set") @CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java index 372fb2c2..44ef4678 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java @@ -68,7 +68,7 @@ class GeneratorsCommand extends MultiverseCommand { super(commandManager); this.generatorProvider = generatorProvider; } - + @CommandAlias("mvgenerators|mvgens") @Subcommand("generators|gens") @CommandPermission("multiverse.core.generator") @CommandCompletion("@flags:groupName=mvgeneratorscommand @flags:groupName=mvgeneratorscommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java index 859de2dd..bc351967 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java @@ -52,6 +52,7 @@ class ImportCommand extends MultiverseCommand { this.generatorProvider = generatorProvider; } + @CommandAlias("mvimport|mvim") @Subcommand("import") @CommandPermission("multiverse.core.import") @CommandCompletion("@mvworlds:scope=potential @environments @flags:groupName=mvimportcommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/InfoCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/InfoCommand.java index 60436e8d..2f5d0fa7 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/InfoCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/InfoCommand.java @@ -75,6 +75,7 @@ class InfoCommand extends MultiverseCommand { } // TODO: support info for unloaded worlds + @CommandAlias("mvinfo|mvi") @Subcommand("info") @CommandPermission("multiverse.core.info") @CommandCompletion("@mvworlds:scope=both|@flags:groupName=mvinfocommand @flags:groupName=mvinfocommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java index 7ac60aed..307f0816 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java @@ -73,6 +73,7 @@ class ListCommand extends MultiverseCommand { this.worldEntryCheckerProvider = worldEntryCheckerProvider; } + @CommandAlias("mvlist|mvl") @Subcommand("list") @CommandPermission("multiverse.core.list.worlds") @CommandCompletion("@flags:groupName=mvlistcommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java index e72ef798..a5e75f74 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java @@ -31,6 +31,7 @@ class LoadCommand extends MultiverseCommand { this.worldManager = worldManager; } + @CommandAlias("mvload") @Subcommand("load") @CommandPermission("multiverse.core.load") @CommandCompletion("@mvworlds:scope=unloaded") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java index 87a58e0b..6de64d25 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ModifyCommand.java @@ -33,6 +33,7 @@ class ModifyCommand extends MultiverseCommand { this.worldManager = worldManager; } + @CommandAlias("mvmodify|mvm") @Subcommand("modify") @CommandPermission("multiverse.core.modify") @CommandCompletion("@mvworlds:scope=both @propsmodifyaction @mvworldpropsname @mvworldpropsvalue") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java index 23f56a14..21773f4a 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java @@ -70,6 +70,7 @@ class RegenCommand extends MultiverseCommand { this.playerWorldTeleporter = playerWorldTeleporter; } + @CommandAlias("mvregen") @Subcommand("regen") @CommandPermission("multiverse.core.regen") @CommandCompletion("@mvworlds:scope=loaded @flags:groupName=mvregencommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java index 2630de1f..d39641f2 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java @@ -44,6 +44,7 @@ class ReloadCommand extends MultiverseCommand { this.pluginManager = pluginManager; } + @CommandAlias("mvreload|mvr") @Subcommand("reload") @CommandPermission("multiverse.core.reload") @Description("{@@mv-core.reload.description}") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java index 4888082c..d2ecb942 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java @@ -48,6 +48,7 @@ class RemoveCommand extends MultiverseCommand { this.playerWorldTeleporter = playerWorldTeleporter; } + @CommandAlias("mvremove") @Subcommand("remove") @CommandPermission("multiverse.core.remove") @CommandCompletion("@mvworlds:scope=both") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java index 42a85aa4..48204f4d 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java @@ -51,6 +51,7 @@ class UnloadCommand extends MultiverseCommand { this.playerWorldTeleporter = playerWorldTeleporter; } + @CommandAlias("mvunload") @Subcommand("unload") @CommandPermission("multiverse.core.unload") @CommandCompletion("@mvworlds @flags:groupName=mvunloadcommand") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java index ea3474dd..4b417ad5 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java @@ -26,6 +26,7 @@ class VersionCommand extends MultiverseCommand { this.plugin = plugin; } + @CommandAlias("mvversion") @Subcommand("version") @CommandPermission("multiverse.core.version") @Description("{@@mv-core.version.description}") From ad3a6fc8fc4652295c06f288f57a168599e900d2 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:56:36 +0800 Subject: [PATCH 09/11] Fix WorldManager#getWorld from bukkit World not mapping to worldname --- .../java/org/mvplugins/multiverse/core/world/WorldManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java index 6e1a31e8..b46ec662 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java @@ -734,7 +734,7 @@ public class WorldManager { * @return The world if it exists. */ public Option getWorld(@Nullable World world) { - return Option.of(world).flatMap(this::getWorld); + return Option.of(world).map(World::getName).flatMap(this::getWorld); } /** From e0d0ee0ad070c25aba0efe194bfbc7d8164ff4b4 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:01:03 +0800 Subject: [PATCH 10/11] Add onFailure methods to AsyncAttempt class. --- .../multiverse/core/utils/result/AsyncAttempt.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java b/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java index 67b8a9a0..f57268ae 100644 --- a/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java +++ b/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java @@ -3,6 +3,7 @@ package org.mvplugins.multiverse.core.utils.result; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.BiFunction; +import java.util.function.Consumer; import java.util.function.Function; import org.mvplugins.multiverse.core.utils.message.MessageReplacement; @@ -67,6 +68,19 @@ public final class AsyncAttempt { return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onSuccess(runnable))); } + public AsyncAttempt onFailure(Runnable runnable) { + // TODO Not sure why we creating a new instance instead of using `this` + return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onFailure(runnable))); + } + + public AsyncAttempt onFailure(Consumer> consumer) { + return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onFailure(consumer))); + } + + public AsyncAttempt onFailureReason(Consumer consumer) { + return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onFailureReason(consumer))); + } + public Attempt toAttempt() { return future.join(); } From d530c2aa4d8002e1151c496d41f7fe09c09bbe37 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:25:50 +0800 Subject: [PATCH 11/11] Fix some formatting issues. --- .../org/mvplugins/multiverse/core/commands/ConfirmCommand.java | 1 - .../org/mvplugins/multiverse/core/commands/GameruleCommand.java | 1 - .../mvplugins/multiverse/core/commands/GeneratorsCommand.java | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java index d0acf236..f37b8ef0 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java @@ -6,7 +6,6 @@ import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Subcommand; import jakarta.inject.Inject; -import org.checkerframework.checker.units.qual.C; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java index 74c8f769..b3f68a1d 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java @@ -72,7 +72,6 @@ class GameruleCommand extends MultiverseCommand { super(commandManager); } - @Subcommand("set") @CommandPermission("multiverse.core.gamerule.set") @CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java index 44ef4678..28899382 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/GeneratorsCommand.java @@ -68,6 +68,7 @@ class GeneratorsCommand extends MultiverseCommand { super(commandManager); this.generatorProvider = generatorProvider; } + @CommandAlias("mvgenerators|mvgens") @Subcommand("generators|gens") @CommandPermission("multiverse.core.generator")