diff --git a/pom.xml b/pom.xml
index d8d98f855..2665c9a07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.onarandombox.multiversecore
Multiverse-Core
- 4.2.3-SNAPSHOT
+ 5.0.0-SNAPSHOT
Multiverse-Core
World Management Plugin
@@ -13,7 +13,7 @@
-
+
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
@@ -38,6 +38,10 @@
CodeMC
https://repo.codemc.org/repository/maven-public
+
+ aikar
+ https://repo.aikar.co/content/groups/aikar/
+
@@ -228,10 +232,6 @@
me.main__.util
com.onarandombox.serializationconfig
-
- com.pneumaticraft.commandhandler
- com.onarandombox.commandhandler
-
buscript
com.onarandombox.buscript
@@ -256,6 +256,14 @@
de.themoep.idconverter
com.onarandombox.idconverter
+
+ co.aikar.commands
+ com.onarandombox.acf
+
+
+ co.aikar.locales
+ com.onarandombox.locales
+
@@ -313,9 +321,9 @@
- com.pneumaticraft.commandhandler
- CommandHandler
- 11
+ co.aikar
+ acf-paper
+ 0.5.0-SNAPSHOT
com.dumptruckman.minecraft
@@ -392,12 +400,12 @@
- OnARandomBox
- http://repo.onarandombox.com/content/repositories/multiverse
+ benergy10
+ http://repo.benergy10.dev/repository/minecraft/
- OnARandomBox
- http://repo.onarandombox.com/content/repositories/multiverse-snapshots/
+ benergy10
+ http://repo.benergy10.dev/repository/minecraft-snapshots/
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
index d7367ad20..4db929421 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
@@ -28,7 +28,6 @@
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
-import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
@@ -37,11 +36,11 @@
import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONObject;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.logging.Level;
/**
* The implementation of a Multiverse handled world.
@@ -1133,6 +1132,14 @@ public boolean getBedRespawn() {
return this.props.getBedRespawn();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Collection getAllPropertyTypes() {
+ return this.props.serialize().keySet();
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
index df00fbe69..0b3c7ba4e 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
@@ -7,21 +7,6 @@
package com.onarandombox.MultiverseCore;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
import buscript.Buscript;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
@@ -33,41 +18,8 @@
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
-import com.onarandombox.MultiverseCore.commands.AnchorCommand;
-import com.onarandombox.MultiverseCore.commands.CheckCommand;
-import com.onarandombox.MultiverseCore.commands.CloneCommand;
-import com.onarandombox.MultiverseCore.commands.ConfigCommand;
-import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
-import com.onarandombox.MultiverseCore.commands.CoordCommand;
-import com.onarandombox.MultiverseCore.commands.CreateCommand;
-import com.onarandombox.MultiverseCore.commands.DebugCommand;
-import com.onarandombox.MultiverseCore.commands.DeleteCommand;
-import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
-import com.onarandombox.MultiverseCore.commands.GameruleCommand;
-import com.onarandombox.MultiverseCore.commands.GamerulesCommand;
-import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
-import com.onarandombox.MultiverseCore.commands.HelpCommand;
-import com.onarandombox.MultiverseCore.commands.ImportCommand;
-import com.onarandombox.MultiverseCore.commands.InfoCommand;
-import com.onarandombox.MultiverseCore.commands.ListCommand;
-import com.onarandombox.MultiverseCore.commands.LoadCommand;
-import com.onarandombox.MultiverseCore.commands.ModifyAddCommand;
-import com.onarandombox.MultiverseCore.commands.ModifyClearCommand;
-import com.onarandombox.MultiverseCore.commands.ModifyCommand;
-import com.onarandombox.MultiverseCore.commands.ModifyRemoveCommand;
-import com.onarandombox.MultiverseCore.commands.ModifySetCommand;
-import com.onarandombox.MultiverseCore.commands.PurgeCommand;
-import com.onarandombox.MultiverseCore.commands.RegenCommand;
-import com.onarandombox.MultiverseCore.commands.ReloadCommand;
-import com.onarandombox.MultiverseCore.commands.RemoveCommand;
-import com.onarandombox.MultiverseCore.commands.ScriptCommand;
-import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
-import com.onarandombox.MultiverseCore.commands.SilentCommand;
-import com.onarandombox.MultiverseCore.commands.SpawnCommand;
-import com.onarandombox.MultiverseCore.commands.TeleportCommand;
-import com.onarandombox.MultiverseCore.commands.UnloadCommand;
-import com.onarandombox.MultiverseCore.commands.VersionCommand;
-import com.onarandombox.MultiverseCore.commands.WhoCommand;
+import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
+import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
import com.onarandombox.MultiverseCore.destination.BedDestination;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
@@ -94,22 +46,20 @@
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.MaterialConverter;
-import com.onarandombox.MultiverseCore.utils.TestingMode;
-import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
+import com.onarandombox.MultiverseCore.utils.TestingMode;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import com.onarandombox.MultiverseCore.utils.WorldManager;
-import com.pneumaticraft.commandhandler.CommandHandler;
+import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
import me.main__.util.SerializationConfig.NoSuchPropertyException;
import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Location;
-import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
@@ -122,6 +72,19 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+
/**
* The implementation of the Multiverse-{@link Core}.
*/
@@ -203,7 +166,7 @@ public int getProtocolVersion() {
}
// Setup our Map for our Commands using the CommandHandler.
- private CommandHandler commandHandler;
+ private MVCommandManager commandManager;
private static final String LOG_TAG = "[Multiverse-Core]";
@@ -255,8 +218,9 @@ public void onLoad() {
// Setup our SafeTTeleporter
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
this.unsafeCallWrapper = new UnsafeCallWrapper(this);
- // Setup our CompatibilityLayer
+ // Setup our static classes
CompatibilityLayer.init();
+ CoreFlags.setCoreInstance(this);
}
@@ -286,12 +250,7 @@ public void onEnable() {
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
this.ph = new MVPermissions(this);
- // Setup the command manager
- this.commandHandler = new CommandHandler(this, this.ph);
- // Call the Function to assign all the Commands to their Class.
- this.registerCommands();
-
- // Initialize the Destination factor AFTER the commands
+ // Initialize the Destination factory
this.initializeDestinationFactory();
this.playerSessions = new HashMap();
@@ -337,6 +296,9 @@ public void onEnable() {
this.initializeBuscript();
this.setupMetrics();
+ // Setup commands
+ this.commandManager = new MVCommandManager(this);
+
// Output a little snippet to show it's enabled.
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
@@ -744,51 +706,6 @@ public MultiverseMessaging getMessaging() {
return this.messaging;
}
- /**
- * Register Multiverse-Core commands to Command Manager.
- */
- private void registerCommands() {
- // Intro Commands
- this.commandHandler.registerCommand(new HelpCommand(this));
- this.commandHandler.registerCommand(new VersionCommand(this));
- this.commandHandler.registerCommand(new ListCommand(this));
- this.commandHandler.registerCommand(new InfoCommand(this));
- this.commandHandler.registerCommand(new CreateCommand(this));
- this.commandHandler.registerCommand(new CloneCommand(this));
- this.commandHandler.registerCommand(new ImportCommand(this));
- this.commandHandler.registerCommand(new ReloadCommand(this));
- this.commandHandler.registerCommand(new SetSpawnCommand(this));
- this.commandHandler.registerCommand(new CoordCommand(this));
- this.commandHandler.registerCommand(new TeleportCommand(this));
- this.commandHandler.registerCommand(new WhoCommand(this));
- this.commandHandler.registerCommand(new SpawnCommand(this));
- // Dangerous Commands
- this.commandHandler.registerCommand(new UnloadCommand(this));
- this.commandHandler.registerCommand(new LoadCommand(this));
- this.commandHandler.registerCommand(new RemoveCommand(this));
- this.commandHandler.registerCommand(new DeleteCommand(this));
- this.commandHandler.registerCommand(new RegenCommand(this));
- this.commandHandler.registerCommand(new ConfirmCommand(this));
- // Modification commands
- this.commandHandler.registerCommand(new ModifyCommand(this));
- this.commandHandler.registerCommand(new PurgeCommand(this));
- this.commandHandler.registerCommand(new ModifyAddCommand(this));
- this.commandHandler.registerCommand(new ModifySetCommand(this));
- this.commandHandler.registerCommand(new ModifyRemoveCommand(this));
- this.commandHandler.registerCommand(new ModifyClearCommand(this));
- this.commandHandler.registerCommand(new ConfigCommand(this));
- this.commandHandler.registerCommand(new AnchorCommand(this));
- // Misc Commands
- this.commandHandler.registerCommand(new EnvironmentCommand(this));
- this.commandHandler.registerCommand(new DebugCommand(this));
- this.commandHandler.registerCommand(new SilentCommand(this));
- this.commandHandler.registerCommand(new GeneratorCommand(this));
- this.commandHandler.registerCommand(new CheckCommand(this));
- this.commandHandler.registerCommand(new ScriptCommand(this));
- this.commandHandler.registerCommand(new GameruleCommand(this));
- this.commandHandler.registerCommand(new GamerulesCommand(this));
- }
-
/**
* {@inheritDoc}
*/
@@ -819,30 +736,6 @@ public MVPermissions getMVPerms() {
return this.ph;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
- if (!this.isEnabled()) {
- sender.sendMessage("This plugin is Disabled!");
- return true;
- }
- ArrayList allArgs = new ArrayList(Arrays.asList(args));
- allArgs.add(0, command.getName());
- try {
- return this.commandHandler.locateAndRunCommand(sender, allArgs, getMVConfig().getDisplayPermErrors());
- } catch (Exception e) {
- e.printStackTrace();
- sender.sendMessage(ChatColor.RED + "An internal error occurred when attempting to perform this command.");
- if (sender.isOp())
- sender.sendMessage(ChatColor.RED + "Details were printed to the server console and logs, please add that to your bug report.");
- else
- sender.sendMessage(ChatColor.RED + "Try again and contact the server owner or an admin if this problem persists.");
- return true;
- }
- }
-
/**
* {@inheritDoc}
*
@@ -911,10 +804,11 @@ public String getAuthors() {
/**
* {@inheritDoc}
+ * @return
*/
@Override
- public CommandHandler getCommandHandler() {
- return this.commandHandler;
+ public MVCommandManager getMVCommandManager() {
+ return commandManager;
}
/**
@@ -981,18 +875,6 @@ public DestinationFactory getDestFactory() {
return this.destFactory;
}
- /**
- * This is a convenience method to allow the QueuedCommand system to call it. You should NEVER call this directly.
- *
- * @param teleporter The Person requesting that the teleport should happen.
- * @param p Player The Person being teleported.
- * @param l The potentially unsafe location.
- */
- public void teleportPlayer(CommandSender teleporter, Player p, Location l) {
- // This command is the override, and MUST NOT TELEPORT SAFELY
- this.getSafeTTeleporter().safelyTeleport(teleporter, p, l, false);
- }
-
/**
* Gets the server's root-folder as {@link File}.
*
@@ -1091,40 +973,6 @@ public boolean saveMVConfigs() {
return this.saveMVConfig() && this.saveWorldConfig();
}
- /**
- * NOT deprecated for the time as queued commands use this.
- * However, this is not in the API and other plugins should therefore not use it.
- *
- * @param name World to delete
- * @return True if success, false if fail.
- */
- public Boolean deleteWorld(String name) {
- return this.worldManager.deleteWorld(name);
- }
-
- /**
- * NOT deprecated for the time as queued commands use this.
- * However, this is not in the API and other plugins should therefore not use it.
- *
- * @param oldName World to copy
- * @param newName World to create
- * @param generator The Custom generator plugin to use.
- * @return True if success, false if fail.
- */
- public Boolean cloneWorld(String oldName, String newName, String generator) {
- return this.worldManager.cloneWorld(oldName, newName, generator);
- }
-
- /**
- * {@inheritDoc}
- * @deprecated This is deprecated!
- */
- @Override
- @Deprecated
- public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed) {
- return this.worldManager.regenWorld(name, useNewSeed, randomSeed, seed);
- }
-
/**
* {@inheritDoc}
*/
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/Core.java b/src/main/java/com/onarandombox/MultiverseCore/api/Core.java
index ff8513d4c..0e4d43a4c 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/Core.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/Core.java
@@ -8,6 +8,7 @@
package com.onarandombox.MultiverseCore.api;
import buscript.Buscript;
+import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
@@ -17,7 +18,6 @@
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
-import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.entity.Player;
/**
@@ -79,12 +79,12 @@ public interface Core {
MVPermissions getMVPerms();
/**
- * Multiverse uses {@link CommandHandler} to make adding and using commands
+ * Multiverse uses {@link MVCommandManager} to make adding and using commands
* a piece of cake.
*
- * @return A non-null {@link CommandHandler}.
+ * @return A non-null {@link MVCommandManager}.
*/
- CommandHandler getCommandHandler();
+ MVCommandManager getMVCommandManager();
/**
* Gets the factory class responsible for loading many different destinations
@@ -115,21 +115,6 @@ public interface Core {
*/
AnchorManager getAnchorManager();
- /**
- * Used by queued commands to regenerate a world on a delay.
- *
- * @param name Name of the world to regenerate
- * @param useNewSeed If a new seed should be used
- * @param randomSeed IF the new seed should be random
- * @param seed The seed of the world.
- *
- * @return True if success, false if fail.
- *
- * @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String)} instead.
- */
- @Deprecated
- Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
-
/**
* Decrements the number of plugins that have specifically hooked into core.
*/
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java b/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java
deleted file mode 100644
index abc740db0..000000000
--- a/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
- * Multiverse 2 is licensed under the BSD License. *
- * For more information please check the README.md file included *
- * with this project. *
- ******************************************************************************/
-
-package com.onarandombox.MultiverseCore.api;
-
-/**
- * A fancy text.
- */
-public interface FancyText {
- /**
- * Gets the {@link String}-representation of this {@link FancyText}.
- *
- * @return The {@link String}-representation of this {@link FancyText}.
- */
- String getFancyText();
-}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java b/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java
index e246c8da1..eca3ec932 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java
@@ -40,6 +40,14 @@ public interface LocationManipulation {
*/
Location stringToLocation(String locationString);
+ /**
+ * Returns a colored string with x, y, z axis.
+ *
+ * @param l The {@link Location}
+ * @return The {@link String}
+ */
+ String strAxis(Location l);
+
/**
* Returns a colored string with the coords.
*
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
index 3eb96e2d5..0d13a825d 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
@@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.api;
+import com.onarandombox.MultiverseCore.enums.WorldValidationResult;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
import org.bukkit.World;
@@ -314,4 +315,20 @@ boolean addWorld(String name, Environment env, String seedString, WorldType type
* does not exist. {@code includeLoaded} if the world exists and is loaded.
*/
boolean hasUnloadedWorld(String name, boolean includeLoaded);
+
+ /**
+ * Check if a world name is a possible importable world folder.
+ *
+ * @param worldName Name of the world you want to check.
+ * @return True if world is valid, false otherwise.
+ */
+ boolean isValidWorld(String worldName);
+
+ /**
+ * Check if a world name is a possible importable world folder.
+ *
+ * @param worldName Name of the world you want to check.
+ * @return WorldValidationResult.VALID if world is valid, else the reason why its not valid.
+ */
+ WorldValidationResult validateWorld(String worldName);
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiversePlugin.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiversePlugin.java
index a6a064b8a..c518687cd 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiversePlugin.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiversePlugin.java
@@ -1,20 +1,14 @@
package com.onarandombox.MultiverseCore.api;
+import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.utils.DebugLog;
+import org.bukkit.plugin.java.JavaPlugin;
+
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.utils.DebugLog;
-import com.pneumaticraft.commandhandler.CommandHandler;
-
/**
* Make things easier for MV-Plugins!
*/
@@ -96,25 +90,6 @@ protected String getAuthors() {
*/
protected abstract void onPluginEnable();
- /**
- * You can register commands here.
- * @param handler The CommandHandler.
- */
- protected abstract void registerCommands(CommandHandler handler);
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!this.isEnabled()) {
- sender.sendMessage("This plugin is Disabled!");
- return true;
- }
-
- ArrayList allArgs = new ArrayList(args.length + 1);
- allArgs.add(command.getName());
- allArgs.addAll(Arrays.asList(args));
- return this.getCore().getCommandHandler().locateAndRunCommand(sender, allArgs);
- }
-
@Override
public void log(Level level, String msg) {
int debugLevel = this.getCore().getMVConfig().getGlobalDebug();
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
index 07ba347f3..fa82e5c08 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
@@ -16,10 +16,10 @@
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldType;
-import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.jetbrains.annotations.Nullable;
+import java.util.Collection;
import java.util.List;
/**
@@ -651,6 +651,13 @@ public interface MultiverseWorld {
*/
List getWorldBlacklist();
+ /**
+ * Gets all the names of all properties that can be SET.
+ *
+ * @return All property names in list.
+ */
+ Collection getAllPropertyTypes();
+
/**
* Gets all the names of all properties that can be SET.
*
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/PermissionsInterface.java b/src/main/java/com/onarandombox/MultiverseCore/api/PermissionsInterface.java
new file mode 100644
index 000000000..758ea87bd
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/PermissionsInterface.java
@@ -0,0 +1,13 @@
+package com.onarandombox.MultiverseCore.api;
+
+import org.bukkit.command.CommandSender;
+
+import java.util.List;
+
+public interface PermissionsInterface {
+ public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired);
+
+ public boolean hasAnyPermission(CommandSender sender, List allPermissionStrings, boolean opRequired);
+
+ public boolean hasAllPermission(CommandSender sender, List allPermissionStrings, boolean opRequired);
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
index 55d0b2cff..998e2e0da 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
+ * Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
@@ -7,156 +7,127 @@
package com.onarandombox.MultiverseCore.commands;
+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.Flags;
+import co.aikar.commands.annotation.Single;
+import co.aikar.commands.annotation.Subcommand;
+import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.api.MultiverseWorld;
+import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
+import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
+import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
+import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
+import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
+import com.onarandombox.MultiverseCore.utils.AnchorManager;
import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.permissions.Permission;
-import org.bukkit.permissions.PermissionDefault;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import java.util.Set;
-/**
- * Allows management of Anchor Destinations.
- */
-public class AnchorCommand extends PaginatedCoreCommand {
+@CommandAlias("mv")
+@Subcommand("anchors")
+public class AnchorCommand extends MultiverseCoreCommand {
+
+ private final AnchorManager anchorManager;
public AnchorCommand(MultiverseCore plugin) {
super(plugin);
- this.setName("Create, Delete and Manage Anchor Destinations.");
- this.setCommandUsage("/mv anchor " + ChatColor.GREEN + "{name}" + ChatColor.GOLD + " [-d]");
- this.setArgRange(0, 2);
- this.addKey("mv anchor");
- this.addKey("mv anchors");
- this.addKey("mvanchor");
- this.addKey("mvanchors");
- this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething");
- this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
- this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
- this.addCommandExample("/mv anchors ");
- this.setPermission("multiverse.core.anchor.list", "Allows a player to list all anchors.", PermissionDefault.OP);
- this.addAdditonalPermission(new Permission("multiverse.core.anchor.create",
- "Allows a player to create anchors.", PermissionDefault.OP));
- this.addAdditonalPermission(new Permission("multiverse.core.anchor.delete",
- "Allows a player to delete anchors.", PermissionDefault.OP));
- this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
+ this.anchorManager = plugin.getAnchorManager();
}
- private List getFancyAnchorList(Player p) {
- List anchorList = new ArrayList();
- ChatColor color = ChatColor.GREEN;
- for (String anchor : this.plugin.getAnchorManager().getAnchors(p)) {
- anchorList.add(color + anchor);
- color = (color == ChatColor.GREEN) ? ChatColor.GOLD : ChatColor.GREEN;
- }
- return anchorList;
- }
+ @Subcommand("create")
+ @CommandPermission("multiverse.core.anchor.create")
+ @Syntax("")
+ @Description("Create a new anchor point.")
+ public void onCreateAnchorCommand(@NotNull Player player,
- private void showList(CommandSender sender, List args) {
- if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.list", true)) {
- sender.sendMessage(ChatColor.RED + "You don't have the permission to list anchors!");
- return;
- }
+ @NotNull
+ @Syntax("")
+ @Description("Name of your new anchor.")
+ @Flags("type=anchor name")
+ @Single String anchorName) {
- sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
- Player p = null;
- if (sender instanceof Player) {
- p = (Player) sender;
- }
+ player.sendMessage((this.plugin.getAnchorManager().saveAnchorLocation(anchorName, player.getLocation()))
+ ? String.format("Anchor '%s%s%s' was successfully %s created!",
+ ChatColor.AQUA, anchorName, ChatColor.WHITE, ChatColor.GREEN)
- FilterObject filterObject = this.getPageAndFilter(args);
+ : String.format("%sThere was an error creating anchor '%s'! Check console for errors.",
+ ChatColor.RED, anchorName));
- List availableAnchors = new ArrayList(this.getFancyAnchorList(p));
- if (filterObject.getFilter().length() > 0) {
- availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
- if (availableAnchors.size() == 0) {
- sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
- + "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
- return;
- }
- } else {
- if (availableAnchors.size() == 0) {
- sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors were defined.");
- return;
- }
- }
+ }
+ @Subcommand("delete")
+ @CommandPermission("multiverse.core.anchor.delete")
+ @Syntax("")
+ @CommandCompletion("@anchors")
+ @Description("Delete an existing anchor point.")
+ public void onDeleteAnchorCommand(@NotNull CommandSender sender,
- if (!(sender instanceof Player)) {
- for (String c : availableAnchors) {
- sender.sendMessage(c);
- }
- return;
- }
+ @NotNull
+ @Syntax("")
+ @Description("Name of anchor you want to delete.")
+ @Flags("type=anchor name")
+ @Single String anchorName) {
- int totalPages = (int) Math.ceil(availableAnchors.size() / (this.itemsPerPage + 0.0));
+ sender.sendMessage((this.plugin.getAnchorManager().deleteAnchor(anchorName))
- if (filterObject.getPage() > totalPages) {
- filterObject.setPage(totalPages);
- } else if (filterObject.getPage() < 1) {
- filterObject.setPage(1);
- }
+ ? String.format("Anchor '%s%s%s' was successfully %s deleted!",
+ ChatColor.AQUA, anchorName, ChatColor.WHITE, ChatColor.RED)
- sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
-
- this.showPage(filterObject.getPage(), sender, availableAnchors);
+ : String.format("%sThere was an error deleting anchor '%s'! Check console for errors.",
+ ChatColor.RED, anchorName));
}
- @Override
- public void runCommand(CommandSender sender, List args) {
- if (args.size() == 0) {
- this.showList(sender, args);
- return;
- }
- if (args.size() == 1 && (this.getPageAndFilter(args).getPage() != 1 || args.get(0).equals("1"))) {
- this.showList(sender, args);
- return;
- }
- if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
- if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) {
- sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!");
- } else {
- if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
- sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
- } else {
- sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
- }
- }
- return;
- }
-
- if (!(sender instanceof Player)) {
- sender.sendMessage("You must be a player to create Anchors.");
- return;
- }
-
- if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) {
- sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!");
- } else {
- Player player = (Player) sender;
- if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
- sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
- } else {
- sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
- }
- }
+ @Subcommand("list")
+ @CommandPermission("multiverse.core.anchor.list")
+ @Syntax("[filter] [page]")
+ @Description("View a list of current anchors.")
+ public void onListAnchorCommand(@NotNull CommandSender sender,
+ @NotNull PageFilter pageFilter) {
+
+ new ContentDisplay.Builder>()
+ .sender(sender)
+ .header("%s====[ Multiverse Anchor List ]====", ChatColor.LIGHT_PURPLE)
+ .contents(buildAnchorList(sender))
+ .emptyMessage("You do not any anchors set. See /mv anchors create to get started!")
+ .displayHandler(DisplayHandlers.PAGE_LIST)
+ .colorTool(ColorAlternator.with(ChatColor.YELLOW, ChatColor.DARK_AQUA))
+ .setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
+ .display();
}
- @Override
- protected List getFilteredItems(List availableItems, String filter) {
- List filtered = new ArrayList();
- for (String s : availableItems) {
- if (s.matches("(?i).*" + filter + ".*")) {
- filtered.add(s);
+ private List buildAnchorList(@NotNull CommandSender sender) {
+ Set anchors = (sender instanceof Player)
+ ? this.anchorManager.getAnchors((Player) sender)
+ : this.anchorManager.getAllAnchors();
+
+ List anchorContent = new ArrayList<>();
+ for (String anchor : anchors) {
+ Location anchorLocation = this.anchorManager.getAnchorLocation(anchor);
+ World world = anchorLocation.getWorld(); // this.plugin.getMVWorldManager().getMVWorld();
+
+ String locationString = ChatColor.RED + "!!INVALID!!";
+ if (world != null) {
+ MultiverseWorld mvWorld = this.plugin.getMVWorldManager().getMVWorld(world);
+ locationString = (mvWorld == null)
+ ? String.format("%s%s !!NOT MULTIVERSE WORLD!!", ChatColor.RED, world.getName())
+ : String.format("%s - %s", mvWorld.getColoredWorldString(), this.plugin.getLocationManipulation().strAxis(anchorLocation));
}
+ anchorContent.add(String.format("%s: %s", anchor, locationString));
}
- return filtered;
- }
- @Override
- protected String getItemText(String item) {
- return item;
+ return anchorContent;
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/BedCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/BedCommand.java
new file mode 100644
index 000000000..492aade72
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/BedCommand.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Multiverse 2 Copyright (c) the Multiverse Team 2020. *
+ * Multiverse 2 is licensed under the BSD License. *
+ * For more information please check the README.md file included *
+ * with this project. *
+ ******************************************************************************/
+
+package com.onarandombox.MultiverseCore.commands;
+
+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.Subcommand;
+import co.aikar.commands.annotation.Syntax;
+import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+@CommandAlias("mv")
+public class BedCommand extends MultiverseCoreCommand {
+
+ public BedCommand(MultiverseCore plugin) {
+ super(plugin);
+ }
+
+ @Subcommand("bed")
+ @CommandPermission("multiverse.core.bed.self")
+ @Description("Takes your current respawn point.")
+ public void onBedCommand(@NotNull Player player) {
+ doBedRespawn(player, player);
+ }
+
+ @Subcommand("bed")
+ @CommandPermission("multiverse.core.bed.other")
+ @Syntax("[player]")
+ @CommandCompletion("@players")
+ @Description("Takes another player to their respawn location.")
+ public void onOtherBedCommand(@NotNull CommandSender sender,
+
+ @Syntax("[player]")
+ @Description("Target player to teleport to respawn location.")
+ @NotNull RequiredPlayer player) {
+
+ doBedRespawn(sender, player.get());
+ }
+
+ private void doBedRespawn(@NotNull CommandSender sender,
+ @NotNull Player player) {
+
+ Location bedLocation = player.getBedSpawnLocation();
+ if (bedLocation == null) {
+ sender.sendMessage(String.format("%sYou do not have a respawn point set!", ChatColor.RED));
+ return;
+ }
+ sender.sendMessage((player.teleport(bedLocation))
+ ? "You have been teleported to your respawn point!"
+ : String.format("%sThere was an error teleporting you to your respawn point.", ChatColor.RED));
+ }
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
index 34fa77914..de9f65926 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
+ * Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
@@ -7,51 +7,42 @@
package com.onarandombox.MultiverseCore.commands;
+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.Subcommand;
+import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
-import com.onarandombox.MultiverseCore.destination.InvalidDestination;
-import com.onarandombox.MultiverseCore.utils.MVPermissions;
-import org.bukkit.ChatColor;
+import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.permissions.PermissionDefault;
+import org.jetbrains.annotations.NotNull;
-import java.util.List;
-/**
- * Checks to see if a player can go to a destination.
- */
-public class CheckCommand extends MultiverseCommand {
+@CommandAlias("mv")
+public class CheckCommand extends MultiverseCoreCommand {
public CheckCommand(MultiverseCore plugin) {
super(plugin);
- this.setName("Help you validate your multiverse settings");
- this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}");
- this.setArgRange(2, 2);
- this.addKey("mv check");
- this.addKey("mvcheck");
- this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld");
- this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
- this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
- this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
}
- @Override
- public void runCommand(CommandSender sender, List args) {
- Player p = this.plugin.getServer().getPlayerExact(args.get(0));
- if (p == null) {
- sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
- sender.sendMessage("Are they online?");
- return;
- }
- MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
- if (dest instanceof InvalidDestination) {
- sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,",
- args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE));
- sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
- return;
- }
-
- MVPermissions perms = this.plugin.getMVPerms();
- perms.tellMeWhyICantDoThis(sender, p, dest);
+ @Subcommand("check")
+ @CommandPermission("multiverse.core.debug")
+ @Syntax(" ")
+ @CommandCompletion("@players @destinations|@MVWorlds")
+ @Description("Checks to see if a player can go to a destination. Prints debug if false.")
+ public void onCheckCommand(@NotNull CommandSender sender,
+
+ @NotNull
+ @Syntax("")
+ @Description("Player to check destination on.")
+ RequiredPlayer player,
+
+ @NotNull
+ @Syntax("")
+ @Description("A destination location, e.g. a world name.")
+ MVDestination destination) {
+
+ this.plugin.getMVPerms().tellMeWhyICantDoThis(sender, player.get(), destination);
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java
index 95a0bf146..01cd5c52f 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
+ * Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
@@ -7,49 +7,46 @@
package com.onarandombox.MultiverseCore.commands;
-import java.util.List;
-
+import co.aikar.commands.annotation.CommandAlias;
+import co.aikar.commands.annotation.CommandCompletion;
+import co.aikar.commands.annotation.CommandPermission;
+import co.aikar.commands.annotation.Conditions;
+import co.aikar.commands.annotation.Description;
+import co.aikar.commands.annotation.Flags;
+import co.aikar.commands.annotation.Single;
+import co.aikar.commands.annotation.Subcommand;
+import co.aikar.commands.annotation.Syntax;
+import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
-import org.bukkit.permissions.PermissionDefault;
-
-import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.api.MVWorldManager;
+import org.jetbrains.annotations.NotNull;
-/**
- * Creates a clone of a world.
- */
-public class CloneCommand extends MultiverseCommand {
- private MVWorldManager worldManager;
+@CommandAlias("mv")
+public class CloneCommand extends MultiverseCoreCommand {
public CloneCommand(MultiverseCore plugin) {
super(plugin);
- this.setName("Clone World");
- this.setCommandUsage("/mv clone" + ChatColor.GREEN + " {TARGET} {NAME}" + ChatColor.GOLD + " -g [GENERATOR[:ID]]");
- this.setArgRange(2, 4); // SUPPRESS CHECKSTYLE: MagicNumberCheck
- this.addKey("mvclone");
- this.addKey("mvcl");
- this.addKey("mv cl");
- this.addKey("mv clone");
- this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup");
- this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock");
- this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP);
- this.worldManager = this.plugin.getMVWorldManager();
}
- @Override
- public void runCommand(CommandSender sender, List args) {
- String oldName = args.get(0);
- if (!this.worldManager.hasUnloadedWorld(oldName, true)) {
- // If no world was found, we can't clone.
- sender.sendMessage("Sorry, Multiverse doesn't know about world " + oldName + ", so we can't clone it!");
- sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed.");
- return;
- }
- if (this.plugin.getMVWorldManager().cloneWorld(oldName, args.get(1))) {
- sender.sendMessage(ChatColor.GREEN + "World cloned!");
- } else {
- sender.sendMessage(ChatColor.RED + "World could NOT be cloned!");
- }
+ @Subcommand("clone")
+ @CommandPermission("multiverse.core.clone")
+ @Syntax(" ")
+ @CommandCompletion("@MVWorlds|@unloadedWorlds @empty")
+ @Description("Clones a world.")
+ public void onCloneCommand(@NotNull CommandSender sender,
+
+ @NotNull
+ @Syntax("")
+ @Description("Current multiverse world.")
+ @Conditions("isWorldInConfig") String worldName,
+
+ @NotNull
+ @Syntax("")
+ @Description("New cloned world name.")
+ @Single @Flags("trim") @Conditions("creatableWorldName") String newWorldName) {
+
+ sender.sendMessage((this.plugin.getMVWorldManager().cloneWorld(worldName, newWorldName))
+ ? String.format("%sWorld cloned!", ChatColor.GREEN)
+ : String.format("%sWorld could not be cloned! See console for more details.", ChatColor.RED));
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
index 55424a941..75ef86931 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
+ * Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
@@ -7,66 +7,88 @@
package com.onarandombox.MultiverseCore.commands;
+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.Single;
+import co.aikar.commands.annotation.Subcommand;
+import co.aikar.commands.annotation.Syntax;
+import co.aikar.commands.annotation.Values;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
+import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
+import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
+import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
-import org.bukkit.permissions.PermissionDefault;
+import org.jetbrains.annotations.NotNull;
-import java.util.List;
import java.util.Map;
-/**
- * Allows you to set Global MV Variables.
- */
-public class ConfigCommand extends MultiverseCommand {
+@CommandAlias("mv")
+@Subcommand("config")
+@CommandPermission("multiverse.core.config")
+public class ConfigCommand extends MultiverseCoreCommand {
+
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
- this.setName("Configuration");
- this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
- this.setArgRange(1, 2);
- this.addKey("mv config");
- this.addKey("mvconfig");
- this.addKey("mv conf");
- this.addKey("mvconf");
- this.addCommandExample("/mv config show");
- this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
- this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
- this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
}
- @Override
- public void runCommand(CommandSender sender, List args) {
- if (args.size() <= 1) {
- StringBuilder builder = new StringBuilder();
- Map serializedConfig = this.plugin.getMVConfig().serialize();
- for (Map.Entry entry : serializedConfig.entrySet()) {
- builder.append(ChatColor.GREEN);
- builder.append(entry.getKey());
- builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
- builder.append(entry.getValue().toString());
- builder.append(ChatColor.WHITE).append(", ");
- }
- String message = builder.toString();
- message = message.substring(0, message.length() - 2);
- sender.sendMessage(message);
+ @Subcommand("list")
+ @Syntax("[filter]")
+ @Description("Show multiverse config values.")
+ public void onShowCommand(@NotNull CommandSender sender,
+ @NotNull ContentFilter filter) {
+
+ new ContentDisplay.Builder