diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java b/common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java index e9ade7b7..f1a13e65 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java @@ -33,6 +33,7 @@ import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -170,6 +171,24 @@ public class ArgumentUtils { set.add(key, value); } + // remove excess entries from the set. + // (it can only have one server and one world.) + List servers = new ArrayList<>(set.getValues("server")); + if (servers.size() > 1) { + // start iterating at index 1 + for (int i = 1; i < servers.size(); i++) { + set.remove("server", servers.get(i)); + } + } + + List worlds = new ArrayList<>(set.getValues("world")); + if (worlds.size() > 1) { + // start iterating at index 1 + for (int i = 1; i < worlds.size(); i++) { + set.remove("world", worlds.get(i)); + } + } + return set; } else { return MutableContextSet.create();