Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CleanCommandSay.java [Say Command] [CommandBook]
@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