From 23241572df102956c7f4d11ed67b70693db2f16b Mon Sep 17 00:00:00 2001
From: benwoo1110 <30431861+benwoo1110@users.noreply.github.com>
Date: Sat, 19 Dec 2020 23:54:30 +0800
Subject: [PATCH] Add modify list command.

---
 .../commands_acf/ModifyCommand.java           | 46 +++++++++++++++----
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/ModifyCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/ModifyCommand.java
index d362c05e..33a948b3 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/ModifyCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/ModifyCommand.java
@@ -36,7 +36,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("set")
         @CommandPermission("multiverse.core.modify.set")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@setProperties")
+        @CommandCompletion("@setProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by setting a property. For more info; https://tinyurl.com/nehhzp6")
         public void onModifySetCommand(@NotNull CommandSender sender,
                                        @NotNull @Conditions("validAddProperty:set") String property,
@@ -50,7 +50,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("add")
         @CommandPermission("multiverse.core.modify.add")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@addProperties")
+        @CommandCompletion("@addProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by adding a property. For more info: https://tinyurl.com/nehhzp6")
         public void onModifyAddCommand(@NotNull CommandSender sender,
                                        @NotNull @Conditions("validAddProperty:add") String property,
@@ -63,7 +63,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("remove")
         @CommandPermission("multiverse.core.modify.remove")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@addProperties")
+        @CommandCompletion("@addProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by removing a property. For more info: https://tinyurl.com/nehhzp6")
         public void onModifyRemoveCommand(@NotNull CommandSender sender,
                                           @NotNull @Conditions("validAddProperty:remove") String property,
@@ -76,7 +76,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("clear")
         @CommandPermission("multiverse.core.modify.clear")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@addProperties")
+        @CommandCompletion("@addProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by clearing a property. For more info: https://tinyurl.com/nehhzp6")
         public void onModifyClearCommand(@NotNull CommandSender sender,
                                          @NotNull @Conditions("validAddProperty:clear") String property,
@@ -84,6 +84,17 @@ public class ModifyCommand extends MultiverseCommand {
 
             doModifyClear(sender, property, world);
         }
+
+        @Subcommand("list")
+        @CommandPermission("multiverse.core.modify.list")
+        @Syntax("[world]")
+        @CommandCompletion("@MVWorlds")
+        @Description("Show properties available to set.")
+        public void onModifyClearCommand(@NotNull CommandSender sender,
+                                         @NotNull @Flags("other,defaultself") MultiverseWorld world) {
+
+            doModifyList(sender, world);
+        }
     }
 
     @CommandAlias("mvm")
@@ -92,7 +103,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("set")
         @CommandPermission("multiverse.core.modify.set")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@setProperties")
+        @CommandCompletion("@setProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by setting a property. For more info; https://tinyurl.com/nehhzp6")
         public void onModifySetCommand(@NotNull CommandSender sender,
                                        @NotNull @Conditions("validAddProperty:set") String property,
@@ -106,7 +117,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("add")
         @CommandPermission("multiverse.core.modify.add")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@addProperties")
+        @CommandCompletion("@addProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by adding a property. For more info: https://tinyurl.com/nehhzp6")
         public void onModifyAddCommand(@NotNull CommandSender sender,
                                        @NotNull @Conditions("validAddProperty:add") String property,
@@ -119,7 +130,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("remove")
         @CommandPermission("multiverse.core.modify.remove")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@addProperties")
+        @CommandCompletion("@addProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by removing a property. For more info: https://tinyurl.com/nehhzp6")
         public void onModifyRemoveCommand(@NotNull CommandSender sender,
                                           @NotNull @Conditions("validAddProperty:remove") String property,
@@ -132,7 +143,7 @@ public class ModifyCommand extends MultiverseCommand {
         @Subcommand("clear")
         @CommandPermission("multiverse.core.modify.clear")
         @Syntax("<property> <value> [world]")
-        @CommandCompletion("@addProperties")
+        @CommandCompletion("@addProperties  @MVWorlds")
         @Description("Modify various aspects of worlds by clearing a property. For more info: https://tinyurl.com/nehhzp6")
         public void onModifyClearCommand(@NotNull CommandSender sender,
                                          @NotNull @Conditions("validAddProperty:clear") String property,
@@ -140,6 +151,17 @@ public class ModifyCommand extends MultiverseCommand {
 
             doModifyClear(sender, property, world);
         }
+
+        @Subcommand("list")
+        @CommandPermission("multiverse.core.modify.list")
+        @Syntax("[world]")
+        @CommandCompletion("@MVWorlds")
+        @Description("Show properties available to set.")
+        public void onModifyClearCommand(@NotNull CommandSender sender,
+                                         @NotNull @Flags("other,defaultself") MultiverseWorld world) {
+
+            doModifyList(sender, world);
+        }
     }
 
     //TODO: Think why properties method for MultiverseWorld is deprecated.
@@ -219,6 +241,14 @@ public class ModifyCommand extends MultiverseCommand {
         saveWorldConfig(sender);
     }
 
+    private void doModifyList(@NotNull CommandSender sender,
+                              @NotNull MultiverseWorld world) {
+
+        //TODO: Think, all worlds should have the same properties?
+        sender.sendMessage("===[ Properties Values ]===");
+        sender.sendMessage(world.getAllPropertyNames());
+    }
+
     private void saveWorldConfig(@NotNull CommandSender sender) {
         if (!this.plugin.saveWorldConfig()) {
             sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml!  Your changes will only be temporary!");