diff --git a/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java b/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java index 08905e84..971e882e 100644 --- a/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java +++ b/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java @@ -12,7 +12,7 @@ import com.onarandombox.MultiverseCore.api.MVPlugin; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.multiverseinventories.command.AddSharesCommand; -import com.onarandombox.multiverseinventories.command.AddWorldCommand; +import com.onarandombox.multiverseinventories.command.AddWorldsCommand; import com.onarandombox.multiverseinventories.command.CreateGroupCommand; import com.onarandombox.multiverseinventories.command.DeleteGroupCommand; import com.onarandombox.multiverseinventories.command.GroupCommand; @@ -22,7 +22,7 @@ import com.onarandombox.multiverseinventories.command.MigrateCommand; import com.onarandombox.multiverseinventories.command.ReloadCommand; import com.onarandombox.multiverseinventories.command.RemoveSharesCommand; -import com.onarandombox.multiverseinventories.command.RemoveWorldCommand; +import com.onarandombox.multiverseinventories.command.RemoveWorldsCommand; import com.onarandombox.multiverseinventories.command.SpawnCommand; import com.onarandombox.multiverseinventories.command.ToggleCommand; import com.onarandombox.multiverseinventories.command.tools.MVInvCommandCompletions; @@ -202,7 +202,7 @@ private void registerCommands() { MVCommandManager commandManager = this.getCore().getMVCommandManager(); commandManager.registerCommand(new AddSharesCommand(this)); - commandManager.registerCommand(new AddWorldCommand(this)); + commandManager.registerCommand(new AddWorldsCommand(this)); commandManager.registerCommand(new CreateGroupCommand(this)); commandManager.registerCommand(new DeleteGroupCommand(this)); commandManager.registerCommand(new GroupCommand(this)); @@ -212,7 +212,7 @@ private void registerCommands() { commandManager.registerCommand(new MigrateCommand(this)); commandManager.registerCommand(new ReloadCommand(this)); commandManager.registerCommand(new RemoveSharesCommand(this)); - commandManager.registerCommand(new RemoveWorldCommand(this)); + commandManager.registerCommand(new RemoveWorldsCommand(this)); commandManager.registerCommand(new SpawnCommand(this)); commandManager.registerCommand(new ToggleCommand(this)); } diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldsCommand.java similarity index 67% rename from src/main/java/com/onarandombox/multiverseinventories/command/AddWorldCommand.java rename to src/main/java/com/onarandombox/multiverseinventories/command/AddWorldsCommand.java index da54cd78..efd6e43c 100644 --- a/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldCommand.java +++ b/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldsCommand.java @@ -1,5 +1,9 @@ package com.onarandombox.multiverseinventories.command; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.acf.BukkitCommandIssuer; import com.onarandombox.acf.annotation.CommandAlias; @@ -14,33 +18,34 @@ import org.jetbrains.annotations.NotNull; @CommandAlias("mvinv") -public class AddWorldCommand extends InventoriesCommand { - public AddWorldCommand(@NotNull MultiverseInventories plugin) { +public class AddWorldsCommand extends InventoriesCommand { + public AddWorldsCommand(@NotNull MultiverseInventories plugin) { super(plugin); setPerm(Perm.COMMAND_ADDWORLD); } - @Subcommand("addworld") - @CommandCompletion("@mvworlds @worldGroups") - @Syntax(" ") + @Subcommand("addworlds") + @CommandCompletion("@mvworlds:multiple @worldGroups") + @Syntax(" ") @Description("Adds a World to a World Group.") public void onAddWorldCommand(BukkitCommandIssuer issuer, @Syntax("") @Description("World name to add.") - MVWorld world, + MVWorld[] world, @Syntax("") @Description("Group you want to add the world to.") WorldGroup group ) { - if (group.containsWorld(world.getName())) { - this.messager.normal(Message.WORLD_ALREADY_EXISTS, issuer.getIssuer(), world.getName(), group.getName()); + List worldNames = Arrays.stream(world).map(MVWorld::getName).collect(Collectors.toList()); + String worldNamesString = String.join(", ", worldNames); + if (!group.getWorlds().addAll(worldNames)) { + this.messager.normal(Message.WORLD_ALREADY_EXISTS, issuer.getIssuer(), worldNamesString, group.getName()); return; } - group.addWorld(world.getCBWorld()); this.plugin.getGroupManager().updateGroup(group); this.plugin.getMVIConfig().save(); - this.messager.normal(Message.WORLD_ADDED, issuer.getIssuer(), world.getName(), group.getName()); + this.messager.normal(Message.WORLD_ADDED, issuer.getIssuer(), worldNamesString, group.getName()); } } diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldsCommand.java similarity index 70% rename from src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldCommand.java rename to src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldsCommand.java index 5997730c..fa639ede 100644 --- a/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldCommand.java +++ b/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldsCommand.java @@ -1,5 +1,9 @@ package com.onarandombox.multiverseinventories.command; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.acf.BukkitCommandIssuer; import com.onarandombox.acf.annotation.CommandAlias; @@ -14,33 +18,34 @@ import org.jetbrains.annotations.NotNull; @CommandAlias("mvinv") -public class RemoveWorldCommand extends InventoriesCommand { - public RemoveWorldCommand(@NotNull MultiverseInventories plugin) { +public class RemoveWorldsCommand extends InventoriesCommand { + public RemoveWorldsCommand(@NotNull MultiverseInventories plugin) { super(plugin); setPerm(Perm.COMMAND_ADDWORLD); } - @Subcommand("removeworld") + @Subcommand("removeworlds") @CommandCompletion("@mvworlds @worldGroups") - @Syntax(" ") + @Syntax(" ") @Description("Adds a World to a World Group.") public void onRemoveWorldCommand(BukkitCommandIssuer issuer, @Syntax("") @Description("World name to remove.") - MVWorld world, + MVWorld[] world, @Syntax("") @Description("Group you want to remove the world from.") @NotNull WorldGroup group ) { - if (!group.containsWorld(world.getName())) { - this.messager.normal(Message.WORLD_NOT_IN_GROUP, issuer.getIssuer(), world.getName(), group.getName()); + Set worldNames = Arrays.stream(world).map(MVWorld::getName).collect(Collectors.toSet()); + String worldNamesString = String.join(", ", worldNames); + if (!group.getWorlds().removeAll(worldNames)) { + this.messager.normal(Message.WORLD_NOT_IN_GROUP, issuer.getIssuer(), worldNamesString, group.getName()); return; } - group.removeWorld(world.getCBWorld()); this.plugin.getGroupManager().updateGroup(group); this.plugin.getMVIConfig().save(); - this.messager.normal(Message.WORLD_REMOVED, issuer.getIssuer(), world.getName(), group.getName()); + this.messager.normal(Message.WORLD_REMOVED, issuer.getIssuer(), worldNamesString, group.getName()); } }