From ffe6c24b53e75af2aa94def451c183795026fd36 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 3 Jun 2019 20:15:29 +0100 Subject: [PATCH] Properly remove "minecraft:" prefixed brigadier aliases --- .../luckperms/bukkit/compat/LuckPermsBrigadier.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/LuckPermsBrigadier.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/LuckPermsBrigadier.java index 9fb253a77..abcc4a0cd 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/LuckPermsBrigadier.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/LuckPermsBrigadier.java @@ -52,7 +52,10 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.GZIPInputStream; public class LuckPermsBrigadier { @@ -80,18 +83,20 @@ public class LuckPermsBrigadier { private static final class PermissionListener implements Listener { private final LPBukkitPlugin plugin; - private final Command pluginCommand; + private final List aliases; private PermissionListener(LPBukkitPlugin plugin, Command pluginCommand) { this.plugin = plugin; - this.pluginCommand = pluginCommand; + this.aliases = Commodore.getAliases(pluginCommand).stream() + .flatMap(alias -> Stream.of(alias, "minecraft:" + alias)) + .collect(Collectors.toList()); } @EventHandler public void onCommandSend(PlayerCommandSendEvent e) { Sender playerAsSender = this.plugin.getSenderFactory().wrap(e.getPlayer()); if (!this.plugin.getCommandManager().hasPermissionForAny(playerAsSender)) { - e.getCommands().removeAll(Commodore.getAliases(this.pluginCommand)); + e.getCommands().removeAll(this.aliases); } } }