Skip to content

Instantly share code, notes, and snippets.

@Niall7459
Created March 26, 2015 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Niall7459/163665cbb60c85320a76 to your computer and use it in GitHub Desktop.
Save Niall7459/163665cbb60c85320a76 to your computer and use it in GitHub Desktop.
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