Updated Essentials to work with R5

This commit is contained in:
snowleo 2012-02-21 17:33:46 +01:00
parent 3b81593ebb
commit f46948249e
22 changed files with 130 additions and 192 deletions

View file

@ -66,7 +66,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials public class Essentials extends JavaPlugin implements IEssentials
{ {
public static final int BUKKIT_VERSION = 1846; public static final int BUKKIT_VERSION = 1952;
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings; private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);

View file

@ -3,7 +3,6 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
@ -12,12 +11,14 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.config.Configuration;
public class EssentialsConf extends Configuration public class EssentialsConf extends YamlConfiguration
{ {
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient File configFile; private transient File configFile;
@ -26,15 +27,10 @@ public class EssentialsConf extends Configuration
public EssentialsConf(final File configFile) public EssentialsConf(final File configFile)
{ {
super(configFile); super();
this.configFile = configFile; this.configFile = configFile;
if (this.root == null)
{
this.root = new HashMap<String, Object>();
}
} }
@Override
public void load() public void load()
{ {
configFile = configFile.getAbsoluteFile(); configFile = configFile.getAbsoluteFile();
@ -105,20 +101,24 @@ public class EssentialsConf extends Configuration
} }
} }
try try
{ {
super.load(); super.load(configFile);
} }
catch (RuntimeException e) catch (FileNotFoundException ex)
{ {
LOGGER.log(Level.SEVERE, null, ex);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
catch (InvalidConfigurationException ex)
{
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis()); File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
configFile.renameTo(broken); configFile.renameTo(broken);
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), e.getCause()); LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
}
if (this.root == null)
{
this.root = new HashMap<String, Object>();
} }
} }
@ -193,7 +193,7 @@ public class EssentialsConf extends Configuration
public boolean hasProperty(final String path) public boolean hasProperty(final String path)
{ {
return getProperty(path) != null; return isSet(path);
} }
public Location getLocation(final String path, final Server server) throws Exception public Location getLocation(final String path, final Server server) throws Exception
@ -218,24 +218,25 @@ public class EssentialsConf extends Configuration
public void setProperty(final String path, final Location loc) public void setProperty(final String path, final Location loc)
{ {
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName()); set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
setProperty((path == null ? "" : path + ".") + "x", loc.getX()); set((path == null ? "" : path + ".") + "x", loc.getX());
setProperty((path == null ? "" : path + ".") + "y", loc.getY()); set((path == null ? "" : path + ".") + "y", loc.getY());
setProperty((path == null ? "" : path + ".") + "z", loc.getZ()); set((path == null ? "" : path + ".") + "z", loc.getZ());
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw()); set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch()); set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
} }
@Override
public ItemStack getItemStack(final String path) public ItemStack getItemStack(final String path)
{ {
final ItemStack stack = new ItemStack( final ItemStack stack = new ItemStack(
Material.valueOf(getString(path + ".type", "AIR")), Material.valueOf(getString(path + ".type", "AIR")),
getInt(path + ".amount", 1), getInt(path + ".amount", 1),
(short)getInt(path + ".damage", 0)); (short)getInt(path + ".damage", 0));
final List<String> enchants = getKeys(path + ".enchant"); final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
if (enchants != null) if (enchants != null)
{ {
for (String enchant : enchants) for (String enchant : enchants.getKeys(false))
{ {
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH)); final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
if (enchantment == null) if (enchantment == null)
@ -271,14 +272,14 @@ public class EssentialsConf extends Configuration
} }
// getData().getData() is broken // getData().getData() is broken
//map.put("data", stack.getDurability()); //map.put("data", stack.getDurability());
setProperty(path, map); set(path, map);
} }
public long getLong(final String path, final long def) public long getLong(final String path, final long def)
{ {
try try
{ {
final Number num = (Number)getProperty(path); final Number num = (Number)get(path);
return num == null ? def : num.longValue(); return num == null ? def : num.longValue();
} }
catch (ClassCastException ex) catch (ClassCastException ex)
@ -292,7 +293,7 @@ public class EssentialsConf extends Configuration
{ {
try try
{ {
Number num = (Number)getProperty(path); Number num = (Number)get(path);
return num == null ? def : num.doubleValue(); return num == null ? def : num.doubleValue();
} }
catch (ClassCastException ex) catch (ClassCastException ex)
@ -300,4 +301,27 @@ public class EssentialsConf extends Configuration
return def; return def;
} }
} }
public void save() {
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
}
public Object getProperty(String path) {
return get(path);
}
public void setProperty(String path, Object object) {
set(path, object);
}
public void removeProperty(String path) {
set(path, null);
}
} }

View file

@ -95,7 +95,7 @@ public class EssentialsUpgrade
} }
final EssentialsConf conf = new EssentialsConf(configFile); final EssentialsConf conf = new EssentialsConf(configFile);
conf.load(); conf.load();
List<String> lines = conf.getStringList(name, null); List<String> lines = conf.getStringList(name);
if (lines != null && !lines.isEmpty()) if (lines != null && !lines.isEmpty())
{ {
if (!file.createNewFile()) if (!file.createNewFile())
@ -332,7 +332,7 @@ public class EssentialsUpgrade
config.setProperty("homes.home", defloc); config.setProperty("homes.home", defloc);
} }
List<String> worlds = config.getKeys("home.worlds"); Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
Location loc; Location loc;
String worldName; String worldName;
@ -381,7 +381,7 @@ public class EssentialsUpgrade
} }
final EssentialsConf usersConfig = new EssentialsConf(usersFile); final EssentialsConf usersConfig = new EssentialsConf(usersFile);
usersConfig.load(); usersConfig.load();
for (String username : usersConfig.getKeys(null)) for (String username : usersConfig.getKeys(false))
{ {
final User user = new User(new OfflinePlayer(username, ess), ess); final User user = new User(new OfflinePlayer(username, ess), ess);
final String nickname = usersConfig.getString(username + ".nickname"); final String nickname = usersConfig.getString(username + ".nickname");
@ -389,7 +389,7 @@ public class EssentialsUpgrade
{ {
user.setNickname(nickname); user.setNickname(nickname);
} }
final List<String> mails = usersConfig.getStringList(username + ".mail", null); final List<String> mails = usersConfig.getStringList(username + ".mail");
if (mails != null && !mails.isEmpty()) if (mails != null && !mails.isEmpty())
{ {
user.setMails(mails); user.setMails(mails);
@ -701,7 +701,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("spawns")) if (!config.hasProperty("spawns"))
{ {
final Spawns spawns = new Spawns(); final Spawns spawns = new Spawns();
List<String> keys = config.getKeys(); Set<String> keys = config.getKeys(false);
for (String group : keys) for (String group : keys)
{ {
Location loc = getFakeLocation(config, group); Location loc = getFakeLocation(config, group);
@ -748,7 +748,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("jails")) if (!config.hasProperty("jails"))
{ {
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails(); final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
List<String> keys = config.getKeys(); Set<String> keys = config.getKeys(false);
for (String jailName : keys) for (String jailName : keys)
{ {
Location loc = getFakeLocation(config, jailName); Location loc = getFakeLocation(config, jailName);

View file

@ -65,7 +65,7 @@ public interface ISettings extends IConf
boolean getRespawnAtHome(); boolean getRespawnAtHome();
List getMultipleHomes(); Set getMultipleHomes();
int getHomeLimit(String set); int getHomeLimit(String set);

View file

@ -666,18 +666,6 @@ public class OfflinePlayer implements Player
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public int getExperience()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setExperience(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override @Override
public int getLevel() public int getLevel()
{ {

View file

@ -45,15 +45,15 @@ public class Settings implements ISettings
} }
@Override @Override
public List<String> getMultipleHomes() public Set<String> getMultipleHomes()
{ {
return config.getKeys("sethome-multiple"); return config.getConfigurationSection("sethome-multiple").getKeys(false);
} }
@Override @Override
public int getHomeLimit(final User user) public int getHomeLimit(final User user)
{ {
final List<String> homeList = getMultipleHomes(); final Set<String> homeList = getMultipleHomes();
if (homeList == null) if (homeList == null)
{ {
//TODO: Replace this code to remove backwards compat, after settings are automatically updated //TODO: Replace this code to remove backwards compat, after settings are automatically updated
@ -116,7 +116,7 @@ public class Settings implements ISettings
@Override @Override
public boolean isCommandDisabled(String label) public boolean isCommandDisabled(String label)
{ {
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0))) for (String c : config.getStringList("disabled-commands"))
{ {
if (!c.equalsIgnoreCase(label)) if (!c.equalsIgnoreCase(label))
{ {
@ -136,7 +136,7 @@ public class Settings implements ISettings
@Override @Override
public boolean isCommandRestricted(String label) public boolean isCommandRestricted(String label)
{ {
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0))) for (String c : config.getStringList("restricted-commands"))
{ {
if (!c.equalsIgnoreCase(label)) if (!c.equalsIgnoreCase(label))
{ {
@ -150,7 +150,7 @@ public class Settings implements ISettings
@Override @Override
public boolean isPlayerCommand(String label) public boolean isPlayerCommand(String label)
{ {
for (String c : config.getStringList("player-commands", new ArrayList<String>(0))) for (String c : config.getStringList("player-commands"))
{ {
if (!c.equalsIgnoreCase(label)) if (!c.equalsIgnoreCase(label))
{ {
@ -164,9 +164,7 @@ public class Settings implements ISettings
@Override @Override
public boolean isCommandOverridden(String name) public boolean isCommandOverridden(String name)
{ {
List<String> defaultList = new ArrayList<String>(1); for (String c : config.getStringList("overridden-commands"))
defaultList.add("god");
for (String c : config.getStringList("overridden-commands", defaultList))
{ {
if (!c.equalsIgnoreCase(name)) if (!c.equalsIgnoreCase(name))
{ {
@ -215,7 +213,7 @@ public class Settings implements ISettings
@Override @Override
public Object getKit(String name) public Object getKit(String name)
{ {
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits"); Map<String, Object> kits = (Map<String, Object>)config.get("kits");
for (Map.Entry<String, Object> entry : kits.entrySet()) for (Map.Entry<String, Object> entry : kits.entrySet())
{ {
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
@ -229,7 +227,7 @@ public class Settings implements ISettings
@Override @Override
public Map<String, Object> getKits() public Map<String, Object> getKits()
{ {
return (Map<String, Object>)config.getProperty("kits"); return (Map<String, Object>)config.get("kits");
} }
@Override @Override
@ -254,7 +252,7 @@ public class Settings implements ISettings
{ {
} }
return ChatColor.getByCode(Integer.parseInt(colorName, 16)); return ChatColor.getByChar(colorName);
} }
@Override @Override
@ -355,7 +353,7 @@ public class Settings implements ISettings
public void reloadConfig() public void reloadConfig()
{ {
config.load(); config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList())); noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = getEnabledSigns(); enabledSigns = getEnabledSigns();
itemSpawnBl = getItemSpawnBlacklist(); itemSpawnBl = getItemSpawnBlacklist();
chatFormats.clear(); chatFormats.clear();
@ -407,7 +405,7 @@ public class Settings implements ISettings
{ {
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>(); List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
for (String signName : config.getStringList("enabledSigns", null)) for (String signName : config.getStringList("enabledSigns"))
{ {
signName = signName.trim().toUpperCase(Locale.ENGLISH); signName = signName.trim().toUpperCase(Locale.ENGLISH);
if (signName.isEmpty()) if (signName.isEmpty())

View file

@ -209,7 +209,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private List<Integer> _getUnlimited() private List<Integer> _getUnlimited()
{ {
return config.getIntList("unlimited", new ArrayList<Integer>()); return config.getIntegerList("unlimited");
} }
public List<Integer> getUnlimited() public List<Integer> getUnlimited()
@ -383,7 +383,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private List<String> _getMails() private List<String> _getMails()
{ {
return config.getStringList("mail", new ArrayList<String>()); return config.getStringList("mail");
} }
public List<String> getMails() public List<String> getMails()
@ -491,7 +491,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public List<String> getIgnoredPlayers() public List<String> getIgnoredPlayers()
{ {
return config.getStringList("ignore", new ArrayList<String>()); return config.getStringList("ignore");
} }
public void setIgnoredPlayers(List<String> players) public void setIgnoredPlayers(List<String> players)

View file

@ -231,12 +231,6 @@ public class FakeWorld implements World
return name; return name;
} }
@Override
public long getId()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override @Override
public Location getSpawnLocation() public Location getSpawnLocation()
{ {
@ -578,4 +572,16 @@ public class FakeWorld implements World
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> type)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Collection<Entity> getEntitiesByClasses(Class<?>... types)
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View file

@ -6,7 +6,7 @@ import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EndermanPickupEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
@ -44,7 +44,7 @@ public class SignEntityListener implements Listener
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onEndermanPickup(final EndermanPickupEvent event) public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{ {
if (event.isCancelled() || ess.getSettings().areSignsDisabled()) if (event.isCancelled() || ess.getSettings().areSignsDisabled())
{ {

View file

@ -14,6 +14,7 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe; import org.bukkit.inventory.Recipe;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -250,7 +251,6 @@ public class FakeServer implements Server
return worlds; return worlds;
} }
@Override
public World createWorld(String string, Environment e) public World createWorld(String string, Environment e)
{ {
World w = new FakeWorld(string, e); World w = new FakeWorld(string, e);
@ -258,7 +258,6 @@ public class FakeServer implements Server
return w; return w;
} }
@Override
public World createWorld(String string, Environment e, long l) public World createWorld(String string, Environment e, long l)
{ {
World w = new FakeWorld(string, e); World w = new FakeWorld(string, e);
@ -331,18 +330,6 @@ public class FakeServer implements Server
return player; return player;
} }
@Override
public World createWorld(String string, Environment e, ChunkGenerator cg)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public World createWorld(String string, Environment e, long l, ChunkGenerator cg)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override @Override
public World createWorld(WorldCreator creator) public World createWorld(WorldCreator creator)
{ {
@ -666,4 +653,28 @@ public class FakeServer implements Server
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public List<Recipe> getRecipesFor(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Iterator<Recipe> recipeIterator()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clearRecipes()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void resetRecipes()
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View file

@ -856,7 +856,7 @@ public class WorldDataHolder {
PluginManager pm = server.getPluginManager(); PluginManager pm = server.getPluginManager();
Plugin[] plugins = pm.getPlugins(); Plugin[] plugins = pm.getPlugins();
for (int i = 0; i < plugins.length; i++) { for (int i = 0; i < plugins.length; i++) {
plugins[i].getConfiguration().load(); //plugins[i].getConfiguration().load();
try { try {
plugins[i].getClass().getMethod("setupPermissions").invoke(plugins[i]); plugins[i].getClass().getMethod("setupPermissions").invoke(plugins[i]);
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -37,7 +37,7 @@ public class GMGroupEvent extends Event {
protected Action action; protected Action action;
public GMGroupEvent(Group group, Action action) { public GMGroupEvent(Group group, Action action) {
super(action.toString()); super();
this.group = group; this.group = group;
this.action = action; this.action = action;
@ -45,7 +45,7 @@ public class GMGroupEvent extends Event {
} }
public GMGroupEvent(String groupName, Action action) { public GMGroupEvent(String groupName, Action action) {
super(action.toString()); super();
this.groupName = groupName; this.groupName = groupName;
this.action = action; this.action = action;

View file

@ -32,7 +32,7 @@ public class GMSystemEvent extends Event {
protected Action action; protected Action action;
public GMSystemEvent(Action action) { public GMSystemEvent(Action action) {
super(action.toString()); super();
this.action = action; this.action = action;
} }

View file

@ -37,7 +37,7 @@ public class GMUserEvent extends Event {
protected Action action; protected Action action;
public GMUserEvent(User user, Action action) { public GMUserEvent(User user, Action action) {
super(action.toString()); super();
this.user = user; this.user = user;
this.action = action; this.action = action;
@ -45,7 +45,7 @@ public class GMUserEvent extends Event {
} }
public GMUserEvent(String userName, Action action) { public GMUserEvent(String userName, Action action) {
super(action.toString()); super();
this.userName = userName; this.userName = userName;
this.action = action; this.action = action;

View file

@ -1,36 +0,0 @@
package com.earth2me.essentials.protect;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockListener;
@Deprecated
public class EmergencyBlockListener extends BlockListener
{
@Override
public void onBlockBurn(final BlockBurnEvent event)
{
event.setCancelled(true);
}
@Override
public void onBlockIgnite(final BlockIgniteEvent event)
{
event.setCancelled(true);
}
@Override
public void onBlockFromTo(final BlockFromToEvent event)
{
event.setCancelled(true);
}
@Override
public void onBlockBreak(final BlockBreakEvent event)
{
event.setCancelled(true);
}
}

View file

@ -1,22 +0,0 @@
package com.earth2me.essentials.protect;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
@Deprecated
public class EmergencyEntityListener extends EntityListener
{
@Override
public void onEntityExplode(final EntityExplodeEvent event)
{
event.setCancelled(true);
}
@Override
public void onEntityDamage(final EntityDamageEvent event)
{
event.setCancelled(true);
}
}

View file

@ -1,16 +0,0 @@
package com.earth2me.essentials.protect;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
@Deprecated
public class EmergencyPlayerListener extends PlayerListener
{
@Override
public void onPlayerJoin(PlayerJoinEvent event)
{
event.getPlayer().sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
}
}

View file

@ -9,8 +9,6 @@ import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -65,21 +63,8 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
private void enableEmergencyMode(final PluginManager pm) private void enableEmergencyMode(final PluginManager pm)
{ {
//final EmergencyListener emListener = new EmergencyListener(); final EmergencyListener emListener = new EmergencyListener();
//pm.registerEvents(emListener, this); pm.registerEvents(emListener, this);
//TODO: Remove deprecated listners in a few weeks.
final EmergencyBlockListener emBlockListener = new EmergencyBlockListener();
final EmergencyEntityListener emEntityListener = new EmergencyEntityListener();
final EmergencyPlayerListener emPlayerListener = new EmergencyPlayerListener();
pm.registerEvent(Type.PLAYER_JOIN, emPlayerListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BURN, emBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_IGNITE, emBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_FROMTO, emBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BREAK, emBlockListener, Priority.Low, this);
pm.registerEvent(Type.ENTITY_DAMAGE, emEntityListener, Priority.Low, this);
pm.registerEvent(Type.ENTITY_EXPLODE, emEntityListener, Priority.Low, this);
for (Player player : getServer().getOnlinePlayers()) for (Player player : getServer().getOnlinePlayers())
{ {

View file

@ -328,7 +328,7 @@ public class EssentialsProtectEntityListener implements Listener
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onEndermanPickup(EndermanPickupEvent event) public void onEntityChangeBlock(EntityChangeBlockEvent event)
{ {
if (event.isCancelled()) if (event.isCancelled())
{ {

View file

@ -7,6 +7,6 @@ public class InstallationFinishedEvent extends Event
{ {
public InstallationFinishedEvent() public InstallationFinishedEvent()
{ {
super(Type.CUSTOM_EVENT); super();
} }
} }

View file

@ -36,7 +36,7 @@ public class UserManager implements IConf
public final String getUserByAddress(final String search) public final String getUserByAddress(final String search)
{ {
final List<String> usernames = users.getKeys(null); final Set<String> usernames = users.getKeys(false);
for (String username : usernames) for (String username : usernames)
{ {
final String address = users.getString(username + "." + ADDRESS, null); final String address = users.getString(username + "." + ADDRESS, null);
@ -73,7 +73,7 @@ public class UserManager implements IConf
{ {
users.load(); users.load();
spyusers.clear(); spyusers.clear();
final List<String> keys = users.getKeys(null); final Set<String> keys = users.getKeys(false);
for (String key : keys) for (String key : keys)
{ {
if (isSpy(key)) if (isSpy(key))

View file

@ -183,7 +183,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
if (config.getBoolean("log-enabled", false)) if (config.getBoolean("log-enabled", false))
{ {
LOGGER.addHandler(this); LOGGER.addHandler(this);
logUsers = config.getStringList("log-users", new ArrayList<String>()); logUsers = config.getStringList("log-users");
final String level = config.getString("log-level", "info"); final String level = config.getString("log-level", "info");
try try
{ {
@ -351,7 +351,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private void sendCommand(final Chat chat, final String message) private void sendCommand(final Chat chat, final String message)
{ {
if (config.getStringList("op-users", new ArrayList<String>()).contains(StringUtils.parseBareAddress(chat.getParticipant()))) if (config.getStringList("op-users").contains(StringUtils.parseBareAddress(chat.getParticipant())))
{ {
try try
{ {