2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.commands.party;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.Users;
|
2012-04-21 00:09:50 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.mcPermissions;
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
2012-04-18 19:01:07 +02:00
|
|
|
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.locale.mcLocale;
|
|
|
|
|
|
|
|
public class ACommand implements CommandExecutor {
|
2012-04-21 00:09:50 +02:00
|
|
|
private final mcMMO plugin;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
public ACommand (mcMMO plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
// Console message?
|
|
|
|
if (!(sender instanceof Player) && args.length >= 1) {
|
|
|
|
String aMessage = args[0];
|
|
|
|
for (int i = 1; i <= args.length - 1; i++) {
|
|
|
|
aMessage = aMessage + " " + args[i];
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage);
|
|
|
|
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
2012-04-18 19:01:07 +02:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
if(chatEvent.isCancelled()) return true;
|
2012-04-18 19:01:07 +02:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
aMessage = chatEvent.getMessage();
|
2012-04-18 19:01:07 +02:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
plugin.getLogger().info("[A]<*Console*> " + aMessage);
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
for (Player herp : plugin.getServer().getOnlinePlayers()) {
|
|
|
|
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
|
|
|
|
herp.sendMessage(aPrefix + aMessage);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
Player player = null;
|
2012-02-11 15:01:46 +01:00
|
|
|
if (sender instanceof Player) {
|
|
|
|
player = (Player) sender;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
if (player != null && !mcPermissions.getInstance().adminChat(player) && !player.isOp()) {
|
|
|
|
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
// Not a toggle, a message
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
if (args.length >= 1) {
|
|
|
|
String aMessage = args[0];
|
|
|
|
for (int i = 1; i <= args.length - 1; i++) {
|
|
|
|
aMessage = aMessage + " " + args[i];
|
|
|
|
}
|
|
|
|
|
2012-04-11 04:14:09 +02:00
|
|
|
Users.getProfile(player).toggleAdminChat();
|
|
|
|
player.chat(aMessage);
|
|
|
|
Users.getProfile(player).toggleAdminChat();
|
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(player != null)
|
|
|
|
{
|
|
|
|
PlayerProfile PP = Users.getProfile(player);
|
|
|
|
|
|
|
|
if (PP.getPartyChatMode())
|
|
|
|
PP.togglePartyChat();
|
|
|
|
|
|
|
|
PP.toggleAdminChat();
|
|
|
|
|
|
|
|
if (PP.getAdminChatMode()) {
|
|
|
|
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn"));
|
|
|
|
} else {
|
|
|
|
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|