package com.alttd.chat.commands; import com.alttd.chat.api.GlobalStaffChatEvent; 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 command = LiteralArgumentBuilder .literal("globaladminchat") .requires(ctx -> ctx.hasPermission("command.proxy.globaladminchat"))// TODO permission system? load permissions from config? .then(RequiredArgumentBuilder .argument("message", StringArgumentType.greedyString()) .executes(context -> { proxyServer.getEventManager().fire(new GlobalStaffChatEvent(context.getSource(), context.getArgument("message", String.class))); return 1; }) // TODO call in the same way as gc? ) .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); } }