forked from SteamWar/SteamWar
Hide /chat msg from players without moderation permission
This commit is contained in:
@@ -616,7 +616,8 @@ CHAT_CHANNEL_NOT_SWITCHABLE = §cYou cannot write into this channel by default.
|
||||
CHAT_NO_WRITE = §cYou cannot write into this channel.
|
||||
CHAT_FIGHT_NO_TEAM = §cYou are not in a fight team.
|
||||
GLOBAL_USAGE = §8/§7global §8[§emessage§8]
|
||||
CHAT_USAGE = §8/§7chat §8[§echannel§8] [§ejoin§8|§eleave§8|§emsg §8<§etext§8>]
|
||||
CHAT_USAGE = §8/§7chat §8[§echannel§8] [§ejoin§8|§eleave§8]
|
||||
CHAT_MSG_USAGE = §8/§7chat §8[§echannel§8] §7msg §8[§emessage§8]
|
||||
CHAT_CHANNEL_UNKNOWN = §cUnknown chat channel.
|
||||
CHAT_CHANNEL_JOINED = §7You are reading §e{0} §7again.
|
||||
CHAT_CHANNEL_LEFT = §7You no longer read §e{0}§7.
|
||||
|
||||
@@ -581,7 +581,8 @@ CHAT_CHANNEL_NOT_SWITCHABLE = §cIn diesen Kanal kannst du nicht standardmäßig
|
||||
CHAT_NO_WRITE = §cDu kannst nicht in diesen Kanal schreiben.
|
||||
CHAT_FIGHT_NO_TEAM = §cDu bist in keinem Kampfteam.
|
||||
GLOBAL_USAGE = §8/§7global §8[§eNachricht§8]
|
||||
CHAT_USAGE = §8/§7chat §8[§eKanal§8] [§ejoin§8|§eleave§8|§emsg §8<§eText§8>]
|
||||
CHAT_USAGE = §8/§7chat §8[§eKanal§8] [§ejoin§8|§eleave§8]
|
||||
CHAT_MSG_USAGE = §8/§7chat §8[§eKanal§8] §7msg §8[§eNachricht§8]
|
||||
CHAT_CHANNEL_UNKNOWN = §cUnbekannter Chatkanal.
|
||||
CHAT_CHANNEL_JOINED = §7Du liest §e{0} §7wieder mit.
|
||||
CHAT_CHANNEL_LEFT = §7Du liest §e{0} §7nicht mehr mit.
|
||||
|
||||
@@ -23,6 +23,7 @@ package de.steamwar.velocitycore.commands;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
@@ -60,16 +61,16 @@ public class ChatCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void msg(PlayerChatter sender, ChatChannel channel, @StaticValue("msg") String msg, @ErrorMessage(value = "CHAT_USAGE", allowEAs = false) String... message) {
|
||||
if (!sender.user().hasPerm(UserPerm.MODERATION)) {
|
||||
sender.system("CHAT_NO_WRITE");
|
||||
return;
|
||||
}
|
||||
|
||||
@Register(description = "CHAT_MSG_USAGE")
|
||||
public void msg(@Validator("moderator") PlayerChatter sender, ChatChannel channel, @StaticValue("msg") String msg, @ErrorMessage(value = "CHAT_MSG_USAGE", allowEAs = false) String... message) {
|
||||
channel.send(sender, String.join(" ", message));
|
||||
}
|
||||
|
||||
@Validator(value = "moderator", local = true)
|
||||
public TypeValidator<PlayerChatter> moderatorValidator() {
|
||||
return (sender, value, messageSender) -> !messageSender.send(!value.user().hasPerm(UserPerm.MODERATION), "CHAT_NO_WRITE");
|
||||
}
|
||||
|
||||
@ClassMapper(value = ChatChannel.class, local = true)
|
||||
public TypeMapper<ChatChannel> channelTypeMapper() {
|
||||
return new TypeMapper<>() {
|
||||
|
||||
Reference in New Issue
Block a user