CleanCommandSay.java [Say Command] [CommandBook]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Command(aliases = {"say"}, usage = "<message...>", desc = "Send a message", min = 1, max = -1) | |
@CommandPermissions({"commandbook.say"}) | |
public void say(CommandContext args, CommandSender sender) throws CommandException { | |
if (sender instanceof Player && sessions.getSession(AdministrativeSession.class, (Player) sender).isMute()) { | |
sender.sendMessage(ChatColor.RED + "You are muted."); | |
return; | |
} | |
String msg = args.getJoinedStrings(0); | |
if (sender instanceof Player) { | |
if (BasePlugin.callEvent( | |
new AsyncPlayerChatEvent(false, (Player) sender, msg, | |
new HashSet<Player>(BasePlugin.server().getOnlinePlayers()))).isCancelled()) { | |
return; | |
} | |
} | |
BasePlugin.callEvent( | |
new CommandSenderMessageEvent(sender, msg)); | |
if (sender instanceof Player) { | |
BasePlugin.server().broadcastMessage( | |
ChatColor.LIGHT_PURPLE + "[" + ChatUtil.toColoredName(sender, ChatColor.LIGHT_PURPLE) | |
+ "] " + args.getJoinedStrings(0)); | |
} else { | |
BasePlugin.server().broadcastMessage( | |
replaceColorMacros(config.consoleSayFormat).replace( | |
"%s", args.getJoinedStrings(0))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment