Log Protection alerts to the console

Also added the world name, which was missing.
This commit is contained in:
snowleo 2011-07-15 19:52:29 +02:00
parent 37d77f3e89
commit 7e65038ae7

View File

@ -26,7 +26,6 @@ import org.bukkit.plugin.java.JavaPlugin;
public class EssentialsProtect extends JavaPlugin implements IConf, IProtect public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
{ {
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class); private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class); private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class); private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
@ -79,30 +78,34 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
public void alert(final User user, final String item, final String type) public void alert(final User user, final String item, final String type)
{ {
final Location loc = user.getLocation(); final Location loc = user.getLocation();
final String warnMessage = Util.format("alertFormat", user.getName(), type, item,
loc.getWorld().getName() + "," + loc.getBlockX() + ","
+ loc.getBlockY() + "," + loc.getBlockZ());
LOGGER.log(Level.WARNING, warnMessage);
for (Player p : this.getServer().getOnlinePlayers()) for (Player p : this.getServer().getOnlinePlayers())
{ {
final User alertUser = ess.getUser(p); final User alertUser = ess.getUser(p);
if (alertUser.isAuthorized("essentials.protect.alerts")) if (alertUser.isAuthorized("essentials.protect.alerts"))
{ {
alertUser.sendMessage(Util.format("alertFormat", user.getName(), type, item, formatCoords(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); alertUser.sendMessage(warnMessage);
} }
} }
} }
public static String formatCoords(final int x, final int y, final int z)
{
return x + "," + y + "," + z;
}
public void reloadConfig() public void reloadConfig()
{ {
for (ProtectConfig protectConfig : ProtectConfig.values()) for (ProtectConfig protectConfig : ProtectConfig.values())
{ {
if (protectConfig.isList()) { if (protectConfig.isList())
{
settingsList.put(protectConfig, ess.getSettings().getProtectList(protectConfig.getConfigName())); settingsList.put(protectConfig, ess.getSettings().getProtectList(protectConfig.getConfigName()));
} else if (protectConfig.isString()) { }
else if (protectConfig.isString())
{
settingsString.put(protectConfig, ess.getSettings().getProtectString(protectConfig.getConfigName())); settingsString.put(protectConfig, ess.getSettings().getProtectString(protectConfig.getConfigName()));
} else { }
else
{
settingsBoolean.put(protectConfig, ess.getSettings().getProtectBoolean(protectConfig.getConfigName(), protectConfig.getDefaultValueBoolean())); settingsBoolean.put(protectConfig, ess.getSettings().getProtectBoolean(protectConfig.getConfigName(), protectConfig.getDefaultValueBoolean()));
} }