diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 8bbd7d999..9523c084f 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -12,7 +12,7 @@ dependencies { compileOnly 'org.spigotmc:spigot-api:1.14-R0.1-SNAPSHOT' compileOnly 'net.kyori:text-adapter-bukkit:3.0.2' - compileOnly 'me.lucko:commodore:1.4' + compileOnly 'me.lucko:commodore:1.5' compileOnly('net.milkbowl.vault:VaultAPI:1.6') { exclude(module: 'bukkit') } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/brigadier/LuckPermsBrigadier.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/brigadier/LuckPermsBrigadier.java index 58413504d..dc41dd742 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/brigadier/LuckPermsBrigadier.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/brigadier/LuckPermsBrigadier.java @@ -34,28 +34,15 @@ import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.sender.Sender; import org.bukkit.command.Command; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandSendEvent; -import org.bukkit.plugin.PluginManager; import java.io.InputStream; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Registers LuckPerms command data to brigadier using {@link Commodore}. */ -public class LuckPermsBrigadier { +public final class LuckPermsBrigadier { + private LuckPermsBrigadier() {} - /** - * Registers LuckPerms command data to the given {@code pluginCommand}. - * - * @param plugin the luckperms plugin - * @param pluginCommand the command - * @throws Exception if something goes wrong - */ public static void register(LPBukkitPlugin plugin, Command pluginCommand) throws Exception { Commodore commodore = CommodoreProvider.getCommodore(plugin.getBootstrap()); try (InputStream is = plugin.getBootstrap().getResourceStream("luckperms.commodore")) { @@ -63,33 +50,11 @@ public class LuckPermsBrigadier { throw new Exception("Brigadier command data missing from jar"); } - LiteralCommandNode command = CommodoreFileFormat.parse(is); - commodore.register(pluginCommand, command); - } - - // add event listener to prevent completions from being send to players without permission - // to use any LP commands. - PluginManager pluginManager = plugin.getBootstrap().getServer().getPluginManager(); - pluginManager.registerEvents(new PermissionListener(plugin, pluginCommand), plugin.getBootstrap()); - } - - private static final class PermissionListener implements Listener { - private final LPBukkitPlugin plugin; - private final List aliases; - - private PermissionListener(LPBukkitPlugin plugin, Command pluginCommand) { - this.plugin = plugin; - 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(this.aliases); - } + LiteralCommandNode commandNode = CommodoreFileFormat.parse(is); + commodore.register(pluginCommand, commandNode, player -> { + Sender playerAsSender = plugin.getSenderFactory().wrap(player); + return plugin.getCommandManager().hasPermissionForAny(playerAsSender); + }); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index 36582fed2..2168b54c9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -136,8 +136,8 @@ public enum Dependency { COMMODORE( "me{}lucko", "commodore", - "1.4", - "9jrCBDKswqiT9/i97FtRmVJwYE3pXncxjoKFvdZMgzM=", + "1.5", + "vRQpmpYu/R780xwdOV5DNFYvKt9QKhkAVg6if6gMaa4=", Relocation.of("commodore", "me{}lucko{}commodore") ), MARIADB_DRIVER(