mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Fix: Properly perm check /channel and channel alias commands (#132)
This commit is contained in:
1 parent
1699fa7a85
commit
d4ecf92877
2 files changed
+33
-16
No files matched your search
+17
-8
@@ -48,22 +48,20 @@ public class AliasedChannelCommand {
|
||||
private void channel(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
|
||||
if (user.channelSettings(this.chatChannel()).ignored()) {
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(this.chatChannel().cannotUseMessage(),
|
||||
"color", "<" + this.chatChannel().channelColor(user).toString() + ">",
|
||||
"channel", this.chatChannel().name()));
|
||||
|
||||
return;
|
||||
}
|
||||
if (!this.canUse(user)) return;
|
||||
|
||||
user.selectedChannel(this.chatChannel());
|
||||
}
|
||||
|
||||
private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
|
||||
if (!this.canUse(user)) return;
|
||||
|
||||
context.<String>getOptional("message").ifPresent(message -> {
|
||||
this.chatChannel().sendComponentsAndLog(
|
||||
context.getSender().identity(),
|
||||
this.chatChannel().parseMessage((PlayerUser) context.getSender(), message, false));
|
||||
this.chatChannel().parseMessage(user, message, false));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,4 +72,15 @@ public class AliasedChannelCommand {
|
||||
public @NonNull String commandName() {
|
||||
return this.commandName;
|
||||
}
|
||||
|
||||
private boolean canUse(final PlayerUser user) {
|
||||
if (user.channelSettings(this.chatChannel()).ignored() || !this.chatChannel().canPlayerUse(user)) {
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(this.chatChannel().cannotUseMessage(),
|
||||
"color", "<" + this.chatChannel().channelColor(user).toString() + ">",
|
||||
"channel", this.chatChannel().name()));
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+16
-8
@@ -54,23 +54,31 @@ public class ChannelCommand {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final TextChannel channel = context.get("channel");
|
||||
|
||||
if (user.channelSettings(channel).ignored()) {
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(channel.cannotUseMessage(),
|
||||
"color", "<" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name()));
|
||||
|
||||
return;
|
||||
}
|
||||
if (!this.canUse(user, channel)) return;
|
||||
|
||||
user.selectedChannel(channel);
|
||||
}
|
||||
|
||||
private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final ChatChannel channel = context.get("channel");
|
||||
final String message = context.get("message");
|
||||
|
||||
channel.sendComponentsAndLog(context.getSender().identity(), channel.parseMessage((PlayerUser) context.getSender(),
|
||||
if (!this.canUse(user, channel)) return;
|
||||
|
||||
channel.sendComponentsAndLog(context.getSender().identity(), channel.parseMessage(user,
|
||||
message, false));
|
||||
}
|
||||
|
||||
private boolean canUse(final PlayerUser user, final ChatChannel channel) {
|
||||
if (user.channelSettings(channel).ignored() || !channel.canPlayerUse(user)) {
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(channel.cannotUseMessage(),
|
||||
"color", "<" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name()));
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user