mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
More command progress
This commit is contained in:
1 parent
e7088c6b56
commit
b1c4c48e83
6 files changed
+152
-198
No files matched your search
@@ -51,6 +51,8 @@ public class CarbonTranslations {
|
||||
@Setting private String spyToggledOff = "<gray>You are no longer spying on <color><channel> <gray>chat!";
|
||||
@Setting private String spyWhispersOn = "<gray>You are now spying on whispers!";
|
||||
@Setting private String spyWhispersOff = "<gray>You are no longer spying on whispers!";
|
||||
@Setting private String spyEverythingOn = "<gray>All spying toggled on!";
|
||||
@Setting private String spyEverythingOff = "<gray>All spying toggled off!";
|
||||
@Setting private String nicknameSet = "<green>Your nickname was set to <nickname><reset><green>!";
|
||||
@Setting private String nicknameReset = "<green>Your nickname was reset!";
|
||||
@Setting private String nowShadowMuted = "<yellow>Player <player> is now shadow muted!";
|
||||
@@ -158,6 +160,14 @@ public class CarbonTranslations {
|
||||
return this.spyWhispersOff;
|
||||
}
|
||||
|
||||
public String spyEverythingOn() {
|
||||
return this.spyEverythingOn;
|
||||
}
|
||||
|
||||
public String spyEverythingOff() {
|
||||
return this.spyEverythingOff;
|
||||
}
|
||||
|
||||
public String nicknameSet() {
|
||||
return this.nicknameSet;
|
||||
}
|
||||
|
||||
+19
-22
@@ -7,6 +7,7 @@ import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class IgnoreCommand {
|
||||
@@ -38,31 +39,27 @@ public class IgnoreCommand {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser targetUser = context.getRequired("user");
|
||||
|
||||
//final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(sender.uuid());
|
||||
|
||||
if (sender.ignoringUser(targetUser)) {
|
||||
sender.ignoringUser(targetUser, false);
|
||||
// sender.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
// this.carbonChat.translations().notIgnoringUser(),
|
||||
// "br", "\n", "player", offlinePlayer.getName()));
|
||||
} else {
|
||||
// Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
// final Permission permission = this.carbonChat.permission();
|
||||
// final String format;
|
||||
//
|
||||
// if (permission.playerHas(null, offlinePlayer, "carbonchat.ignore.exempt")) {
|
||||
// format = this.carbonChat.translations().ignoreExempt();
|
||||
// } else {
|
||||
// user.ignoringUser(targetUser, true);
|
||||
// format = this.carbonChat.translations().ignoringUser();
|
||||
// }
|
||||
//
|
||||
// final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
// "br", "\n", "sender", player.getDisplayName(), "player", offlinePlayer.getName());
|
||||
//
|
||||
// user.sendMessage(message);
|
||||
// });
|
||||
|
||||
sender.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().notIgnoringUser(),
|
||||
"br", "\n", "player", targetUser.displayName()));
|
||||
} else {
|
||||
// TODO: schedule task because sync permission checks
|
||||
final String format;
|
||||
|
||||
if (sender.hasPermission("carbonchat.ignore.exempt")) {
|
||||
format = this.carbonChat.translations().ignoreExempt();
|
||||
} else {
|
||||
sender.ignoringUser(targetUser, true);
|
||||
format = this.carbonChat.translations().ignoringUser();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
"br", "\n", "sender", sender.displayName(), "player", targetUser.displayName());
|
||||
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-37
@@ -1,26 +1,15 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.LiteralArgument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class SetColorCommand {
|
||||
|
||||
@NonNull
|
||||
@@ -36,37 +25,35 @@ public class SetColorCommand {
|
||||
}
|
||||
|
||||
for (final ChatChannel channel : this.carbonChat.channelRegistry()) {
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("channel", new LiteralArgument(channel.key()));
|
||||
arguments.put("color", CarbonUtils.textColorArgument());
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.setcolor")
|
||||
//.argument(CommandUtils.colorArgument())
|
||||
.handler(context -> {
|
||||
final ChatUser user = context.getSender();
|
||||
final TextColor color = context.getRequired("color");
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.setcolor"))
|
||||
.executesPlayer((player, args) -> {
|
||||
final TextColor color = (TextColor) args[0];
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
if (!user.hasPermission("carbonchat.setcolor." + channel.key())) {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().cannotSetColor(),
|
||||
"br", "\n", "input", color.asHexString(),
|
||||
"channel", channel.name()));
|
||||
|
||||
if (!player.hasPermission("carbonchat.setcolor." + channel.key())) {
|
||||
user.sendMessage(carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().cannotSetColor(),
|
||||
"br", "\n", "input", color.asHexString(),
|
||||
"channel", channel.name()));
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
final UserChannelSettings settings = user.channelSettings(channel);
|
||||
|
||||
final UserChannelSettings settings = user.channelSettings(channel);
|
||||
settings.color(color);
|
||||
|
||||
settings.color(color);
|
||||
|
||||
user.sendMessage(carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().channelColorSet(),
|
||||
"br", "\n", "color", "<color:" + color.asHexString() + ">", "channel",
|
||||
channel.name(), "hex", color.asHexString()));
|
||||
})
|
||||
.register();
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().channelColorSet(),
|
||||
"br", "\n", "color", "<color:" + color.asHexString() + ">", "channel",
|
||||
channel.name(), "hex", color.asHexString()));
|
||||
}).build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+40
-50
@@ -1,27 +1,18 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import com.intellectualsites.commands.arguments.StaticArgument;
|
||||
import com.intellectualsites.commands.arguments.standard.BooleanArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.BooleanArgument;
|
||||
import dev.jorel.commandapi.arguments.LiteralArgument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class SpyChannelCommand {
|
||||
|
||||
@NonNull
|
||||
@@ -36,41 +27,41 @@ public class SpyChannelCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.spy")
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.handler(this::spyChannel)
|
||||
.build()
|
||||
);
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.spy")
|
||||
.argument(StaticArgument.required("whispers"))
|
||||
.handler(this::spyWhispers)
|
||||
.build()
|
||||
);
|
||||
|
||||
final LinkedHashMap<String, Argument> whisperArguments = new LinkedHashMap<>();
|
||||
whisperArguments.put("channel", new LiteralArgument("whispers"));
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(whisperArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||
.executesPlayer(this::executeWhispers)
|
||||
.register();
|
||||
|
||||
final LinkedHashMap<String, Argument> everythingArguments = new LinkedHashMap<>();
|
||||
everythingArguments.put("channel", new LiteralArgument("*"));
|
||||
everythingArguments.put("should-spy", new BooleanArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(everythingArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||
.executesPlayer(this::executeEverything) // lul
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.spy")
|
||||
.argument(StaticArgument.required("*"))
|
||||
.argument(BooleanArgument.required("enabled"))
|
||||
.handler(this::spyEverything)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatChannel chatChannel = (ChatChannel) args[0];
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
private void spyChannel(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatChannel chatChannel = context.getRequired("channel");
|
||||
|
||||
final String message;
|
||||
|
||||
@@ -88,8 +79,8 @@ public class SpyChannelCommand {
|
||||
"color", "<color:" + chatChannel.channelColor(user).toString() + ">", "channel", chatChannel.name()));
|
||||
}
|
||||
|
||||
private void executeWhispers(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
private void spyWhispers(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
|
||||
final String message;
|
||||
|
||||
@@ -104,10 +95,9 @@ public class SpyChannelCommand {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n"));
|
||||
}
|
||||
|
||||
private void executeEverything(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final Boolean shouldSpy = (Boolean) args[0];
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
private void spyEverything(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final Boolean shouldSpy = context.getRequired("enabled");
|
||||
|
||||
final String message;
|
||||
|
||||
|
||||
+36
-53
@@ -1,29 +1,17 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class SudoChannelCommand {
|
||||
|
||||
@NonNull
|
||||
@@ -38,35 +26,35 @@ public class SudoChannelCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> setOtherChannelArguments = new LinkedHashMap<>();
|
||||
setOtherChannelArguments.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
setOtherChannelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.channel.others")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.handler(this::otherChannel)
|
||||
.build()
|
||||
);
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(setOtherChannelArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.others"))
|
||||
.executes((sender, args) -> {
|
||||
this.otherChannel(sender, (ChatUser) args[0], (ChatChannel) args[1]);
|
||||
})
|
||||
.register();
|
||||
|
||||
final LinkedHashMap<String, Argument> sendMessageOtherArguments = new LinkedHashMap<>();
|
||||
sendMessageOtherArguments.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
sendMessageOtherArguments.put("channel", CarbonUtils.channelArgument());
|
||||
sendMessageOtherArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(sendMessageOtherArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.others.message"))
|
||||
.executes((sender, args) -> {
|
||||
this.sendMessageOther(sender, (ChatUser) args[0], (ChatChannel) args[1], (String) args[2]);
|
||||
})
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.channel.others.message")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().build())
|
||||
.handler(this::sendMessageOther)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void otherChannel(@NonNull final CommandSender sender, @NonNull final ChatUser user, @NonNull final ChatChannel channel) {
|
||||
private void otherChannel(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
user.selectedChannel(channel);
|
||||
|
||||
final String message = channel.switchMessage();
|
||||
@@ -75,22 +63,17 @@ public class SudoChannelCommand {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
cmdSender.sendMessage(
|
||||
sender.sendMessage(
|
||||
this.carbonChat.messageProcessor().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name(),
|
||||
"player", Bukkit.getOfflinePlayer(user.uuid()).getName()));
|
||||
"player", user.name()));
|
||||
}
|
||||
|
||||
private void sendMessageOther(@NonNull final CommandSender sender, @NonNull final ChatUser user,
|
||||
@NonNull final ChatChannel channel, @NonNull final String message) {
|
||||
private void sendMessageOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
final String message = context.getRequired("message");
|
||||
|
||||
final Component component = channel.sendMessage(user, message, false);
|
||||
|
||||
this.carbonChat.messageProcessor().audiences().console().sendMessage(component);
|
||||
|
||||
+23
-36
@@ -2,28 +2,15 @@ package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class ToggleCommand {
|
||||
|
||||
@NonNull
|
||||
@@ -38,31 +25,31 @@ public class ToggleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.toggle")
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.handler(this::toggleSelf)
|
||||
.build()
|
||||
);
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.toggle"))
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
|
||||
final LinkedHashMap<String, Argument> argumentsOther = new LinkedHashMap<>();
|
||||
argumentsOther.put("players", CarbonUtils.chatUserArgument());
|
||||
argumentsOther.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(argumentsOther)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.toggle"))
|
||||
.executes(this::executeOther)
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player & console
|
||||
.withPermission("carbonchat.toggle")
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::toggleOther)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void executeSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void toggleSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatChannel channel = (ChatChannel) args[0];
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
final String message;
|
||||
|
||||
@@ -82,7 +69,7 @@ public class ToggleCommand {
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
}
|
||||
|
||||
private void executeOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void toggleOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
Reference in new issue
Block a user