mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-08 20:09:59 +01:00
Update commodore to 1.5
This commit is contained in:
parent
3ceb53aa4f
commit
c1e3660551
@ -12,7 +12,7 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.14-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.14-R0.1-SNAPSHOT'
|
||||||
compileOnly 'net.kyori:text-adapter-bukkit:3.0.2'
|
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') {
|
compileOnly('net.milkbowl.vault:VaultAPI:1.6') {
|
||||||
exclude(module: 'bukkit')
|
exclude(module: 'bukkit')
|
||||||
}
|
}
|
||||||
|
@ -34,28 +34,15 @@ import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
|||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
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.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}.
|
* 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 {
|
public static void register(LPBukkitPlugin plugin, Command pluginCommand) throws Exception {
|
||||||
Commodore commodore = CommodoreProvider.getCommodore(plugin.getBootstrap());
|
Commodore commodore = CommodoreProvider.getCommodore(plugin.getBootstrap());
|
||||||
try (InputStream is = plugin.getBootstrap().getResourceStream("luckperms.commodore")) {
|
try (InputStream is = plugin.getBootstrap().getResourceStream("luckperms.commodore")) {
|
||||||
@ -63,33 +50,11 @@ public class LuckPermsBrigadier {
|
|||||||
throw new Exception("Brigadier command data missing from jar");
|
throw new Exception("Brigadier command data missing from jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
LiteralCommandNode<?> command = CommodoreFileFormat.parse(is);
|
LiteralCommandNode<?> commandNode = CommodoreFileFormat.parse(is);
|
||||||
commodore.register(pluginCommand, command);
|
commodore.register(pluginCommand, commandNode, player -> {
|
||||||
}
|
Sender playerAsSender = plugin.getSenderFactory().wrap(player);
|
||||||
|
return plugin.getCommandManager().hasPermissionForAny(playerAsSender);
|
||||||
// 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<String> 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ public enum Dependency {
|
|||||||
COMMODORE(
|
COMMODORE(
|
||||||
"me{}lucko",
|
"me{}lucko",
|
||||||
"commodore",
|
"commodore",
|
||||||
"1.4",
|
"1.5",
|
||||||
"9jrCBDKswqiT9/i97FtRmVJwYE3pXncxjoKFvdZMgzM=",
|
"vRQpmpYu/R780xwdOV5DNFYvKt9QKhkAVg6if6gMaa4=",
|
||||||
Relocation.of("commodore", "me{}lucko{}commodore")
|
Relocation.of("commodore", "me{}lucko{}commodore")
|
||||||
),
|
),
|
||||||
MARIADB_DRIVER(
|
MARIADB_DRIVER(
|
||||||
|
Loading…
Reference in New Issue
Block a user