Chat/velocity/src/main/java/com/alttd/velocitychat/commands/GlobalAdminChat.java

43 lines
1.8 KiB
Java
Raw Normal View History

2021-12-11 18:35:35 +00:00
package com.alttd.velocitychat.commands;
2021-12-11 18:35:35 +00:00
import com.alttd.velocitychat.VelocityChat;
import com.alttd.chat.config.Config;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.ProxyServer;
public class GlobalAdminChat {
public GlobalAdminChat(ProxyServer proxyServer) {
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
.<CommandSource>literal("globaladminchat")
2021-07-17 22:48:55 +00:00
.requires(ctx -> ctx.hasPermission("command.proxy.globaladminchat"))
.then(RequiredArgumentBuilder
.<CommandSource, String>argument("message", StringArgumentType.greedyString())
.executes(context -> {
2021-05-24 13:14:11 +00:00
VelocityChat.getPlugin().getChatHandler().globalAdminChat(context.getSource(), context.getArgument("message", String.class));
return 1;
2021-06-13 11:53:49 +00:00
})
)
.executes(context -> 0)
.build();
BrigadierCommand brigadierCommand = new BrigadierCommand(command);
CommandMeta.Builder metaBuilder = proxyServer.getCommandManager().metaBuilder(brigadierCommand);
for (String alias : Config.GACECOMMANDALIASES) {
metaBuilder.aliases(alias);
}
CommandMeta meta = metaBuilder.build();
proxyServer.getCommandManager().register(meta, brigadierCommand);
}
}