use of com.velocitypowered.api.command.CommandSource in project LimboFilter by Elytrium.
the class LimboFilterCommand method execute.
@Override
public void execute(SimpleCommand.Invocation invocation) {
CommandSource source = invocation.source();
String[] args = invocation.arguments();
if (args.length == 1) {
switch(args[0].toLowerCase(Locale.ROOT)) {
case "reload":
{
if (source.hasPermission("limbofilter.reload")) {
try {
this.plugin.reload();
source.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Settings.IMP.MAIN.STRINGS.RELOAD));
} catch (Exception e) {
source.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Settings.IMP.MAIN.STRINGS.RELOAD_FAILED));
e.printStackTrace();
}
} else {
this.showHelp(source);
}
return;
}
case "stats":
{
if (source instanceof Player) {
if (source.hasPermission("limbofilter.stats")) {
ConnectedPlayer player = (ConnectedPlayer) source;
if (!this.playersWithStats.contains(player.getUniqueId())) {
source.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Settings.IMP.MAIN.STRINGS.STATS_ENABLED));
this.playersWithStats.add(player.getUniqueId());
} else {
source.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Settings.IMP.MAIN.STRINGS.STATS_DISABLED));
this.playersWithStats.remove(player.getUniqueId());
}
} else {
this.showHelp(source);
}
} else {
source.sendMessage(this.createStatsComponent(0));
}
return;
}
default:
{
this.showHelp(source);
}
}
}
this.showHelp(source);
}
use of com.velocitypowered.api.command.CommandSource in project LibertyBans by A248.
the class CommandHandler method execute.
@Override
public void execute(Invocation invocation) {
CommandSource platformSender = invocation.source();
String[] args = invocation.arguments();
commandHelper.execute(platformSender, ArrayCommandPackage.create(adaptArgs(args, false)));
}
use of com.velocitypowered.api.command.CommandSource in project SickCore by SickMC.
the class BuildServerCommand method onCMD.
public void onCMD() {
LiteralCommandNode<CommandSource> node = LiteralArgumentBuilder.<CommandSource>literal("bs").executes(context -> {
if (!(context.getSource() instanceof Player))
return 0;
BungeePlayer player = new BungeePlayer(context.getSource());
if (!player.api().isTeam()) {
player.sendMessage(LanguagePath.NETWORK_COMMAND_NOSTAFF);
return 0;
}
if (player.api().cloud().cloudAPI().getConnectedService().getServerName().startsWith("Build-")) {
player.sendMessage(LanguagePath.PROXY_STAFF_COMMAND_BUILDSERVER_ALREADY);
return 0;
}
player.api().cloud().cloudAPI().getPlayerExecutor().connectToGroup("Build", ServerSelectorType.LOWEST_PLAYERS);
player.sendMessage(LanguagePath.PROXY_STAFF_COMMAND_BUILDSERVER_SUCCESS);
return 1;
}).build();
BrigadierCommand command = new BrigadierCommand(node);
}
Aggregations