2021-05-13 12:11:59 +00:00
|
|
|
package com.alttd.chat.commands;
|
2021-05-03 15:51:35 +00:00
|
|
|
|
2021-05-24 13:14:11 +00:00
|
|
|
import com.alttd.chat.VelocityChat;
|
2021-05-03 15:51:35 +00:00
|
|
|
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;
|
|
|
|
|
|
2021-05-10 08:01:35 +00:00
|
|
|
public class GlobalAdminChat {
|
2021-05-03 15:51:35 +00:00
|
|
|
|
2021-05-10 08:01:35 +00:00
|
|
|
public GlobalAdminChat(ProxyServer proxyServer) {
|
2021-05-03 15:51:35 +00:00
|
|
|
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
2021-05-10 08:01:35 +00:00
|
|
|
.<CommandSource>literal("globaladminchat")
|
2021-07-17 22:48:55 +00:00
|
|
|
.requires(ctx -> ctx.hasPermission("command.proxy.globaladminchat"))
|
2021-05-03 15:51:35 +00:00
|
|
|
.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));
|
2021-05-03 15:51:35 +00:00
|
|
|
return 1;
|
2021-06-13 11:53:49 +00:00
|
|
|
})
|
2021-05-03 15:51:35 +00:00
|
|
|
)
|
|
|
|
|
.executes(context -> 0)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
BrigadierCommand brigadierCommand = new BrigadierCommand(command);
|
|
|
|
|
|
|
|
|
|
CommandMeta.Builder metaBuilder = proxyServer.getCommandManager().metaBuilder(brigadierCommand);
|
|
|
|
|
|
2021-05-10 08:01:35 +00:00
|
|
|
for (String alias : Config.GACECOMMANDALIASES) {
|
2021-05-03 15:51:35 +00:00
|
|
|
metaBuilder.aliases(alias);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandMeta meta = metaBuilder.build();
|
|
|
|
|
|
|
|
|
|
proxyServer.getCommandManager().register(meta, brigadierCommand);
|
|
|
|
|
}
|
|
|
|
|
}
|