diff options
6 files changed, 85 insertions, 62 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index ecc368473..fed7a2956 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -97,7 +97,6 @@ public class EssentialsEntityListener extends EntityListener @Override public void onFoodLevelChange(FoodLevelChangeEvent event) { - LOGGER.log(Level.INFO, "Getting hungry..."); if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) { event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/Spawn.java b/Essentials/src/com/earth2me/essentials/Spawn.java index 283984231..b1e06d50c 100644 --- a/Essentials/src/com/earth2me/essentials/Spawn.java +++ b/Essentials/src/com/earth2me/essentials/Spawn.java @@ -9,20 +9,23 @@ import org.bukkit.Server; import org.bukkit.World; import org.bukkit.World.Environment; -public class Spawn implements IConf { +public class Spawn implements IConf +{ private static final Logger logger = Logger.getLogger("Minecraft"); private final EssentialsConf config; private final Server server; - public Spawn(Server server, File dataFolder) { + public Spawn(Server server, File dataFolder) + { File configFile = new File(dataFolder, "spawn.yml"); this.server = server; config = new EssentialsConf(configFile); config.load(); } - public void setSpawn(Location loc, String group) { + public void setSpawn(Location loc, String group) + { Map<String, Object> map = new HashMap<String, Object>(); map.put("world", loc.getWorld().getName()); map.put("x", loc.getX()); @@ -33,18 +36,24 @@ public class Spawn implements IConf { config.setProperty(group, map); config.save(); - if ("default".equals(group)) { + if ("default".equals(group)) + { loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } } - public Location getSpawn(String group) { - if (config.getProperty(group) == null) { + public Location getSpawn(String group) + { + if (config.getProperty(group) == null) + { group = "default"; } - if (config.getProperty(group) == null) { - for (World w : server.getWorlds()) { - if (w.getEnvironment() != Environment.NORMAL) { + if (config.getProperty(group) == null) + { + for (World w : server.getWorlds()) + { + if (w.getEnvironment() != Environment.NORMAL) + { continue; } return w.getSpawnLocation(); @@ -52,15 +61,19 @@ public class Spawn implements IConf { } String worldId = config.getString(group + ".world", ""); World world = server.getWorlds().get(server.getWorlds().size() > 1 ? 1 : 0); - for (World w : server.getWorlds()) { - if (w.getEnvironment() != Environment.NORMAL) { + for (World w : server.getWorlds()) + { + if (w.getEnvironment() != Environment.NORMAL) + { continue; } world = w; break; } - for (World w : server.getWorlds()) { - if (!w.getName().equals(worldId)) { + for (World w : server.getWorlds()) + { + if (!w.getName().equals(worldId)) + { continue; } world = w; @@ -70,18 +83,20 @@ public class Spawn implements IConf { double x = config.getDouble(group + ".x", config.getDouble("default.x", 0)); double y = config.getDouble(group + ".y", config.getDouble("default.y", 0)); double z = config.getDouble(group + ".z", config.getDouble("default.z", 0)); - float yaw = (float) config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0)); - float pitch = (float) config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0)); + float yaw = (float)config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0)); + float pitch = (float)config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0)); Location retval = new Location(world, x, y, z, yaw, pitch); - if (y < 1) { + if (y < 1) + { retval.setY(world.getHighestBlockYAt(retval)); } return retval; } - public void reloadConfig() { + public void reloadConfig() + { config.load(); } } diff --git a/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java b/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java index 90c66aa35..0f3ca01cc 100644 --- a/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java +++ b/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java @@ -37,7 +37,8 @@ public class TNTExplodeListener extends EntityListener implements Runnable timer = ess.scheduleSyncDelayedTask(this, 1000); return; } - if (timer != -1) { + if (timer != -1) + { ess.getScheduler().cancelTask(timer); timer = ess.scheduleSyncDelayedTask(this, 1000); } @@ -54,28 +55,31 @@ public class TNTExplodeListener extends EntityListener implements Runnable { return; } - try { - final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size()); - final Player[] players = ess.getServer().getOnlinePlayers(); - final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length); - final Location loc = event.getLocation(); - for (Player player : players) + try { - if (player.getWorld().equals(loc.getWorld())) + final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size()); + final Player[] players = ess.getServer().getOnlinePlayers(); + final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length); + final Location loc = event.getLocation(); + for (Player player : players) { - blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ())); + if (player.getWorld().equals(loc.getWorld())) + { + blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ())); + } } - } - for (Block block : event.blockList()) - { - final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ()); - if (!blocksUnderPlayers.contains(cp)) + for (Block block : event.blockList()) { - set.add(cp); + final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ()); + if (!blocksUnderPlayers.contains(cp)) + { + set.add(cp); + } } + ((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set)); } - ((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set)); - } catch (Throwable ex) { + catch (Throwable ex) + { Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex); } event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index 8c082be3e..69f6478f7 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -18,22 +18,22 @@ public class Trade private final transient Double money; private final transient ItemStack itemStack; private final transient IEssentials ess; - + public Trade(final String command, final IEssentials ess) { this(command, null, null, ess); } - + public Trade(final double money, final IEssentials ess) { this(null, money, null, ess); } - + public Trade(final ItemStack items, final IEssentials ess) { this(null, null, items, ess); } - + private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess) { this.command = command; @@ -41,7 +41,7 @@ public class Trade this.itemStack = item; this.ess = ess; } - + public void isAffordableFor(final IUser user) throws ChargeException { final double mon = user.getMoney(); @@ -52,13 +52,13 @@ public class Trade { throw new ChargeException(Util.i18n("notEnoughMoney")); } - + if (getItemStack() != null && !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack)) { throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " "))); } - + if (command != null && !command.isEmpty() && !user.isAuthorized("essentials.nocommandcost.all") && !user.isAuthorized("essentials.nocommandcost." + command) @@ -69,12 +69,12 @@ public class Trade throw new ChargeException(Util.i18n("notEnoughMoney")); } } - + public void pay(final IUser user) { pay(user, true); } - + public boolean pay(final IUser user, final boolean dropItems) { boolean success = true; @@ -100,7 +100,7 @@ public class Trade } return success; } - + public void charge(final IUser user) throws ChargeException { if (getMoney() != null) @@ -134,18 +134,18 @@ public class Trade user.takeMoney(cost); } } - + public Double getMoney() { return money; } - + public ItemStack getItemStack() { return itemStack; } private static FileWriter fw = null; - + public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess) { if (!ess.getSettings().isEcoLogEnabled()) @@ -239,7 +239,7 @@ public class Trade Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex); } } - + public static void closeLog() { if (fw != null) diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index 69ddb5354..580b2aaf9 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -52,7 +52,7 @@ public class UserMap implements Function<String, User>, IConf } catch (ComputationException ex) { - Bukkit.getLogger().log(Level.INFO, "Failed to preload user "+name, ex); + Bukkit.getLogger().log(Level.INFO, "Failed to preload user " + name, ex); } } } diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index 66cdf1f9c..fd1426f10 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -21,28 +21,34 @@ public class Worth implements IConf { String itemname = itemStack.getType().toString().toLowerCase().replace("_", ""); double result; - result = config.getDouble("worth."+itemname+"."+itemStack.getDurability(), Double.NaN); - if (Double.isNaN(result)) { - result = config.getDouble("worth."+itemname+".0", Double.NaN); + result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN); + if (Double.isNaN(result)) + { + result = config.getDouble("worth." + itemname + ".0", Double.NaN); } - if (Double.isNaN(result)) { - result = config.getDouble("worth."+itemname, Double.NaN); + if (Double.isNaN(result)) + { + result = config.getDouble("worth." + itemname, Double.NaN); } - if (Double.isNaN(result)) { - result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN); + if (Double.isNaN(result)) + { + result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN); } return result; } public void setPrice(ItemStack itemStack, double price) { - if (itemStack.getType().getData() == null) { + if (itemStack.getType().getData() == null) + { config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price); - } else { + } + else + { // Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0. - config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price); + config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "") + "." + itemStack.getDurability(), price); } - config.removeProperty("worth-"+itemStack.getTypeId()); + config.removeProperty("worth-" + itemStack.getTypeId()); config.save(); } @@ -50,5 +56,4 @@ public class Worth implements IConf { config.load(); } - } |