66import com .earth2me .essentials .UserMap ;
77import com .earth2me .essentials .economy .EconomyLayer ;
88import com .earth2me .essentials .economy .EconomyLayers ;
9+ import com .earth2me .essentials .utils .CommandMapUtil ;
910import com .earth2me .essentials .utils .DateUtil ;
1011import com .earth2me .essentials .utils .EnumUtil ;
1112import com .earth2me .essentials .utils .FloatUtil ;
2526import org .bukkit .Server ;
2627import org .bukkit .Sound ;
2728import org .bukkit .World ;
29+ import org .bukkit .command .Command ;
2830import org .bukkit .entity .Player ;
2931import org .bukkit .plugin .Plugin ;
3032import org .bukkit .plugin .PluginDescriptionFile ;
4244import java .util .Collection ;
4345import java .util .Collections ;
4446import java .util .Comparator ;
47+ import java .util .HashMap ;
4548import java .util .List ;
4649import java .util .Locale ;
4750import java .util .Map ;
@@ -270,6 +273,9 @@ private void runDump(Server server, CommandSource sender, String commandLabel, S
270273 final Plugin essDiscord = Bukkit .getPluginManager ().getPlugin ("EssentialsDiscord" );
271274 final Plugin essSpawn = Bukkit .getPluginManager ().getPlugin ("EssentialsSpawn" );
272275
276+ final Map <String , Command > knownCommandsCopy = new HashMap <>(ess .getKnownCommandsProvider ().getKnownCommands ());
277+ final Map <String , String > disabledCommandsCopy = new HashMap <>(ess .getAlternativeCommandsHandler ().disabledCommands ());
278+
273279 // Further operations will be heavy IO
274280 ess .runTaskAsynchronously (() -> {
275281 boolean config = false ;
@@ -279,6 +285,7 @@ private void runDump(Server server, CommandSource sender, String commandLabel, S
279285 boolean worth = false ;
280286 boolean tpr = false ;
281287 boolean spawns = false ;
288+ boolean commands = false ;
282289 for (final String arg : args ) {
283290 if (arg .equals ("*" ) || arg .equalsIgnoreCase ("all" )) {
284291 config = true ;
@@ -288,6 +295,7 @@ private void runDump(Server server, CommandSource sender, String commandLabel, S
288295 worth = true ;
289296 tpr = true ;
290297 spawns = true ;
298+ commands = true ;
291299 break ;
292300 } else if (arg .equalsIgnoreCase ("config" )) {
293301 config = true ;
@@ -303,6 +311,8 @@ private void runDump(Server server, CommandSource sender, String commandLabel, S
303311 tpr = true ;
304312 } else if (arg .equalsIgnoreCase ("spawns" )) {
305313 spawns = true ;
314+ } else if (arg .equalsIgnoreCase ("commands" )) {
315+ commands = true ;
306316 }
307317 }
308318
@@ -366,6 +376,16 @@ private void runDump(Server server, CommandSource sender, String commandLabel, S
366376 }
367377 }
368378
379+ if (commands ) {
380+ try {
381+ files .add (new PasteUtil .PasteFile ("commands.yml" , new String (Files .readAllBytes (Paths .get ("commands.yml" )), StandardCharsets .UTF_8 )));
382+ files .add (new PasteUtil .PasteFile ("commandmap.json" , CommandMapUtil .toJsonPretty (ess , knownCommandsCopy )));
383+ files .add (new PasteUtil .PasteFile ("commandoverride.json" , disabledCommandsCopy .toString ()));
384+ } catch (IOException e ) {
385+ sender .sendMessage (tl ("dumpErrorUpload" , "commands.yml" , e .getMessage ()));
386+ }
387+ }
388+
369389 final CompletableFuture <PasteUtil .PasteResult > future = PasteUtil .createPaste (files );
370390 future .thenAccept (result -> {
371391 if (result != null ) {
@@ -769,7 +789,7 @@ protected List<String> getTabCompleteOptions(final Server server, final CommandS
769789 }
770790 break ;
771791 case "dump" :
772- final List <String > list = Lists .newArrayList ("config" , "kits" , "log" , "discord" , "worth" , "tpr" , "spawns" , "all" );
792+ final List <String > list = Lists .newArrayList ("config" , "kits" , "log" , "discord" , "worth" , "tpr" , "spawns" , "commands" , " all" );
773793 for (String arg : args ) {
774794 if (arg .equals ("*" ) || arg .equalsIgnoreCase ("all" )) {
775795 list .clear ();
0 commit comments