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 861e2cd2..0a2f165b 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java @@ -1,6 +1,5 @@ package org.mvplugins.multiverse.core.commands; -import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -12,6 +11,7 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; +import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.destination.DestinationsProvider; @@ -20,12 +20,12 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n; @Service @CommandAlias("mv") -public class CheckCommand extends MultiverseCommand { +class CheckCommand extends MultiverseCommand { private final DestinationsProvider destinationsProvider; @Inject - public CheckCommand(@NotNull MVCommandManager commandManager, @NotNull DestinationsProvider destinationsProvider) { + CheckCommand(@NotNull MVCommandManager commandManager, @NotNull DestinationsProvider destinationsProvider) { super(commandManager); this.destinationsProvider = destinationsProvider; } @@ -35,16 +35,16 @@ public class CheckCommand extends MultiverseCommand { @CommandCompletion("@players @destinations|@mvworlds") @Syntax(" ") @Description("{@@mv-core.check.description}") - public void onCheckCommand(BukkitCommandIssuer issuer, + void onCheckCommand( + MVCommandIssuer issuer, - @Syntax("") - @Description("{@@mv-core.check.player.description}") - Player player, + @Syntax("") + @Description("{@@mv-core.check.player.description}") + Player player, - @Syntax("") - @Description("{@@mv-core.check.destination.description}") - ParsedDestination destination - ) { + @Syntax("") + @Description("{@@mv-core.check.destination.description}") + ParsedDestination destination) { issuer.sendInfo(MVCorei18n.CHECK_CHECKING, "{player}", player.getName(), "{destination}", destination.toString()); 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 ecdbedbc..fe7c2e2c 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java @@ -16,7 +16,6 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag; -import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagGroup; import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; import org.mvplugins.multiverse.core.utils.MVCorei18n; import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; @@ -25,31 +24,31 @@ import org.mvplugins.multiverse.core.worldnew.options.CloneWorldOptions; @Service @CommandAlias("mv") -public class CloneCommand extends MultiverseCommand { +class CloneCommand extends MultiverseCommand { private final WorldManager worldManager; + private final CommandFlag RESET_WORLD_CONFIG_FLAG = flag(CommandFlag.builder("--reset-world-config") + .addAlias("-wc") + .build()); + + private final CommandFlag RESET_GAMERULES_FLAG = flag(CommandFlag.builder("--reset-gamerules") + .addAlias("-gm") + .build()); + + private final CommandFlag RESET_WORLD_BORDER_FLAG = flag(CommandFlag.builder("--reset-world-border") + .addAlias("-wb") + .build()); + @Inject - public CloneCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + CloneCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { super(commandManager); this.worldManager = worldManager; - - registerFlagGroup(CommandFlagGroup.builder("mvclone") - .add(CommandFlag.builder("--reset-world-config") - .addAlias("-wc") - .build()) - .add(CommandFlag.builder("--reset-gamerules") - .addAlias("-gm") - .build()) - .add(CommandFlag.builder("--reset-world-border") - .addAlias("-wb") - .build()) - .build()); } @Subcommand("clone") @CommandPermission("multiverse.core.clone") - @CommandCompletion("@mvworlds:scope=both @empty") + @CommandCompletion("@mvworlds:scope=loaded @empty @flags:groupName=mvclonecommand") @Syntax(" ") @Description("{@@mv-core.clone.description}") void onCloneCommand( @@ -71,9 +70,9 @@ public class CloneCommand extends MultiverseCommand { issuer.sendInfo(MVCorei18n.CLONE_CLONING, "{world}", world.getName(), "{newworld}", newWorldName); CloneWorldOptions cloneWorldOptions = CloneWorldOptions.fromTo(world, newWorldName) - .keepWorldConfig(!parsedFlags.hasFlag("--reset-world-config")) - .keepGameRule(!parsedFlags.hasFlag("--reset-gamerules")) - .keepWorldBorder(!parsedFlags.hasFlag("--reset-world-border")); + .keepWorldConfig(!parsedFlags.hasFlag(RESET_WORLD_CONFIG_FLAG)) + .keepGameRule(!parsedFlags.hasFlag(RESET_GAMERULES_FLAG)) + .keepWorldBorder(!parsedFlags.hasFlag(RESET_WORLD_BORDER_FLAG)); worldManager.cloneWorld(cloneWorldOptions) .onSuccess(newWorld -> { Logging.fine("World clone success: " + newWorld); 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 c464962c..b419dc1a 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ConfigCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ConfigCommand.java @@ -5,7 +5,6 @@ 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.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import io.vavr.control.Option; @@ -22,12 +21,12 @@ import org.mvplugins.multiverse.core.exceptions.MultiverseException; @Service @CommandAlias("mv") -public class ConfigCommand extends MultiverseCommand { +class ConfigCommand extends MultiverseCommand { private final MVCoreConfig config; @Inject - public ConfigCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) { + ConfigCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) { super(commandManager); this.config = config; } @@ -37,18 +36,17 @@ public class ConfigCommand extends MultiverseCommand { @CommandCompletion("@mvconfigs") @Syntax(" [new-value]") @Description("") // TODO: Description - public void onConfigCommand(MVCommandIssuer issuer, + void onConfigCommand( + MVCommandIssuer issuer, - @Syntax("") - @Description("") // TODO: Description - String name, + @Syntax("") + @Description("") // TODO: Description + String name, - @Optional - @Single - @Syntax("[new-value]") - @Description("") // TODO: Description - MVConfigValue value - ) { + @Optional + @Syntax("[new-value]") + @Description("") // TODO: Description + MVConfigValue value) { if (value == null) { showConfigValue(issuer, name); return; 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 fae2d74d..b14fd6a6 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java @@ -14,17 +14,17 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; @Service @CommandAlias("mv") -public class ConfirmCommand extends MultiverseCommand { +class ConfirmCommand extends MultiverseCommand { @Inject - public ConfirmCommand(@NotNull MVCommandManager commandManager) { + ConfirmCommand(@NotNull MVCommandManager commandManager) { super(commandManager); } @Subcommand("confirm") @CommandPermission("multiverse.core.confirm") @Description("{@@mv-core.confirm.description}") - public void onConfirmCommand(@NotNull BukkitCommandIssuer issuer) { + void onConfirmCommand(@NotNull BukkitCommandIssuer issuer) { this.commandManager.getCommandQueueManager().runQueuedCommand(issuer.getIssuer()); } } 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 2f316ec4..f019cb25 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java @@ -19,15 +19,14 @@ import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; @Service @CommandAlias("mv") -public class CoordinatesCommand extends MultiverseCommand { +class CoordinatesCommand extends MultiverseCommand { private final LocationManipulation locationManipulation; @Inject - public CoordinatesCommand( + CoordinatesCommand( @NotNull MVCommandManager commandManager, - @NotNull LocationManipulation locationManipulation - ) { + @NotNull LocationManipulation locationManipulation) { super(commandManager); this.locationManipulation = locationManipulation; } @@ -35,14 +34,14 @@ public class CoordinatesCommand extends MultiverseCommand { @Subcommand("coordinates|coords|coord|co") @CommandPermission("multiverse.core.coord") @Description("{@@mv-core.coordinates.description}") - public void onCoordinatesCommand(BukkitCommandIssuer issuer, + void onCoordinatesCommand( + BukkitCommandIssuer issuer, - @Flags("resolve=issuerOnly") - Player player, + @Flags("resolve=issuerOnly") + Player player, - @Flags("resolve=issuerOnly") - LoadedMultiverseWorld world - ) { + @Flags("resolve=issuerOnly") + LoadedMultiverseWorld world) { issuer.sendInfo(MVCorei18n.COORDINATES_INFO_TITLE); issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLD, "{world}", world.getName()); issuer.sendInfo(MVCorei18n.COORDINATES_INFO_ALIAS, "{alias}", world.getAlias()); 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 8d85b97a..84f8b2c0 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java @@ -21,7 +21,6 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag; -import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagGroup; import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag; import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; import org.mvplugins.multiverse.core.utils.MVCorei18n; @@ -31,78 +30,91 @@ import org.mvplugins.multiverse.core.worldnew.options.CreateWorldOptions; @Service @CommandAlias("mv") -public class CreateCommand extends MultiverseCommand { +class CreateCommand extends MultiverseCommand { private final WorldManager worldManager; + private GeneratorProvider generatorProvider; + + private final CommandValueFlag SEED_FLAG = flag(CommandValueFlag.builder("--seed", String.class) + .addAlias("-s") + .completion(input -> Collections.singleton(String.valueOf(new Random().nextLong()))) + .build()); + + private final CommandValueFlag GENERATOR_FLAG = flag(CommandValueFlag + .builder("--generator", String.class) + .addAlias("-g") + .completion(input -> generatorProvider.suggestGeneratorString(input)) + .build()); + + private final CommandValueFlag WORLD_TYPE_FLAG = flag(CommandValueFlag + .enumBuilder("--world-type", WorldType.class) + .addAlias("-t") + .build()); + + private final CommandFlag NO_ADJUST_SPAWN_FLAG = flag(CommandFlag.builder("--no-adjust-spawn") + .addAlias("-n") + .build()); + + private final CommandFlag NO_STRUCTURES_FLAG = flag(CommandFlag.builder("--no-structures") + .addAlias("-a") + .build()); @Inject - public CreateCommand( + CreateCommand( @NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager, - @NotNull GeneratorProvider generatorProvider - ) { + @NotNull GeneratorProvider generatorProvider) { super(commandManager); this.worldManager = worldManager; - - registerFlagGroup(CommandFlagGroup.builder("mvcreate") - .add(CommandValueFlag.builder("--seed", String.class) - .addAlias("-s") - .completion((input) -> Collections.singleton(String.valueOf(new Random().nextLong()))) - .build()) - .add(CommandValueFlag.builder("--generator", String.class) - .addAlias("-g") - .completion(generatorProvider::suggestGeneratorString) - .build()) - .add(CommandValueFlag.enumBuilder("--world-type", WorldType.class) - .addAlias("-t") - .build()) - .add(CommandFlag.builder("--no-adjust-spawn") - .addAlias("-n") - .build()) - .add(CommandFlag.builder("--no-structures") - .addAlias("-a") - .build()) - .build()); + this.generatorProvider = generatorProvider; } @Subcommand("create") @CommandPermission("multiverse.core.create") - @CommandCompletion("@empty @flags:groupName=mvcreate") + @CommandCompletion("@empty @flags:groupName=mvcreatecommand") @Syntax(" --seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures") @Description("{@@mv-core.create.description}") - public void onCreateCommand(MVCommandIssuer issuer, + void onCreateCommand( + MVCommandIssuer issuer, - @Syntax("") - @Description("{@@mv-core.create.name.description}") - String worldName, + @Syntax("") + @Description("{@@mv-core.create.name.description}") + String worldName, - @Syntax("") - @Description("{@@mv-core.create.environment.description}") - World.Environment environment, + @Syntax("") + @Description("{@@mv-core.create.environment.description}") + World.Environment environment, - @Optional - @Syntax("--seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures") - @Description("{@@mv-core.create.flags.description}") - String[] flags) { + @Optional + @Syntax("--seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures") + @Description("{@@mv-core.create.flags.description}") + String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES, "{worldName}", worldName); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ENVIRONMENT, "{environment}", environment.name()); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_SEED, "{seed}", parsedFlags.flagValue("--seed", "RANDOM", String.class)); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_WORLDTYPE, "{worldType}", parsedFlags.flagValue("--world-type", WorldType.NORMAL, WorldType.class).name()); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ADJUSTSPAWN, "{adjustSpawn}", String.valueOf(!parsedFlags.hasFlag("--no-adjust-spawn"))); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_GENERATOR, "{generator}", parsedFlags.flagValue("--generator", "", String.class)); - issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_STRUCTURES, "{structures}", String.valueOf(!parsedFlags.hasFlag("--no-structures"))); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES, + "{worldName}", worldName); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ENVIRONMENT, + "{environment}", environment.name()); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_SEED, + "{seed}", parsedFlags.flagValue(SEED_FLAG, "RANDOM")); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_WORLDTYPE, + "{worldType}", parsedFlags.flagValue(WORLD_TYPE_FLAG, WorldType.NORMAL).name()); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ADJUSTSPAWN, + "{adjustSpawn}", String.valueOf(!parsedFlags.hasFlag(NO_ADJUST_SPAWN_FLAG))); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_GENERATOR, + "{generator}", parsedFlags.flagValue(GENERATOR_FLAG, "")); + issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_STRUCTURES, + "{structures}", String.valueOf(!parsedFlags.hasFlag(NO_STRUCTURES_FLAG))); issuer.sendInfo(MVCorei18n.CREATE_LOADING); worldManager.createWorld(CreateWorldOptions.worldName(worldName) .environment(environment) - .seed(parsedFlags.flagValue("--seed", String.class)) - .worldType(parsedFlags.flagValue("--world-type", WorldType.NORMAL, WorldType.class)) - .useSpawnAdjust(!parsedFlags.hasFlag("--no-adjust-spawn")) - .generator(parsedFlags.flagValue("--generator", "", String.class)) - .generateStructures(!parsedFlags.hasFlag("--no-structures"))) + .seed(parsedFlags.flagValue(SEED_FLAG)) + .worldType(parsedFlags.flagValue(WORLD_TYPE_FLAG, WorldType.NORMAL)) + .useSpawnAdjust(!parsedFlags.hasFlag(NO_ADJUST_SPAWN_FLAG)) + .generator(parsedFlags.flagValue(GENERATOR_FLAG, "")) + .generateStructures(!parsedFlags.hasFlag(NO_STRUCTURES_FLAG))) .onSuccess(newWorld -> { Logging.fine("World create success: " + newWorld); issuer.sendInfo(MVCorei18n.CREATE_SUCCESS, "{world}", newWorld.getName()); 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 68185a50..7a315471 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DebugCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DebugCommand.java @@ -19,12 +19,12 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n; @Service @CommandAlias("mv") -public class DebugCommand extends MultiverseCommand { +class DebugCommand extends MultiverseCommand { private final MVCoreConfig config; @Inject - public DebugCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) { + DebugCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) { super(commandManager); this.config = config; } @@ -32,7 +32,7 @@ public class DebugCommand extends MultiverseCommand { @Subcommand("debug") @CommandPermission("multiverse.core.debug") @Description("{@@mv-core.debug.info.description}") - public void onShowDebugCommand(BukkitCommandIssuer issuer) { + void onShowDebugCommand(BukkitCommandIssuer issuer) { this.displayDebugMode(issuer); } @@ -41,11 +41,12 @@ public class DebugCommand extends MultiverseCommand { @CommandCompletion("@range:3") @Syntax("<{@@mv-core.debug.change.syntax}>") @Description("{@@mv-core.debug.change.description}") - public void onChangeDebugCommand(BukkitCommandIssuer issuer, + void onChangeDebugCommand( + BukkitCommandIssuer issuer, - @Syntax("<{@@mv-core.debug.change.syntax}>") - @Description("{@@mv-core.debug.change.level.description}") - int level) { + @Syntax("<{@@mv-core.debug.change.syntax}>") + @Description("{@@mv-core.debug.change.level.description}") + int level) { config.setGlobalDebug(level); config.save(); 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 da028dd8..8f576620 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java @@ -23,12 +23,12 @@ import org.mvplugins.multiverse.core.worldnew.WorldManager; @Service @CommandAlias("mv") -public class DeleteCommand extends MultiverseCommand { +class DeleteCommand extends MultiverseCommand { private final WorldManager worldManager; @Inject - public DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { super(commandManager); this.worldManager = worldManager; } @@ -38,14 +38,14 @@ public class DeleteCommand extends MultiverseCommand { @CommandCompletion("@mvworlds:scope=both") @Syntax("") @Description("{@@mv-core.delete.description}") - public void onDeleteCommand(MVCommandIssuer issuer, + void onDeleteCommand( + MVCommandIssuer issuer, - @Single - @Conditions("worldname:scope=both") - @Syntax("") - @Description("The world you want to delete.") - String worldName - ) { + @Single + @Conditions("worldname:scope=both") + @Syntax("") + @Description("The world you want to delete.") + String worldName) { this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand( issuer.getIssuer(), () -> { @@ -58,12 +58,7 @@ public class DeleteCommand extends MultiverseCommand { Logging.fine("World delete failure: " + failure); issuer.sendError(failure.getFailureMessage()); }); - }, - this.commandManager.formatMessage( - issuer, - MessageType.INFO, - MVCorei18n.DELETE_PROMPT, - "{world}", worldName) - )); + }, this.commandManager.formatMessage( + issuer, MessageType.INFO, MVCorei18n.DELETE_PROMPT, "{world}", worldName))); } } diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java index cbcb75d8..eaa0cd53 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java @@ -43,30 +43,33 @@ import static org.mvplugins.multiverse.core.utils.file.FileUtils.getServerProper @Service @CommandAlias("mv") -public class DumpsCommand extends MultiverseCommand { +class DumpsCommand extends MultiverseCommand { private final MultiverseCore plugin; private final WorldManager worldManager; + private final CommandValueFlag LOGS_FLAG = flag(CommandValueFlag + .enumBuilder("--logs", LogsTypeOption.class) + .addAlias("-l") + .build()); + + private final CommandValueFlag UPLOAD_FLAG = flag(CommandValueFlag + .enumBuilder("--upload", ServiceTypeOption.class) + .addAlias("-u") + .build()); + + // Does not upload logs or plugin list (except if --logs mclogs is there) + private final CommandFlag PARANOID_FLAG = flag(CommandFlag.builder("--paranoid") + .addAlias("-p") + .build()); + @Inject - public DumpsCommand(@NotNull MVCommandManager commandManager, + DumpsCommand(@NotNull MVCommandManager commandManager, @NotNull MultiverseCore plugin, @NotNull WorldManager worldManager) { super(commandManager); this.plugin = plugin; this.worldManager = worldManager; - - registerFlagGroup(CommandFlagGroup.builder("mvdumps") - .add(CommandValueFlag.enumBuilder("--logs", LogsTypeOption.class) - .addAlias("-l") - .build()) - .add(CommandValueFlag.enumBuilder("--upload", ServiceTypeOption.class) - .addAlias("-u") - .build()) - .add(CommandFlag.builder("--paranoid")// Does not upload logs or plugin list (except if --logs mclogs is there) - .addAlias("-p") - .build()) - .build()); } private enum ServiceTypeOption { @@ -81,21 +84,21 @@ public class DumpsCommand extends MultiverseCommand { @Subcommand("dumps") @CommandPermission("multiverse.core.dumps") - @CommandCompletion("@flags:groupName=mvdumps") + @CommandCompletion("@flags:groupName=mvdumpscommand") @Syntax("[--logs ] [--upload ] [--paranoid]") @Description("{@@mv-core.dumps.description}") - public void onDumpsCommand(CommandIssuer issuer, + void onDumpsCommand( + CommandIssuer issuer, - @Optional - @Syntax("[--logs ] [--upload ] [--paranoid]") - String[] flags - ) { + @Optional + @Syntax("[--logs ] [--upload ] [--paranoid]") + String[] flags) { final ParsedCommandFlags parsedFlags = parseFlags(flags); // Grab all our flags - final boolean paranoid = parsedFlags.hasFlag("--paranoid"); - final LogsTypeOption logsType = parsedFlags.flagValue("--logs", LogsTypeOption.MCLOGS, LogsTypeOption.class); - final ServiceTypeOption servicesType = parsedFlags.flagValue("--upload", ServiceTypeOption.PASTEGG, ServiceTypeOption.class); + final boolean paranoid = parsedFlags.hasFlag(PARANOID_FLAG); + final LogsTypeOption logsType = parsedFlags.flagValue(LOGS_FLAG, LogsTypeOption.MCLOGS); + final ServiceTypeOption servicesType = parsedFlags.flagValue(UPLOAD_FLAG, ServiceTypeOption.PASTEGG); // Initialise and add info to the debug event MVVersionEvent versionEvent = new MVVersionEvent(); @@ -119,8 +122,7 @@ public class DumpsCommand extends MultiverseCommand { switch (logsType) { case MCLOGS -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST, "{service}", "Logs", - "{link}", postToService(PasteServiceType.MCLOGS, true, getLogs(), null) - ); + "{link}", postToService(PasteServiceType.MCLOGS, true, getLogs(), null)); case APPEND -> versionEvent.putDetailedVersionInfo("latest.log", getLogs()); } } @@ -132,13 +134,10 @@ public class DumpsCommand extends MultiverseCommand { switch (servicesType) { case PASTEGG -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST, "{service}", "paste.gg", - "{link}", postToService(PasteServiceType.PASTEGG, true, null, files) - ); - + "{link}", postToService(PasteServiceType.PASTEGG, true, null, files)); case PASTESDEV -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST, "{service}", "pastes.dev", - "{link}", postToService(PasteServiceType.PASTESDEV, true, null, files) - ); + "{link}", postToService(PasteServiceType.PASTESDEV, true, null, files)); } } @@ -149,6 +148,7 @@ public class DumpsCommand extends MultiverseCommand { } /** + * Get the contents of the latest.log file * * @return A string containing the latest.log file */ @@ -222,7 +222,8 @@ public class DumpsCommand extends MultiverseCommand { } /** - * Turns a list of files in to a string containing askii art + * Turns a list of files in to a string containing askii art. + * * @param files Map of filenames/contents * @return The askii art */ 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 919023cc..0fad4434 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java @@ -22,10 +22,10 @@ import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; @Service @CommandAlias("mv") -public class GameruleCommand extends MultiverseCommand { +class GameruleCommand extends MultiverseCommand { @Inject - public GameruleCommand(@NotNull MVCommandManager commandManager) { + GameruleCommand(@NotNull MVCommandManager commandManager) { super(commandManager); } @@ -34,24 +34,24 @@ public class GameruleCommand extends MultiverseCommand { @CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*") @Syntax(" [World or *]") @Description("{@@mv-core.gamerule.description}") - public void onGameruleCommand(BukkitCommandIssuer issuer, + void onGameruleCommand( + BukkitCommandIssuer issuer, - @Syntax("") - @Description("{@@mv-core.gamerule.gamerule.description}") - GameRule gamerule, + @Syntax("") + @Description("{@@mv-core.gamerule.gamerule.description}") + GameRule gamerule, - @Syntax("") - @Description("{@@mv-core.gamerule.value.description}") - GameRuleValue gameRuleValue, + @Syntax("") + @Description("{@@mv-core.gamerule.value.description}") + GameRuleValue gameRuleValue, - @Flags("resolve=issuerAware") - @Syntax("[World or *]") - @Description("{@@mv-core.gamerule.world.description}") - LoadedMultiverseWorld[] worlds - ) { + @Flags("resolve=issuerAware") + @Syntax("[World or *]") + @Description("{@@mv-core.gamerule.world.description}") + LoadedMultiverseWorld[] worlds) { Object value = gameRuleValue.getValue(); boolean success = true; - for(LoadedMultiverseWorld world : worlds) { + for (LoadedMultiverseWorld world : worlds) { // Set gamerules and add false to list if it fails World bukkitWorld = world.getBukkitWorld().getOrNull(); if (bukkitWorld == null || !bukkitWorld.setGameRule(gamerule, value)) { @@ -70,8 +70,7 @@ public class GameruleCommand extends MultiverseCommand { "{gamerule}", gamerule.getName(), "{value}", value.toString(), "{world}", worlds[0].getName()); - } - else if (worlds.length > 1) { + } else if (worlds.length > 1) { issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_MULTIPLE, "{gamerule}", gamerule.getName(), "{value}", value.toString(), diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java index 7856b9bd..3de96f5c 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java @@ -40,7 +40,7 @@ import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; */ @Service @CommandAlias("mv") -public class GamerulesCommand extends MultiverseCommand { +class GamerulesCommand extends MultiverseCommand { private final CommandValueFlag PAGE_FLAG = flag(CommandValueFlag .builder("--page", Integer.class) @@ -76,7 +76,7 @@ public class GamerulesCommand extends MultiverseCommand { @CommandCompletion("@mvworlds|@flags:groupName=mvgamerulescommand @flags:groupName=mvgamerulescommand") @Syntax("[world] [--page ] [--filter ]") @Description("{@@mv-core.gamerules.description}") - public void onGamerulesCommand( + void onGamerulesCommand( @NotNull MVCommandIssuer issuer, @Flags("resolve=issuerAware") @@ -87,8 +87,7 @@ public class GamerulesCommand extends MultiverseCommand { @Optional @Syntax("[--page ] [--filter ]") @Description("{@@mv-core.gamerules.description.page}") - String[] flags - ) { + String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); ContentDisplay.create() 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 715a470a..7e594b17 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java @@ -11,6 +11,7 @@ import co.aikar.commands.annotation.Syntax; import com.dumptruckman.minecraft.util.Logging; import jakarta.inject.Inject; import org.bukkit.World; +import org.bukkit.WorldType; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; @@ -28,58 +29,59 @@ import org.mvplugins.multiverse.core.worldnew.options.ImportWorldOptions; @Service @CommandAlias("mv") -public class ImportCommand extends MultiverseCommand { +class ImportCommand extends MultiverseCommand { private final WorldManager worldManager; + private GeneratorProvider generatorProvider; + private final CommandValueFlag GENERATOR_FLAG = flag(CommandValueFlag + .builder("--generator", String.class) + .addAlias("-g") + .completion(input -> generatorProvider.suggestGeneratorString(input)) + .build()); + + private final CommandFlag NO_ADJUST_SPAWN_FLAG = flag(CommandFlag.builder("--no-adjust-spawn") + .addAlias("-n") + .build()); + @Inject - public ImportCommand( + ImportCommand( @NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager, - @NotNull GeneratorProvider generatorProvider - ) { + @NotNull GeneratorProvider generatorProvider) { super(commandManager); this.worldManager = worldManager; - - registerFlagGroup(CommandFlagGroup.builder("mvimport") - .add(CommandValueFlag.builder("--generator", String.class) - .addAlias("-g") - .completion(generatorProvider::suggestGeneratorString) - .build()) - .add(CommandFlag.builder("--adjust-spawn") - .addAlias("-a") - .build()) - .build()); + this.generatorProvider = generatorProvider; } @Subcommand("import") @CommandPermission("multiverse.core.import") - @CommandCompletion("@mvworlds:scope=potential @flags:groupName=mvimport") + @CommandCompletion("@mvworlds:scope=potential @flags:groupName=mvimportcommand") @Syntax(" --generator [generator[:id]] --adjust-spawn") @Description("{@@mv-core.import.description") - public void onImportCommand(MVCommandIssuer issuer, + void onImportCommand( + MVCommandIssuer issuer, - @Conditions("worldname:scope=new") - @Syntax("") - @Description("{@@mv-core.import.name.description}") - String worldName, + @Conditions("worldname:scope=new") + @Syntax("") + @Description("{@@mv-core.import.name.description}") + String worldName, - @Syntax("") - @Description("{@@mv-core.import.env.description}") - World.Environment environment, - - @Optional - @Syntax("--generator [generator[:id]] --adjust-spawn") - @Description("{@@mv-core.import.other.description}") - String[] flags) { + @Syntax("") + @Description("{@@mv-core.import.env.description}") + World.Environment environment, + @Optional + @Syntax("--generator [generator[:id]] --adjust-spawn") + @Description("{@@mv-core.import.other.description}") + String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); issuer.sendInfo(MVCorei18n.IMPORT_IMPORTING, "{world}", worldName); worldManager.importWorld(ImportWorldOptions.worldName(worldName) .environment(environment) - .generator(parsedFlags.flagValue("--generator", String.class)) - .useSpawnAdjust(parsedFlags.hasFlag("--adjust-spawn"))) + .generator(parsedFlags.flagValue(GENERATOR_FLAG, String.class)) + .useSpawnAdjust(!parsedFlags.hasFlag(NO_ADJUST_SPAWN_FLAG))) .onSuccess(newWorld -> { Logging.fine("World import success: " + newWorld); issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS, "{world}", newWorld.getName()); 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 64e2d1f6..d6477883 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java @@ -35,68 +35,68 @@ import org.mvplugins.multiverse.core.worldnew.entrycheck.WorldEntryCheckerProvid @Service @CommandAlias("mv") -public class ListCommand extends MultiverseCommand { +class ListCommand extends MultiverseCommand { private final WorldManager worldManager; private final WorldEntryCheckerProvider worldEntryCheckerProvider; + 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 - public ListCommand( + ListCommand( @NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager, - @NotNull WorldEntryCheckerProvider worldEntryCheckerProvider - ) { + @NotNull WorldEntryCheckerProvider worldEntryCheckerProvider) { super(commandManager); this.worldManager = worldManager; this.worldEntryCheckerProvider = worldEntryCheckerProvider; - - registerFlagGroup(CommandFlagGroup.builder("mvlist") - .add(CommandValueFlag.builder("--filter", ContentFilter.class) - .addAlias("-f") - .context((value) -> { - try { - return RegexContentFilter.fromString(value); - } catch (IllegalArgumentException e) { - throw new InvalidCommandArgument("Invalid filter: " + value); - } - }) - .build()) - .add(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()) - .build()); } @Subcommand("list") @CommandPermission("multiverse.core.list.worlds") - @CommandCompletion("@flags:groupName=mvlist") + @CommandCompletion("@flags:groupName=mvlistcommand") @Syntax("--filter [filter] --page [page]") @Description("Displays a listing of all worlds that you can enter.") - public void onListCommand(MVCommandIssuer issuer, + public void onListCommand( + MVCommandIssuer issuer, - @Syntax("--filter [filter] --page [page]") - @Description("Filters the list of worlds by the given regex and displays the given page.") - String[] flags - ) { + @Syntax("[--filter ] [--page ]") + @Description("Filters the list of worlds by the given regex and displays the given page.") + String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); ContentDisplay.create() .addContent(ListContentProvider.forContent(getListContents(issuer))) .withSendHandler(PagedSendHandler.create() .withHeader("%s====[ Multiverse World List ]====", ChatColor.GOLD) - .withTargetPage(parsedFlags.flagValue("--page", 1, Integer.class)) - .withFilter(parsedFlags.flagValue("--filter", DefaultContentFilter.get(), ContentFilter.class))) + .withTargetPage(parsedFlags.flagValue(PAGE_FLAG, 1)) + .withFilter(parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get()))) .send(issuer); } private List getListContents(MVCommandIssuer issuer) { - List worldList = new ArrayList<>(); + List worldList = new ArrayList<>(); WorldEntryChecker worldEntryChecker = worldEntryCheckerProvider.forSender(issuer.getIssuer()); worldManager.getLoadedWorlds().stream() 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 016163ac..c1a02bd9 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java @@ -21,12 +21,12 @@ import org.mvplugins.multiverse.core.worldnew.WorldManager; @Service @CommandAlias("mv") -public class LoadCommand extends MultiverseCommand { +class LoadCommand extends MultiverseCommand { private final WorldManager worldManager; @Inject - public LoadCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + LoadCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { super(commandManager); this.worldManager = worldManager; } @@ -36,14 +36,14 @@ public class LoadCommand extends MultiverseCommand { @CommandCompletion("@mvworlds:scope=unloaded") @Syntax("") @Description("{@@mv-core.load.description}") - public void onLoadCommand(MVCommandIssuer issuer, + void onLoadCommand( + MVCommandIssuer issuer, - @Single - @Conditions("worldname:scope=unloaded") - @Syntax("") - @Description("{@@mv-core.load.world.description}") - String worldName - ) { + @Single + @Conditions("worldname:scope=unloaded") + @Syntax("") + @Description("{@@mv-core.load.world.description}") + String worldName) { issuer.sendInfo(MVCorei18n.LOAD_LOADING, "{world}", worldName); worldManager.loadWorld(worldName) .onSuccess(newWorld -> { 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 51a25e29..591188da 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java @@ -20,7 +20,6 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag; -import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagGroup; import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag; import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; import org.mvplugins.multiverse.core.commandtools.queue.QueuedCommand; @@ -31,49 +30,49 @@ import org.mvplugins.multiverse.core.worldnew.options.RegenWorldOptions; @Service @CommandAlias("mv") -public class RegenCommand extends MultiverseCommand { +class RegenCommand extends MultiverseCommand { private final WorldManager worldManager; + private final CommandValueFlag SEED_FLAG = flag(CommandValueFlag.builder("--seed", String.class) + .addAlias("-s") + .completion(input -> Collections.singleton(String.valueOf(new Random().nextLong()))) + .build()); + + private final CommandFlag RESET_WORLD_CONFIG_FLAG = flag(CommandFlag.builder("--reset-world-config") + .addAlias("-wc") + .build()); + + private final CommandFlag RESET_GAMERULES_FLAG = flag(CommandFlag.builder("--reset-gamerules") + .addAlias("-gm") + .build()); + + private final CommandFlag RESET_WORLD_BORDER_FLAG = flag(CommandFlag.builder("--reset-world-border") + .addAlias("-wb") + .build()); + @Inject - public RegenCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + RegenCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { super(commandManager); this.worldManager = worldManager; - - registerFlagGroup(CommandFlagGroup.builder("mvregen") - .add(CommandValueFlag.builder("--seed", String.class) - .addAlias("-s") - .completion((input) -> Collections.singleton(String.valueOf(new Random().nextLong()))) - .optional() - .build()) - .add(CommandFlag.builder("--reset-world-config") - .addAlias("-wc") - .build()) - .add(CommandFlag.builder("--reset-gamerules") - .addAlias("-gm") - .build()) - .add(CommandFlag.builder("--reset-world-border") - .addAlias("-wb") - .build()) - .build()); } @Subcommand("regen") @CommandPermission("multiverse.core.regen") - @CommandCompletion("@mvworlds:scope=loaded @flags:groupName=mvregen") + @CommandCompletion("@mvworlds:scope=loaded @flags:groupName=mvregencommand") @Syntax(" --seed [seed] --keep-gamerules") @Description("{@@mv-core.regen.description}") - public void onRegenCommand(MVCommandIssuer issuer, + void onRegenCommand( + MVCommandIssuer issuer, - @Syntax("") - @Description("{@@mv-core.regen.world.description}") - LoadedMultiverseWorld world, + @Syntax("") + @Description("{@@mv-core.regen.world.description}") + LoadedMultiverseWorld world, - @Optional - @Syntax("--seed [seed] --reset-gamerules") - @Description("{@@mv-core.regen.other.description}") - String[] flags - ) { + @Optional + @Syntax("--seed [seed] --reset-gamerules") + @Description("{@@mv-core.regen.other.description}") + String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand( @@ -81,11 +80,11 @@ public class RegenCommand extends MultiverseCommand { () -> { issuer.sendInfo(MVCorei18n.REGEN_REGENERATING, "{world}", world.getName()); worldManager.regenWorld(RegenWorldOptions.world(world) - .randomSeed(parsedFlags.hasFlag("--seed")) - .seed(parsedFlags.flagValue("--seed", String.class)) - .keepWorldConfig(!parsedFlags.hasFlag("--reset-world-config")) - .keepGameRule(!parsedFlags.hasFlag("--reset-gamerules")) - .keepWorldBorder(!parsedFlags.hasFlag("--reset-world-border")) + .randomSeed(parsedFlags.hasFlag(SEED_FLAG)) + .seed(parsedFlags.flagValue(SEED_FLAG)) + .keepWorldConfig(!parsedFlags.hasFlag(RESET_WORLD_CONFIG_FLAG)) + .keepGameRule(!parsedFlags.hasFlag(RESET_GAMERULES_FLAG)) + .keepWorldBorder(!parsedFlags.hasFlag(RESET_WORLD_BORDER_FLAG)) ).onSuccess(newWorld -> { Logging.fine("World regen success: " + newWorld); issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, "{world}", newWorld.getName()); @@ -95,10 +94,6 @@ public class RegenCommand extends MultiverseCommand { }); }, this.commandManager.formatMessage( - issuer, - MessageType.INFO, - MVCorei18n.REGEN_PROMPT, - "{world}", world.getName()) - )); + issuer, MessageType.INFO, MVCorei18n.REGEN_PROMPT, "{world}", world.getName()))); } } 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 68bfc944..4ac7d85d 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java @@ -23,7 +23,7 @@ import org.mvplugins.multiverse.core.worldnew.WorldManager; @Service @CommandAlias("mv") -public class ReloadCommand extends MultiverseCommand { +class ReloadCommand extends MultiverseCommand { private final MVCoreConfig config; private final AnchorManager anchorManager; @@ -31,13 +31,12 @@ public class ReloadCommand extends MultiverseCommand { private final PluginManager pluginManager; @Inject - public ReloadCommand( + ReloadCommand( @NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config, @NotNull AnchorManager anchorManager, @NotNull WorldManager worldManager, - @NotNull PluginManager pluginManager - ) { + @NotNull PluginManager pluginManager) { super(commandManager); this.config = config; this.anchorManager = anchorManager; @@ -48,7 +47,7 @@ public class ReloadCommand extends MultiverseCommand { @Subcommand("reload") @CommandPermission("multiverse.core.reload") @Description("{@@mv-core.reload.description}") - public void onReloadCommand(@NotNull BukkitCommandIssuer issuer) { + void onReloadCommand(@NotNull BukkitCommandIssuer issuer) { issuer.sendInfo(MVCorei18n.RELOAD_RELOADING); try { // TODO: Make this all Try 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 92bae812..dcfd9a44 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java @@ -21,12 +21,12 @@ import org.mvplugins.multiverse.core.worldnew.WorldManager; @Service @CommandAlias("mv") -public class RemoveCommand extends MultiverseCommand { +class RemoveCommand extends MultiverseCommand { private final WorldManager worldManager; @Inject - public RemoveCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + RemoveCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { super(commandManager); this.worldManager = worldManager; } @@ -36,14 +36,14 @@ public class RemoveCommand extends MultiverseCommand { @CommandCompletion("@mvworlds:scope=both") @Syntax("") @Description("{@@mv-core.remove.description}") - public void onRemoveCommand(MVCommandIssuer issuer, + void onRemoveCommand( + MVCommandIssuer issuer, - @Single - @Conditions("mvworlds:scope=both") - @Syntax("") - @Description("{@@mv-core.remove.world.description}") - String worldName - ) { + @Single + @Conditions("mvworlds:scope=both") + @Syntax("") + @Description("{@@mv-core.remove.world.description}") + String worldName) { worldManager.removeWorld(worldName) .onSuccess(removedWorldName -> { Logging.fine("World remove success: " + removedWorldName); diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RootCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RootCommand.java index 5cc31057..4d0bb326 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RootCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RootCommand.java @@ -14,18 +14,18 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.utils.MVCorei18n; @Service -public class RootCommand extends MultiverseCommand { +class RootCommand extends MultiverseCommand { private final Plugin plugin; @Inject - public RootCommand(@NotNull MVCommandManager commandManager, @NotNull MultiverseCore plugin) { + RootCommand(@NotNull MVCommandManager commandManager, @NotNull MultiverseCore plugin) { super(commandManager); this.plugin = plugin; } @CommandAlias("mv") - public void onRootCommand(CommandIssuer issuer) { + void onRootCommand(CommandIssuer issuer) { PluginDescriptionFile description = this.plugin.getDescription(); issuer.sendInfo(MVCorei18n.ROOT_TITLE, "{name}", description.getName(), diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java index 8c7c1502..b9c2a0b5 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java @@ -26,13 +26,13 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n; @Service @CommandAlias("mv") -public class TeleportCommand extends MultiverseCommand { +class TeleportCommand extends MultiverseCommand { private final CorePermissionsChecker permissionsChecker; private final AsyncSafetyTeleporter safetyTeleporter; @Inject - public TeleportCommand( + TeleportCommand( @NotNull MVCommandManager commandManager, @NotNull CorePermissionsChecker permissionsChecker, @NotNull AsyncSafetyTeleporter safetyTeleporter) { @@ -46,7 +46,7 @@ public class TeleportCommand extends MultiverseCommand { @CommandCompletion("@players|@mvworlds:playerOnly|@destinations:playerOnly @mvworlds|@destinations") @Syntax("[player] ") @Description("{@@mv-core.teleport.description}") - public void onTeleportCommand( + void onTeleportCommand( MVCommandIssuer issuer, @Flags("resolve=issuerAware") 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 e82120f6..9507e19e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java @@ -24,7 +24,7 @@ import org.mvplugins.multiverse.core.worldnew.options.UnloadWorldOptions; @Service @CommandAlias("mv") -public class UnloadCommand extends MultiverseCommand { +class UnloadCommand extends MultiverseCommand { private final WorldManager worldManager; @@ -37,7 +37,7 @@ public class UnloadCommand extends MultiverseCommand { .build()); @Inject - public UnloadCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + UnloadCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { super(commandManager); this.worldManager = worldManager; } @@ -47,7 +47,7 @@ public class UnloadCommand extends MultiverseCommand { @CommandCompletion("@mvworlds @flags:groupName=mvunloadcommand") @Syntax("") @Description("{@@mv-core.unload.description}") - public void onUnloadCommand( + void onUnloadCommand( MVCommandIssuer issuer, @Syntax("") diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/UsageCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/UsageCommand.java index 93c4b7a6..a27e3a5e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/UsageCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/UsageCommand.java @@ -17,10 +17,10 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; @Service @CommandAlias("mv") -public class UsageCommand extends MultiverseCommand { +class UsageCommand extends MultiverseCommand { @Inject - public UsageCommand(@NotNull MVCommandManager commandManager) { + UsageCommand(@NotNull MVCommandManager commandManager) { super(commandManager); } @@ -30,7 +30,7 @@ public class UsageCommand extends MultiverseCommand { @CommandCompletion("@commands:mv") @Syntax("[filter] [page]") @Description("{@@mv-core.usage.description}") - public void onUsageCommand(CommandHelp help) { + void onUsageCommand(CommandHelp help) { if (help.getIssuer().isPlayer()) { // Prevent flooding the chat help.setPerPage(4); diff --git a/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/CommandValueFlag.java b/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/CommandValueFlag.java index 0301b4ab..4b75eb22 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/CommandValueFlag.java +++ b/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/CommandValueFlag.java @@ -263,7 +263,7 @@ public class CommandValueFlag extends CommandFlag { * @return The flag. */ @Override - public @NotNull CommandFlag build() { + public @NotNull CommandValueFlag build() { return new CommandValueFlag<>(key, aliases, type, optional, defaultValue, context, completion); } } diff --git a/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/ParsedCommandFlags.java b/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/ParsedCommandFlags.java index 9b124235..d9c47994 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/ParsedCommandFlags.java +++ b/src/main/java/org/mvplugins/multiverse/core/commandtools/flags/ParsedCommandFlags.java @@ -83,6 +83,17 @@ public class ParsedCommandFlags return (T) value; } + /** + * Get the value of a flag. + * + * @param The type of the value. + * @param flag The flag to get the value of. + * @return The value of the flag, default value if flag does not exist or no value. + */ + public @Nullable T flagValue(@NotNull CommandValueFlag flag) { + return flagValue(flag.getKey(), flag.getType()); + } + /** * Get the value of a flag. *