diff --git a/.gitignore b/.gitignore index 7152ec996..dd7da3087 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ /EssentialsPermissionsCommands/dist/ /Essentials/nbproject/private/ /Essentials/dist/ -/Essentials/build/ \ No newline at end of file +/Essentials/build/ +/YamlAnnotations/ \ No newline at end of file diff --git a/Essentials/nbproject/pmd.settings b/Essentials/nbproject/pmd.settings index 6a34e356c..824aa3ac9 100644 --- a/Essentials/nbproject/pmd.settings +++ b/Essentials/nbproject/pmd.settings @@ -1 +1,2 @@ DoNotUseThreads +SignatureDeclareThrowsException diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 8df8ef4d2..db78855e6 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -62,6 +62,7 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar +file.reference.bPermissions.jar=../lib/bPermissions.jar file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar file.reference.iCo4.jar=../lib/iCo4.jar file.reference.iCo5.jar=../lib/iCo5.jar @@ -69,6 +70,7 @@ file.reference.iCo6.jar=../lib/iCo6.jar file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar file.reference.Permissions3.jar=../lib/Permissions3.jar +file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar includes=** jar.archive.disabled=${jnlp.enabled} @@ -82,7 +84,9 @@ javac.classpath=\ ${file.reference.iCo6.jar}:\ ${file.reference.MultiCurrency.jar}:\ ${file.reference.BOSEconomy7.jar}:\ - ${file.reference.PermissionsEx.jar} + ${file.reference.PermissionsEx.jar}:\ + ${file.reference.bPermissions.jar}:\ + ${file.reference.PermissionsBukkit-1.2.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/Essentials/src/com/earth2me/essentials/Backup.java b/Essentials/src/com/earth2me/essentials/Backup.java index 6b88eaef9..b7b441b1e 100644 --- a/Essentials/src/com/earth2me/essentials/Backup.java +++ b/Essentials/src/com/earth2me/essentials/Backup.java @@ -1,35 +1,45 @@ package com.earth2me.essentials; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.CraftServer; -public class Backup implements Runnable { - private static final Logger logger = Logger.getLogger("Minecraft"); - private final CraftServer server; - private final IEssentials ess; - private boolean running = false; - private int taskId = -1; - private boolean active = false; - public Backup(IEssentials ess) { +public class Backup implements Runnable +{ + private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private transient final CraftServer server; + private transient final IEssentials ess; + private transient boolean running = false; + private transient int taskId = -1; + private transient boolean active = false; + + public Backup(final IEssentials ess) + { this.ess = ess; server = (CraftServer)ess.getServer(); - if (server.getOnlinePlayers().length > 0) { + if (server.getOnlinePlayers().length > 0) + { startTask(); } - } + } - void onPlayerJoin() { + void onPlayerJoin() + { startTask(); } - - private void startTask() { - if (!running) { - long interval = ess.getSettings().getBackupInterval()*1200; // minutes -> ticks - if (interval < 1200) { + + private void startTask() + { + if (!running) + { + final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks + if (interval < 1200) + { return; } taskId = ess.scheduleSyncRepeatingTask(this, interval, interval); @@ -37,48 +47,84 @@ public class Backup implements Runnable { } } - public void run() { - if (active) return; - active = true; - final String command = ess.getSettings().getBackupCommand(); - if (command == null || "".equals(command)) { + public void run() + { + if (active) + { return; } - logger.log(Level.INFO, Util.i18n("backupStarted")); + active = true; + final String command = ess.getSettings().getBackupCommand(); + if (command == null || "".equals(command)) + { + return; + } + LOGGER.log(Level.INFO, Util.i18n("backupStarted")); final CommandSender cs = server.getServer().console; server.dispatchCommand(cs, "save-all"); server.dispatchCommand(cs, "save-off"); - + ess.scheduleAsyncDelayedTask( - new Runnable() { - - public void run() { - try { - Process child = Runtime.getRuntime().exec(command); - child.waitFor(); - } catch (InterruptedException ex) { - logger.log(Level.SEVERE, null, ex); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } finally { - ess.scheduleSyncDelayedTask( - new Runnable() { - - public void run() { - server.dispatchCommand(cs, "save-on"); - if (server.getOnlinePlayers().length == 0) { - running = false; - if (taskId != -1) { - server.getScheduler().cancelTask(taskId); + new Runnable() + { + public void run() + { + try + { + final ProcessBuilder childBuilder = new ProcessBuilder(command); + childBuilder.redirectErrorStream(true); + childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile()); + final Process child = childBuilder.start(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream())); + try + { + child.waitFor(); + String line; + do + { + line = reader.readLine(); + if (line != null) + { + LOGGER.log(Level.INFO, line); + } } + while (line != null); + } + finally + { + reader.close(); } - active = false; - logger.log(Level.INFO, Util.i18n("backupFinished")); } - }); - } - } - }); + catch (InterruptedException ex) + { + LOGGER.log(Level.SEVERE, null, ex); + } + catch (IOException ex) + { + LOGGER.log(Level.SEVERE, null, ex); + } + finally + { + ess.scheduleSyncDelayedTask( + new Runnable() + { + public void run() + { + server.dispatchCommand(cs, "save-on"); + if (server.getOnlinePlayers().length == 0) + { + running = false; + if (taskId != -1) + { + server.getScheduler().cancelTask(taskId); + } + } + active = false; + LOGGER.log(Level.INFO, Util.i18n("backupFinished")); + } + }); + } + } + }); } - } diff --git a/Essentials/src/com/earth2me/essentials/BukkitPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/BukkitPermissionsHandler.java deleted file mode 100644 index aee9ef0b4..000000000 --- a/Essentials/src/com/earth2me/essentials/BukkitPermissionsHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.earth2me.essentials; - -import org.bukkit.entity.Player; - - -public class BukkitPermissionsHandler implements IPermissionsHandler -{ - public String getGroup(Player base) - { - return "default"; - } - - public boolean canBuild(Player base, String group) - { - return true; - } - - public boolean inGroup(Player base, String group) - { - return false; - } - - public boolean hasPermission(Player base, String node) - { - if (base.hasPermission("-" + node)) - { - return false; - } - final String[] parts = node.split("\\."); - final StringBuilder sb = new StringBuilder(); - for (String part : parts) - { - if (base.hasPermission(sb.toString() + "*")) - { - return true; - } - sb.append(part).append("."); - } - return base.hasPermission(node); - } - - public String getPrefix(Player base) - { - return ""; - } - - public String getSuffix(Player base) - { - return ""; - } -} diff --git a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java index a64f8e3c7..0fd2e9047 100755 --- a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java +++ b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java @@ -155,10 +155,6 @@ public final class DescParseTickFormat int hours = 0; int minutes = 0; - if (desc.endsWith("pm")) - { - hours += 12; - } desc = desc.toLowerCase().replaceAll("[^0-9]", ""); @@ -189,6 +185,16 @@ public final class DescParseTickFormat { throw new NumberFormatException(); } + + if (desc.endsWith("pm") && hours != 12) + { + hours += 12; + } + + if (desc.endsWith("am") && hours == 12) + { + hours -= 12; + } return hoursMinutesToTicks(hours, minutes); } diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 56693632e..43d397fda 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -17,6 +17,8 @@ */ package com.earth2me.essentials; +import com.earth2me.essentials.perm.IPermissionsHandler; +import com.earth2me.essentials.perm.ConfigPermissionsHandler; import com.earth2me.essentials.api.Economy; import com.earth2me.essentials.commands.EssentialsCommand; import java.io.*; @@ -148,9 +150,10 @@ public class Essentials extends JavaPlugin implements IEssentials LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged")); } - final ServerListener serverListener = new EssentialsPluginListener(this); + final EssentialsPluginListener serverListener = new EssentialsPluginListener(this); pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this); pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this); + confList.add(serverListener); final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this); pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this); @@ -209,10 +212,10 @@ public class Essentials extends JavaPlugin implements IEssentials final EssentialsTimer timer = new EssentialsTimer(this); getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50); Economy.setEss(this); - if (enableErrorLogging) + if (getSettings().isUpdateEnabled()) { updateTimer = new EssentialsUpdateTimer(this); - getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360)); + getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60, 20 * 3600 * 6); } LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors()))); } @@ -561,7 +564,7 @@ public class Essentials extends JavaPlugin implements IEssentials } catch (NullPointerException ex) { - return null; + return new User(base, this); } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index eaf23b773..c48f9f987 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -1,6 +1,8 @@ package com.earth2me.essentials; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -19,12 +21,12 @@ import org.bukkit.util.config.Configuration; public class EssentialsConf extends Configuration { - private static final Logger logger = Logger.getLogger("Minecraft"); - private File configFile; - private String templateName = null; - private Class resourceClass = EssentialsConf.class; + private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private transient File configFile; + private transient String templateName = null; + private transient Class resourceClass = EssentialsConf.class; - public EssentialsConf(File configFile) + public EssentialsConf(final File configFile) { super(configFile); this.configFile = configFile; @@ -42,33 +44,79 @@ public class EssentialsConf extends Configuration { if (!configFile.getParentFile().mkdirs()) { - logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString())); + LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString())); } } + // This will delete files where the first character is 0. In most cases they are broken. + if (configFile.exists() && configFile.length() != 0) + { + try + { + final InputStream input = new FileInputStream(configFile); + try + { + if (input.read() == 0) + { + input.close(); + configFile.delete(); + } + } + catch (IOException ex) + { + LOGGER.log(Level.SEVERE, null, ex); + } + finally + { + try + { + input.close(); + } + catch (IOException ex) + { + LOGGER.log(Level.SEVERE, null, ex); + } + } + } + catch (FileNotFoundException ex) + { + LOGGER.log(Level.SEVERE, null, ex); + } + } + if (!configFile.exists()) { if (templateName != null) { - logger.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString())); + LOGGER.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString())); createFromTemplate(); } else { try { - logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString())); + LOGGER.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString())); if (!configFile.createNewFile()) { - logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString())); + LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString())); } } catch (IOException ex) { - logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex); + LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex); } } } - super.load(); + + try + { + super.load(); + } + catch (RuntimeException e) + { + LOGGER.log(Level.INFO, "File: " + configFile.toString()); + throw e; + } + if (this.root == null) { this.root = new HashMap(); @@ -84,7 +132,7 @@ public class EssentialsConf extends Configuration istr = resourceClass.getResourceAsStream(templateName); if (istr == null) { - logger.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName)); + LOGGER.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName)); return; } ostr = new FileOutputStream(configFile); @@ -99,7 +147,7 @@ public class EssentialsConf extends Configuration } catch (IOException ex) { - logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex); + LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex); return; } finally @@ -124,12 +172,12 @@ public class EssentialsConf extends Configuration } catch (IOException ex) { - logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex); + LOGGER.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex); } } } - public void setTemplateName(String templateName) + public void setTemplateName(final String templateName) { this.templateName = templateName; } @@ -139,48 +187,48 @@ public class EssentialsConf extends Configuration return configFile; } - public void setTemplateName(String templateName, Class resClass) + public void setTemplateName(final String templateName, final Class resClass) { this.templateName = templateName; this.resourceClass = resClass; } - public boolean hasProperty(String path) + public boolean hasProperty(final String path) { return getProperty(path) != null; } - public Location getLocation(String path, Server server) + public Location getLocation(final String path, final Server server) throws Exception { - String worldName = getString((path != null ? path + "." : "") + "world"); + final String worldName = getString((path == null ? "" : path + ".") + "world"); if (worldName == null || worldName.isEmpty()) { return null; } - World world = server.getWorld(worldName); + final World world = server.getWorld(worldName); if (world == null) { - return null; + throw new Exception(Util.i18n("invalidWorld")); } return new Location(world, - getDouble((path != null ? path + "." : "") + "x", 0), - getDouble((path != null ? path + "." : "") + "y", 0), - getDouble((path != null ? path + "." : "") + "z", 0), - (float)getDouble((path != null ? path + "." : "") + "yaw", 0), - (float)getDouble((path != null ? path + "." : "") + "pitch", 0)); + getDouble((path == null ? "" : path + ".") + "x", 0), + getDouble((path == null ? "" : path + ".") + "y", 0), + getDouble((path == null ? "" : path + ".") + "z", 0), + (float)getDouble((path == null ? "" : path + ".") + "yaw", 0), + (float)getDouble((path == null ? "" : path + ".") + "pitch", 0)); } - public void setProperty(String path, Location loc) + public void setProperty(final String path, final Location loc) { - setProperty((path != null ? path + "." : "") + "world", loc.getWorld().getName()); - setProperty((path != null ? path + "." : "") + "x", loc.getX()); - setProperty((path != null ? path + "." : "") + "y", loc.getY()); - setProperty((path != null ? path + "." : "") + "z", loc.getZ()); - setProperty((path != null ? path + "." : "") + "yaw", loc.getYaw()); - setProperty((path != null ? path + "." : "") + "pitch", loc.getPitch()); + setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName()); + setProperty((path == null ? "" : path + ".") + "x", loc.getX()); + setProperty((path == null ? "" : path + ".") + "y", loc.getY()); + setProperty((path == null ? "" : path + ".") + "z", loc.getZ()); + setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw()); + setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch()); } - public ItemStack getItemStack(String path) + public ItemStack getItemStack(final String path) { return new ItemStack( Material.valueOf(getString(path + ".type", "AIR")), @@ -189,9 +237,9 @@ public class EssentialsConf extends Configuration (byte)getInt(path + ".data", 0)*/); } - public void setProperty(String path, ItemStack stack) + public void setProperty(final String path, final ItemStack stack) { - Map map = new HashMap(); + final Map map = new HashMap(); map.put("type", stack.getType().toString()); map.put("amount", stack.getAmount()); map.put("damage", stack.getDurability()); @@ -200,40 +248,30 @@ public class EssentialsConf extends Configuration setProperty(path, map); } - public long getLong(String path, long def) + public long getLong(final String path, final long def) { - Number num; try { - num = (Number)getProperty(path); + final Number num = (Number)getProperty(path); + return num == null ? def : num.longValue(); } - catch(ClassCastException ex) + catch (ClassCastException ex) { return def; } - if (num == null) - { - return def; - } - return num.longValue(); } @Override - public double getDouble(String path, double def) + public double getDouble(final String path, final double def) { - Number num; try { - num = (Number)getProperty(path); + Number num = (Number)getProperty(path); + return num == null ? def : num.doubleValue(); } - catch(ClassCastException ex) + catch (ClassCastException ex) { return def; } - if (num == null) - { - return def; - } - return num.doubleValue(); } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 0d4759c64..ce97726dc 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -1,12 +1,10 @@ package com.earth2me.essentials; -import org.bukkit.craftbukkit.entity.CraftPlayer; +import java.util.List; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityListener; @@ -35,25 +33,28 @@ public class EssentialsEntityListener extends EntityListener User defender = ess.getUser(eDefend); User attacker = ess.getUser(eAttack); ItemStack is = attacker.getItemInHand(); - String command = attacker.getPowertool(is); - if (command != null && !command.isEmpty()) + List commandList = attacker.getPowertool(is); + if (commandList != null && !commandList.isEmpty()) { - attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName())); - event.setCancelled(true); - return; + for (String command : commandList) + { + + if (command != null && !command.isEmpty()) + { + attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName())); + event.setCancelled(true); + return; + } + } } } } - if (event instanceof EntityDamageEvent || event instanceof EntityDamageByBlockEvent || event instanceof EntityDamageByProjectileEvent) + if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) { - - if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) - { - CraftPlayer player = (CraftPlayer)event.getEntity(); - player.getHandle().fireTicks = 0; - player.setRemainingAir(player.getMaximumAir()); - event.setCancelled(true); - } + final Player player = (Player)event.getEntity(); + player.setFireTicks(0); + player.setRemainingAir(player.getMaximumAir()); + event.setCancelled(true); } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index ff32a9636..66de8ef29 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -73,11 +73,7 @@ public class EssentialsPlayerListener extends PlayerListener it.remove(); } } - if (user.isAfk()) - { - user.setAfk(false); - ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName())); - } + user.updateActivity(); if (ess.getSettings().changeDisplayName()) { user.setDisplayName(user.getNick()); @@ -93,12 +89,26 @@ public class EssentialsPlayerListener extends PlayerListener } final User user = ess.getUser(event.getPlayer()); - if (user.isAfk()) + if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers()) { - user.setAfk(false); - ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName())); + final Location from = event.getFrom(); + final Location to = event.getTo().clone(); + to.setX(from.getX()); + to.setY(from.getY()); + to.setZ(from.getZ()); + try + { + event.setTo(Util.getSafeDestination(to)); + } + catch (Exception ex) + { + event.setTo(to); + } + return; } + user.updateActivity(); + if (!ess.getSettings().getNetherPortalsEnabled()) { return; @@ -216,6 +226,7 @@ public class EssentialsPlayerListener extends PlayerListener user.getInventory().setContents(user.getSavedInventory()); user.setSavedInventory(null); } + user.updateActivity(); user.dispose(); if (!ess.getSettings().getReclaimSetting()) { @@ -304,9 +315,6 @@ public class EssentialsPlayerListener extends PlayerListener return; } User user = ess.getUser(event.getPlayer()); - if (user == null) { - user = new User(event.getPlayer(), ess); - } user.setNPC(false); final long currentTime = System.currentTimeMillis(); @@ -326,6 +334,7 @@ public class EssentialsPlayerListener extends PlayerListener event.disallow(Result.KICK_FULL, Util.i18n("serverFull")); return; } + event.allow(); user.setLastLogin(System.currentTimeMillis()); updateCompass(user); @@ -430,26 +439,31 @@ public class EssentialsPlayerListener extends PlayerListener { return; } - final String command = user.getPowertool(is); - if (command == null || command.isEmpty()) + final List commandList = user.getPowertool(is); + if (commandList == null || commandList.isEmpty()) { return; } - if (command.matches(".*\\{player\\}.*")) + + // We need to loop through each command and execute + for (String command : commandList) { - //user.sendMessage("Click a player to use this command"); - return; - } - if (command.startsWith("c:")) - { - for (Player p : server.getOnlinePlayers()) + if (command.matches(".*\\{player\\}.*")) { - p.sendMessage(user.getDisplayName() + ":" + command.substring(2)); + //user.sendMessage("Click a player to use this command"); + continue; + } + else if (command.startsWith("c:")) + { + for (Player p : server.getOnlinePlayers()) + { + p.sendMessage(user.getDisplayName() + ":" + command.substring(2)); + } + } + else + { + user.getServer().dispatchCommand(user, command); } - } - else - { - user.getServer().dispatchCommand(user, command); } } @@ -473,10 +487,9 @@ public class EssentialsPlayerListener extends PlayerListener } } } - if (user.isAfk()) + if (!cmd.equalsIgnoreCase("afk")) { - user.setAfk(false); - ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName())); + user.updateActivity(); } } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java index 34632dd40..cd969a10c 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java @@ -1,6 +1,12 @@ package com.earth2me.essentials; -import com.earth2me.essentials.register.payment.Methods; +import com.earth2me.essentials.perm.BPermissionsHandler; +import com.earth2me.essentials.perm.ConfigPermissionsHandler; +import com.earth2me.essentials.perm.Permissions3Handler; +import com.earth2me.essentials.perm.Permissions2Handler; +import com.earth2me.essentials.perm.PermissionsBukkitHandler; +import com.earth2me.essentials.perm.PermissionsExHandler; +import com.earth2me.essentials.perm.SuperpermsHandler; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.event.server.PluginDisableEvent; @@ -10,7 +16,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -public class EssentialsPluginListener extends ServerListener +public class EssentialsPluginListener extends ServerListener implements IConf { private final transient IEssentials ess; private static final Logger LOGGER = Logger.getLogger("Minecraft"); @@ -41,7 +47,7 @@ public class EssentialsPluginListener extends ServerListener LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments."); } } - + private void checkPermissions() { final PluginManager pm = ess.getServer().getPluginManager(); @@ -52,30 +58,74 @@ public class EssentialsPluginListener extends ServerListener final Plugin permissionsPlugin = pm.getPlugin("Permissions"); if (permissionsPlugin == null || !permissionsPlugin.isEnabled()) { - if (ess.getSettings().useBukkitPermissions()) + final Plugin permissionsBukkitPlugin = pm.getPlugin("PermissionsBukkit"); + final Plugin bPermissionsPlugin = pm.getPlugin("bPermissions"); + if (permissionsBukkitPlugin != null && permissionsBukkitPlugin.isEnabled()) { - ess.setPermissionsHandler(new BukkitPermissionsHandler()); + if (!(ess.getPermissionsHandler() instanceof PermissionsBukkitHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions."); + ess.setPermissionsHandler(new PermissionsBukkitHandler(permissionsBukkitPlugin)); + } + } + else if (bPermissionsPlugin != null && bPermissionsPlugin.isEnabled()) + { + if (!(ess.getPermissionsHandler() instanceof BPermissionsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions."); + ess.setPermissionsHandler(new BPermissionsHandler()); + } + } + else if (ess.getSettings().useBukkitPermissions()) + { + if (!(ess.getPermissionsHandler() instanceof SuperpermsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions."); + ess.setPermissionsHandler(new SuperpermsHandler()); + } } else { - ess.setPermissionsHandler(new ConfigPermissionsHandler(ess)); + if (!(ess.getPermissionsHandler() instanceof ConfigPermissionsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using config based permissions. Enable superperms in config."); + ess.setPermissionsHandler(new ConfigPermissionsHandler(ess)); + } } } else { if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3') { - ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin)); + if (!(ess.getPermissionsHandler() instanceof Permissions3Handler)) + { + LOGGER.log(Level.INFO, "Essentials: Using Permissions 3 based permissions."); + ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin)); + } } else { - ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin)); + if (!(ess.getPermissionsHandler() instanceof Permissions2Handler)) + { + LOGGER.log(Level.INFO, "Essentials: Using Permissions 2 based permissions."); + ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin)); + } } } } else { - ess.setPermissionsHandler(new PermissionsExHandler()); + if (!(ess.getPermissionsHandler() instanceof PermissionsExHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using PermissionsEx based permissions."); + ess.setPermissionsHandler(new PermissionsExHandler()); + } } } + + @Override + public void reloadConfig() + { + checkPermissions(); + } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java index 639802776..f3b447dae 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java @@ -24,16 +24,17 @@ public class EssentialsTimer implements Runnable { final User user = ess.getUser(player); onlineUsers.add(user); - user.setLastActivity(currentTime); + user.setLastOnlineActivity(currentTime); + user.checkActivity(); } final Iterator iterator = onlineUsers.iterator(); while (iterator.hasNext()) { final User user = iterator.next(); - if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout()) + if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout()) { - user.setLastLogout(user.getLastActivity()); + user.setLastLogout(user.getLastOnlineActivity()); iterator.remove(); continue; } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java index f00f644cd..6f7579d4e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java @@ -4,65 +4,81 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.bukkit.entity.Player; class EssentialsUpdateTimer implements Runnable { - private URL url; - private final Essentials ess; - private static final Logger logger = Logger.getLogger("Minecraft"); - - public EssentialsUpdateTimer(Essentials ess) + private transient URL url; + private final transient IEssentials ess; + private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*"); + + public EssentialsUpdateTimer(final IEssentials ess) { this.ess = ess; try { - url = new URL("http://127.0.0.1:8080/check"); + url = new URL("http://essentialsupdate.appspot.com/check"); } catch (MalformedURLException ex) { - logger.log(Level.SEVERE, "Invalid url!", ex); + LOGGER.log(Level.SEVERE, "Invalid url!", ex); } } + @Override public void run() { try { - StringBuilder sb = new StringBuilder(); - sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8")); - sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8")); - sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8")); - sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8")); - sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8")); - sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8")); - for (BigInteger bigInteger : ess.getErrors().keySet()) + final StringBuilder builder = new StringBuilder(); + String bukkitVersion = ess.getServer().getVersion(); + final Matcher versionMatch = pattern.matcher(bukkitVersion); + if (versionMatch.matches()) { - sb.append("&e[]=").append(bigInteger.toString(36)); + bukkitVersion = versionMatch.group(4); } - URLConnection conn = url.openConnection(); + builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8")); + builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8")); + final URLConnection conn = url.openConnection(); conn.setConnectTimeout(10000); conn.setDoOutput(true); conn.connect(); - OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); - wr.write(sb.toString()); - wr.flush(); - BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); - String ret = br.readLine(); - wr.close(); - br.close(); - logger.log(Level.INFO, ret); + final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); + writer.write(builder.toString()); + writer.flush(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + final String ret = reader.readLine(); + writer.close(); + reader.close(); + if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK")) + { + LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret); + if (ret.startsWith("New Version")) + { + for (Player player : ess.getServer().getOnlinePlayers()) + { + final User user = ess.getUser(player); + if (user.isAuthorized("essentials.admin.notices.update")) + { + user.sendMessage(ret); + } + } + } + } } catch (IOException ex) { - logger.log(Level.SEVERE, "Failed to open connection", ex); + LOGGER.log(Level.SEVERE, "Failed to open connection", ex); } - } + } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java index c6c7effd8..ffe4f5375 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -5,7 +5,9 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Location; @@ -197,6 +199,133 @@ public class EssentialsUpgrade doneFile.save(); } + private void updateUsersPowerToolsFormat() + { + if (doneFile.getBoolean("updateUsersPowerToolsFormat", false)) + { + return; + } + final File userdataFolder = new File(ess.getDataFolder(), "userdata"); + if (!userdataFolder.exists() || !userdataFolder.isDirectory()) + { + return; + } + final File[] userFiles = userdataFolder.listFiles(); + + for (File file : userFiles) + { + if (!file.isFile() || !file.getName().endsWith(".yml")) + { + continue; + } + final EssentialsConf config = new EssentialsConf(file); + try + { + config.load(); + if (config.hasProperty("powertools")) + { + @SuppressWarnings("unchecked") + final Map powertools = (Map)config.getProperty("powertools"); + if (powertools == null) + { + continue; + } + for (Map.Entry entry : powertools.entrySet()) + { + if (entry.getValue() instanceof String) + { + List temp = new ArrayList(); + temp.add((String)entry.getValue()); + ((Map)powertools).put(entry.getKey(), temp); + } + } + config.save(); + } + } + catch (RuntimeException ex) + { + LOGGER.log(Level.INFO, "File: " + file.toString()); + throw ex; + } + } + doneFile.setProperty("updateUsersPowerToolsFormat", true); + doneFile.save(); + } + + private void updateUsersHomesFormat() + { + if (doneFile.getBoolean("updateUsersHomesFormat", false)) + { + return; + } + final File userdataFolder = new File(ess.getDataFolder(), "userdata"); + if (!userdataFolder.exists() || !userdataFolder.isDirectory()) + { + return; + } + final File[] userFiles = userdataFolder.listFiles(); + + for (File file : userFiles) + { + if (!file.isFile() || !file.getName().endsWith(".yml")) + { + continue; + } + final EssentialsConf config = new EssentialsConf(file); + try + { + + config.load(); + if (config.hasProperty("home") && config.hasProperty("home.default")) + { + @SuppressWarnings("unchecked") + final String defworld = (String)config.getProperty("home.default"); + final Location defloc = getFakeLocation(config,"home.worlds." + defworld); + if (defloc != null) + { + config.setProperty("homes.home", defloc); + } + + List worlds = config.getKeys("home.worlds"); + Location loc; + String worldName; + + if (worlds == null) + { + continue; + } + for (String world : worlds) + { + if (defworld.equalsIgnoreCase(world)) + { + continue; + } + loc = getFakeLocation(config, "home.worlds." + world); + if (loc == null) + { + continue; + } + worldName = loc.getWorld().getName().toLowerCase(); + if (worldName != null && !worldName.isEmpty()) + { + config.setProperty("homes." + worldName, loc); + } + } + config.removeProperty("home"); + config.save(); + } + + } + catch (RuntimeException ex) + { + LOGGER.log(Level.INFO, "File: " + file.toString()); + throw ex; + } + } + doneFile.setProperty("updateUsersHomesFormat", true); + doneFile.save(); + } + private void moveUsersDataToUserdataFolder() { final File usersFile = new File(ess.getDataFolder(), "users.yml"); @@ -232,12 +361,12 @@ public class EssentialsUpgrade } if (world != null) { - user.setHome(new Location(world, - ((Number)vals.get(0)).doubleValue(), - ((Number)vals.get(1)).doubleValue(), - ((Number)vals.get(2)).doubleValue(), - ((Number)vals.get(3)).floatValue(), - ((Number)vals.get(4)).floatValue()), true); + user.setHome("home", new Location(world, + ((Number)vals.get(0)).doubleValue(), + ((Number)vals.get(1)).doubleValue(), + ((Number)vals.get(2)).doubleValue(), + ((Number)vals.get(3)).floatValue(), + ((Number)vals.get(4)).floatValue())); } } } @@ -441,6 +570,25 @@ public class EssentialsUpgrade } return null; } + public Location getFakeLocation(EssentialsConf config, String path) + { + String worldName = config.getString((path != null ? path + "." : "") + "world"); + if (worldName == null || worldName.isEmpty()) + { + return null; + } + World world = getFakeWorld(worldName); + if (world == null) + { + return null; + } + return new Location(world, + config.getDouble((path != null ? path + "." : "") + "x", 0), + config.getDouble((path != null ? path + "." : "") + "y", 0), + config.getDouble((path != null ? path + "." : "") + "z", 0), + (float)config.getDouble((path != null ? path + "." : "") + "yaw", 0), + (float)config.getDouble((path != null ? path + "." : "") + "pitch", 0)); + } public void beforeSettings() { @@ -457,5 +605,7 @@ public class EssentialsUpgrade updateUsersToNewDefaultHome(); moveUsersDataToUserdataFolder(); convertWarps(); + updateUsersPowerToolsFormat(); + updateUsersHomesFormat(); } } diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 9f427b220..0512b629e 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import com.earth2me.essentials.perm.IPermissionsHandler; import com.earth2me.essentials.register.payment.Methods; import org.bukkit.World; import org.bukkit.command.Command; diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 13717f469..82c057648 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -72,6 +72,8 @@ public interface ISettings extends IConf boolean getReclaimSetting(); boolean getRespawnAtHome(); + + int getMultipleHomes(); boolean getSortListByGroups(); @@ -107,8 +109,6 @@ public interface ISettings extends IConf boolean permissionBasedItemSpawn(); - void reloadConfig(); - boolean showNonEssCommandsInHelp(); boolean spawnIfNoHome(); @@ -129,7 +129,15 @@ public interface ISettings extends IConf boolean isPlayerCommand(String string); - public boolean useBukkitPermissions(); + boolean useBukkitPermissions(); - public boolean addPrefixSuffix(); + boolean addPrefixSuffix(); + + boolean isUpdateEnabled(); + + long getAutoAfk(); + + long getAutoAfkKick(); + + boolean getFreezeAfkPlayers(); } diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index 5b2e7075e..91a121e0a 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -22,7 +22,7 @@ public interface IUser boolean isAuthorized(String node); boolean isAuthorized(IEssentialsCommand cmd); - + boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); void setLastTeleportTimestamp(long time); @@ -45,7 +45,9 @@ public interface IUser void setLastLocation(); - Location getHome(Location location); + Location getHome(String name) throws Exception; + + Location getHome(Location loc) throws Exception; String getName(); diff --git a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java index 9aee4033c..3f0f89af2 100644 --- a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java +++ b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java @@ -3,7 +3,6 @@ package com.earth2me.essentials; import java.util.HashMap; import java.util.Map; import org.bukkit.Location; -import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.Item; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -130,7 +129,7 @@ public final class InventoryWorkaround // More than a single stack! if (item.getAmount() > item.getType().getMaxStackSize()) { - cinventory.setItem(firstFree, new CraftItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability())); + cinventory.setItem(firstFree, new ItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability())); item.setAmount(item.getAmount() - item.getType().getMaxStackSize()); } else diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 1700dec3a..2b7eea8f6 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -30,6 +30,12 @@ public class Settings implements ISettings { return config.getBoolean("respawn-at-home", false); } + + @Override + public int getMultipleHomes() + { + return config.getInt("multiple-homes", 5); + } @Override public boolean getBedSetsHome() @@ -473,4 +479,28 @@ public class Settings implements ISettings { return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat")); } + + @Override + public boolean isUpdateEnabled() + { + return config.getBoolean("update-check", true); + } + + @Override + public long getAutoAfk() + { + return config.getLong("auto-afk", 300); + } + + @Override + public long getAutoAfkKick() + { + return config.getLong("auto-afk-kick", -1); + } + + @Override + public boolean getFreezeAfkPlayers() + { + return config.getBoolean("freeze-afk-players", false); + } } diff --git a/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java b/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java index bdd453266..90c66aa35 100644 --- a/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java +++ b/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import net.minecraft.server.ChunkPosition; import net.minecraft.server.Packet60Explosion; import org.bukkit.Location; @@ -52,6 +54,7 @@ public class TNTExplodeListener extends EntityListener implements Runnable { return; } + try { final Set set = new HashSet(event.blockList().size()); final Player[] players = ess.getServer().getOnlinePlayers(); final List blocksUnderPlayers = new ArrayList(players.length); @@ -72,6 +75,9 @@ public class TNTExplodeListener extends EntityListener implements Runnable } } ((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) { + Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex); + } event.setCancelled(true); } diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 9fb9b7433..14574b83c 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import com.earth2me.essentials.commands.NotEnoughArgumentsException; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.logging.Logger; @@ -10,6 +11,8 @@ import org.bukkit.entity.Entity; public class Teleport implements Runnable { private static final double MOVE_CONSTANT = 0.3; + + private static class Target { private final Location location; @@ -57,9 +60,9 @@ public class Teleport implements Runnable this.started = System.currentTimeMillis(); this.delay = delay; this.health = user.getHealth(); - this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT); - this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT); - this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT); + this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT); + this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT); + this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT); this.teleportTarget = target; this.chargeFor = chargeFor; } @@ -72,9 +75,9 @@ public class Teleport implements Runnable cancel(); return; } - if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX - || Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY - || Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ + if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX + || Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY + || Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ || user.getHealth() < health) { // user moved, cancel teleport cancel(true); @@ -92,7 +95,7 @@ public class Teleport implements Runnable user.sendMessage(Util.i18n("teleportationCommencing")); try { - + now(teleportTarget); if (chargeFor != null) { @@ -229,7 +232,7 @@ public class Teleport implements Runnable cooldown(false); now(new Target(loc)); } - + public void now(Location loc, Trade chargeFor) throws Exception { cooldown(false); @@ -256,14 +259,9 @@ public class Teleport implements Runnable back(null); } - public void home(Trade chargeFor) throws Exception + public void home(IUser user, String home, Trade chargeFor) throws Exception { - home(user, chargeFor); - } - - public void home(IUser user, Trade chargeFor) throws Exception - { - Location loc = user.getHome(this.user.getLocation()); + final Location loc = user.getHome(home); if (loc == null) { if (ess.getSettings().spawnIfNoHome()) @@ -272,7 +270,7 @@ public class Teleport implements Runnable } else { - throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); + throw new NotEnoughArgumentsException(); } } teleport(new Target(loc), chargeFor); diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 6c18c03ae..918f0f128 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -4,67 +4,72 @@ import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.register.payment.Method; import java.util.Calendar; import java.util.GregorianCalendar; -import java.util.logging.Logger; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class User extends UserData implements Comparable, IReplyTo, IUser { - private static final Logger logger = Logger.getLogger("Minecraft"); private boolean justPortaled = false; private CommandSender replyTo = null; - private User teleportRequester; - private boolean teleportRequestHere; - private final Teleport teleport; - private long lastActivity; + private transient User teleportRequester; + private transient boolean teleportRequestHere; + private transient final Teleport teleport; + private transient long lastOnlineActivity ; + private transient long lastActivity = System.currentTimeMillis(); private boolean hidden = false; - - User(Player base, IEssentials ess) + private transient boolean godStateBeforeAfk; + + User(final Player base, final IEssentials ess) { super(base, ess); teleport = new Teleport(this, ess); + godStateBeforeAfk = isGodModeEnabled(); } - - User update(Player base) + + User update(final Player base) { setBase(base); return this; } - - public boolean isAuthorized(IEssentialsCommand cmd) + + @Override + public boolean isAuthorized(final IEssentialsCommand cmd) { return isAuthorized(cmd, "essentials."); } - - public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix) + + @Override + public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix) { return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName())); } - - public boolean isAuthorized(String node) + + @Override + public boolean isAuthorized(final String node) { if (isOp()) { return true; } - + if (isJailed()) { return false; } - + return ess.getPermissionsHandler().hasPermission(this, node); } - + public void healCooldown() throws Exception { - Calendar now = new GregorianCalendar(); + final Calendar now = new GregorianCalendar(); if (getLastHealTimestamp() > 0) { - double cooldown = ess.getSettings().getHealCooldown(); - Calendar cooldownTime = new GregorianCalendar(); + final double cooldown = ess.getSettings().getHealCooldown(); + final Calendar cooldownTime = new GregorianCalendar(); cooldownTime.setTimeInMillis(getLastHealTimestamp()); cooldownTime.add(Calendar.SECOND, (int)cooldown); cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0)); @@ -75,13 +80,14 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } setLastHealTimestamp(now.getTimeInMillis()); } - - public void giveMoney(double value) + + @Override + public void giveMoney(final double value) { giveMoney(value, null); } - - public void giveMoney(double value, CommandSender initiator) + + public void giveMoney(final double value, final CommandSender initiator) { if (value == 0) { @@ -91,35 +97,36 @@ public class User extends UserData implements Comparable, IReplyTo, IUser sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess))); if (initiator != null) { - initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()))); + initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())); } } - - public void payUser(User reciever, double value) throws Exception + + public void payUser(final User reciever, final double value) throws Exception { if (value == 0) { return; } - if (!canAfford(value)) - { - throw new Exception(Util.i18n("notEnoughMoney")); - } - else + if (canAfford(value)) { setMoney(getMoney() - value); reciever.setMoney(reciever.getMoney() + value); sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName())); reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName())); } + else + { + throw new Exception(Util.i18n("notEnoughMoney")); + } } - - public void takeMoney(double value) + + @Override + public void takeMoney(final double value) { takeMoney(value, null); } - - public void takeMoney(double value, CommandSender initiator) + + public void takeMoney(final double value, final CommandSender initiator) { if (value == 0) { @@ -129,99 +136,108 @@ public class User extends UserData implements Comparable, IReplyTo, IUser sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess))); if (initiator != null) { - initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()))); + initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())); } } - - public boolean canAfford(double cost) + + public boolean canAfford(final double cost) { - double mon = getMoney(); + final double mon = getMoney(); return mon >= cost || isAuthorized("essentials.eco.loan"); } - + public void dispose() { this.base = new OfflinePlayer(getName(), ess); } - + public boolean getJustPortaled() { return justPortaled; } - - public void setJustPortaled(boolean value) + + public void setJustPortaled(final boolean value) { justPortaled = value; } - - public void setReplyTo(CommandSender user) + + @Override + public void setReplyTo(final CommandSender user) { replyTo = user; } - + + @Override public CommandSender getReplyTo() { return replyTo; } - - public int compareTo(User t) - { - return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName())); - } - + @Override - public boolean equals(Object o) + public int compareTo(final User other) { - if (!(o instanceof User)) + return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(other.getDisplayName())); + } + + @Override + public boolean equals(final Object object) + { + if (!(object instanceof User)) { return false; } - return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName())); - + return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName())); + } - + @Override public int hashCode() { return ChatColor.stripColor(this.getDisplayName()).hashCode(); } - - public Boolean canSpawnItem(int itemId) + + public Boolean canSpawnItem(final int itemId) { return !ess.getSettings().itemSpawnBlacklist().contains(itemId); } - + + public Location getHome() throws Exception + { + return getHome(getHomes().get(0)); + } + public void setHome() { - setHome(getLocation(), true); + setHome("home", getLocation()); } - - public void setHome(boolean defaultHome) + + public void setHome(final String name) { - setHome(getLocation(), defaultHome); + setHome(name, getLocation()); } - + + @Override public void setLastLocation() { setLastLocation(getLocation()); } - - public void requestTeleport(User player, boolean here) + + public void requestTeleport(final User player, final boolean here) { teleportRequester = player; teleportRequestHere = here; } - + public User getTeleportRequest() { return teleportRequester; } - + public boolean isTeleportRequestHere() { return teleportRequestHere; } - + public String getNick() { final StringBuilder nickname = new StringBuilder(); @@ -245,12 +261,12 @@ public class User extends UserData implements Comparable, IReplyTo, IUser { } } - + if (ess.getSettings().addPrefixSuffix()) { final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); - + nickname.insert(0, prefix); nickname.append(suffix); if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§")) @@ -258,25 +274,25 @@ public class User extends UserData implements Comparable, IReplyTo, IUser nickname.append("§f"); } } - + return nickname.toString(); } - + public Teleport getTeleport() { return teleport; } - - public long getLastActivity() + + public long getLastOnlineActivity() { - return lastActivity; + return lastOnlineActivity; } - - public void setLastActivity(long timestamp) + + public void setLastOnlineActivity(final long timestamp) { - lastActivity = timestamp; + lastOnlineActivity = timestamp; } - + @Override public double getMoney() { @@ -284,12 +300,12 @@ public class User extends UserData implements Comparable, IReplyTo, IUser { try { - Method method = ess.getPaymentMethod().getMethod(); + final Method method = ess.getPaymentMethod().getMethod(); if (!method.hasAccount(this.getName())) { throw new Exception(); } - Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName()); + final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName()); return account.balance(); } catch (Throwable ex) @@ -298,20 +314,20 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } return super.getMoney(); } - + @Override - public void setMoney(double value) + public void setMoney(final double value) { if (ess.getPaymentMethod().hasMethod()) { try { - Method method = ess.getPaymentMethod().getMethod(); + final Method method = ess.getPaymentMethod().getMethod(); if (!method.hasAccount(this.getName())) { throw new Exception(); } - Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName()); + final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName()); account.set(value); } catch (Throwable ex) @@ -320,32 +336,39 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } super.setMoney(value); } - + @Override - public void setAfk(boolean set) + public void setAfk(final boolean set) { this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set); + if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers()) { + godStateBeforeAfk = isGodModeEnabled(); + setGodModeEnabled(true); + } + if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers()) { + setGodModeEnabled(godStateBeforeAfk); + } super.setAfk(set); } - + @Override public boolean toggleAfk() { - boolean now = super.toggleAfk(); + final boolean now = super.toggleAfk(); this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now); return now; } - + public boolean isHidden() { return hidden; } - - public void setHidden(boolean hidden) + + public void setHidden(final boolean hidden) { this.hidden = hidden; } - + public void checkJailTimeout(final long currentTime) { if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed()) @@ -363,7 +386,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } } } - + public void checkMuteTimeout(final long currentTime) { if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted()) @@ -373,7 +396,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser setMuted(false); } } - + public void checkBanTimeout(final long currentTime) { if (getBanTimeout() > 0 && getBanTimeout() < currentTime && ess.getBans().isNameBanned(getName())) @@ -382,4 +405,42 @@ public class User extends UserData implements Comparable, IReplyTo, IUser ess.getBans().unbanByName(getName()); } } + + public void updateActivity() + { + if (isAfk()) + { + setAfk(false); + ess.broadcastMessage(getName(), Util.format("userIsNotAway", getDisplayName())); + return; + } + lastActivity = System.currentTimeMillis(); + } + + public void checkActivity() + { + final long autoafkkick = ess.getSettings().getAutoAfkKick(); + if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis() + && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt")) + { + final String kickReason = Util.format("autoAfkKickReason", autoafkkick/60.0); + kickPlayer(kickReason); + + + for (Player player : ess.getServer().getOnlinePlayers()) + { + final User user = ess.getUser(player); + if (user.isAuthorized("essentials.kick.notify")) + { + player.sendMessage(Util.format("playerKicked", Console.NAME, getName(), kickReason)); + } + } + } + final long autoafk = ess.getSettings().getAutoAfk(); + if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis()) + { + setAfk(true); + ess.broadcastMessage(getName(), Util.format("userIsAway", getDisplayName())); + } + } } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 896339642..e5c7385b2 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -1,15 +1,14 @@ package com.earth2me.essentials; +import com.earth2me.essentials.commands.NotEnoughArgumentsException; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -36,7 +35,8 @@ public abstract class UserData extends PlayerExtension implements IConf config.load(); money = _getMoney(); unlimited = _getUnlimited(); - powertools = getPowertools(); + powertools = _getPowertools(); + homes = _getHomes(); lastLocation = _getLastLocation(); lastTeleportTimestamp = _getLastTeleportTimestamp(); lastHealTimestamp = _getLastHealTimestamp(); @@ -89,6 +89,89 @@ public abstract class UserData extends PlayerExtension implements IConf config.setProperty("money", value); config.save(); } + private Map homes; + + private Map _getHomes() + { + Object o = config.getProperty("homes"); + + if (o instanceof Map) + { + return (Map)o; + } + else + { + return new HashMap(); + } + + } + + public Location getHome(String name) throws Exception + { + Location loc = config.getLocation("homes." + name, getServer()); + if (loc == null) + { + try + { + loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer()); + } + catch (IndexOutOfBoundsException e) + { + return null; + } + catch (NumberFormatException e) + { + return null; + } + } + + return loc; + } + + public Location getHome(Location world) throws Exception + { + Location loc; + for (String home : getHomes()) + { + loc = config.getLocation("homes." + home, getServer()); + if (world.getWorld() == loc.getWorld()) + { + return loc; + } + + } + loc = config.getLocation("homes." + getHomes().get(0), getServer()); + return loc; + } + + public List getHomes() + { + List list = new ArrayList(homes.keySet()); + return list; + + } + + public void setHome(String name, Location loc) + { + homes.put(name, loc); + config.setProperty("homes." + name, loc); + config.save(); + } + + public void delHome(String name) throws Exception + { + if (getHome(name) != null) + { + homes.remove(name); + config.removeProperty("homes." + name); + config.save(); + } + else + { + //TODO: move this message to messages file + throw new Exception("Home " + name + " doesn't exist"); + } + } public boolean hasHome() { @@ -99,40 +182,6 @@ public abstract class UserData extends PlayerExtension implements IConf return false; } - public Location getHome(Location location) - { - if (!hasHome()) - { - return null; - } - World world = location.getWorld(); - String worldHome = "home.worlds." + world.getName().toLowerCase(); - if (!config.hasProperty(worldHome)) - { - String defaultWorld = config.getString("home.default"); - worldHome = "home.worlds." + defaultWorld; - } - Location loc = config.getLocation(worldHome, getServer()); - return loc; - } - - public void setHome(Location loc, boolean b) - { - String worldName = loc.getWorld().getName().toLowerCase(); - if (worldName == null || worldName.isEmpty()) - { - logger.log(Level.WARNING, Util.i18n("emptyWorldName")); - return; - } - if (b || !config.hasProperty("home.default")) - { - config.setProperty("home.default", worldName); - } - - config.setProperty("home.worlds." + worldName, loc); - config.save(); - } - public String getNickname() { return config.getString("nickname"); @@ -173,37 +222,38 @@ public abstract class UserData extends PlayerExtension implements IConf config.setProperty("unlimited", unlimited); config.save(); } - private Map powertools; + private Map powertools; @SuppressWarnings("unchecked") - private Map getPowertools() + private Map _getPowertools() { Object o = config.getProperty("powertools"); + if (o instanceof Map) { - return (Map)o; + return (Map)o; } else { - return new HashMap(); + return new HashMap(); } } - public String getPowertool(ItemStack stack) + public List getPowertool(ItemStack stack) { - return powertools.get(stack.getTypeId()); + return (List)powertools.get(stack.getTypeId()); } - public void setPowertool(ItemStack stack, String command) + public void setPowertool(ItemStack stack, List commandList) { - if (command == null || command.isEmpty()) + if (commandList == null || commandList.isEmpty()) { powertools.remove(stack.getTypeId()); } else { - powertools.put(stack.getTypeId(), command); + powertools.put(stack.getTypeId(), commandList); } config.setProperty("powertools", powertools); config.save(); @@ -212,7 +262,14 @@ public abstract class UserData extends PlayerExtension implements IConf private Location _getLastLocation() { - return config.getLocation("lastlocation", getServer()); + try + { + return config.getLocation("lastlocation", getServer()); + } + catch (Exception e) + { + return null; + } } public Location getLastLocation() diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 82231cb06..6565a9f57 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -14,6 +14,7 @@ import java.text.MessageFormat; import java.util.Calendar; import java.util.Enumeration; import java.util.GregorianCalendar; +import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -469,17 +470,34 @@ public class Util public static String joinList(Object... list) { - final StringBuilder buf = new StringBuilder(); - boolean first = true; + return joinList(", ", list); + } + + public static String joinList(String seperator, Object... list) + { + StringBuilder buf = new StringBuilder(); for (Object each : list) { - if (!first) + if (buf.length() > 0) { - buf.append(", "); - + buf.append(seperator); + } + + if(each instanceof List) + { + buf.append(joinList(seperator, ((List)each).toArray())); + } + else + { + try + { + buf.append(each.toString()); + } + catch (Exception e) + { + buf.append(each.toString()); + } } - first = false; - buf.append(each); } return buf.toString(); } @@ -487,5 +505,5 @@ public class Util public static String capitalCase(String s) { return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1); - } + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java index 03950966c..9fe17d5a0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java @@ -15,8 +15,6 @@ public class Commandafk extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); - if (args.length > 0 && user.isAuthorized("essentials.afk.others")) { User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0])); @@ -35,12 +33,13 @@ public class Commandafk extends EssentialsCommand { if (!user.toggleAfk()) { - user.sendMessage(Util.i18n("markedAsNotAway")); + //user.sendMessage(Util.i18n("markedAsNotAway")); ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName())); + user.updateActivity(); } else { - user.sendMessage(Util.i18n("markedAsAway")); + //user.sendMessage(Util.i18n("markedAsAway")); ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java index 4dd3042d0..c30975b03 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java @@ -17,7 +17,6 @@ public class Commandantioch extends EssentialsCommand @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - charge(user); ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,"); ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it."); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java index 8f6e8e8bf..6bbf8361c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java @@ -19,9 +19,8 @@ public class Commandbackup extends EssentialsCommand Backup backup = ess.getBackup(); if (backup == null) { - return; + throw new Exception(); } - charge(sender); backup.run(); sender.sendMessage(Util.i18n("backupStarted")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java index 7dd1fb449..d26df68cb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java @@ -26,7 +26,6 @@ public class Commandbalance extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); double bal = (args.length < 1 || !(user.isAuthorized("essentials.balance.others") || user.isAuthorized("essentials.balance.other")) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index 8370896b1..ded3ffdaf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -41,12 +41,11 @@ public class Commandbigtree extends EssentialsCommand final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); if (success) { - charge(user); user.sendMessage(Util.i18n("bigTreeSuccess")); } else { - user.sendMessage(Util.i18n("bigTreeFailure")); + throw new Exception(Util.i18n("bigTreeFailure")); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java index 3ca9d3fd0..684920114 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java @@ -22,7 +22,6 @@ public class Commandbroadcast extends EssentialsCommand throw new NotEnoughArgumentsException(); } - charge(sender); ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME, Util.format("broadcast", getFinalArg(args, 0))); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java index e63331203..5df3cb5d8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java @@ -21,7 +21,6 @@ public class Commandburn extends EssentialsCommand throw new NotEnoughArgumentsException(); } - charge(sender); for (Player p : server.matchPlayer(args[0])) { p.setFireTicks(Integer.parseInt(args[1]) * 20); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java index 09496c7a2..447689691 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java @@ -27,7 +27,6 @@ public class Commandclearinventory extends EssentialsCommand if (!online.isEmpty()) { - charge(user); for (Player p : online) { p.getInventory().clear(); @@ -42,7 +41,6 @@ public class Commandclearinventory extends EssentialsCommand Player p = server.getPlayer(args[0]); if (p != null) { - charge(user); p.getInventory().clear(); user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName())); } @@ -54,7 +52,6 @@ public class Commandclearinventory extends EssentialsCommand } else { - charge(user); user.getInventory().clear(); user.sendMessage(Util.i18n("inventoryCleared")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java index 0386485f4..bd07c2b9b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java @@ -15,7 +15,6 @@ public class Commandcompass extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); int r = (int)user.getCorrectedYaw(); String dir; if (r < 23) dir = "N"; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java new file mode 100644 index 000000000..aa60c9168 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java @@ -0,0 +1,48 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import com.earth2me.essentials.Util; + + +public class Commanddelhome extends EssentialsCommand +{ + public Commanddelhome() + { + super("delhome"); + } + + @Override + public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + //Allowing both formats /delhome khobbits house | /delhome khobbits:house + final String[] nameParts = args[0].split(":"); + if (nameParts[0].length() != args[0].length()) + { + args = nameParts; + } + + User user = ess.getUser(sender); + String name; + if (args.length < 1) + { + throw new NotEnoughArgumentsException(); + } + else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) + { + user = getPlayer(server, args, 0); + name = args[1]; + } + else + { + if (user == null) + { + throw new NotEnoughArgumentsException(); + } + name = args[0]; + } + user.delHome(name.toLowerCase()); + sender.sendMessage(Util.format("deleteHome", name)); + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java index 7fb6f816c..23ec04c4e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java @@ -16,7 +16,6 @@ public class Commanddeljail extends EssentialsCommand { { throw new NotEnoughArgumentsException(); } - charge(sender); ess.getJail().delJail(args[0]); sender.sendMessage(Util.format("deleteJail", args[0])); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java index 42a68dda8..7c2795dda 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java @@ -19,7 +19,6 @@ public class Commanddelwarp extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - charge(sender); ess.getWarps().delWarp(args[0]); sender.sendMessage(Util.format("deleteWarp", args[0])); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java index 9a719335e..5ceb62591 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java @@ -15,7 +15,6 @@ public class Commanddepth extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); int y = user.getLocation().getBlockY() - 63; if (y > 0) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index bf0226138..fda7061d5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -102,7 +102,6 @@ public class Commandessentials extends EssentialsCommand return; } ess.reload(); - charge(sender); sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandext.java b/Essentials/src/com/earth2me/essentials/commands/Commandext.java index 339351ef1..afb9fa3a6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandext.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandext.java @@ -30,7 +30,6 @@ public class Commandext extends EssentialsCommand { if (args.length < 1) { - charge(user); user.setFireTicks(0); user.sendMessage(Util.i18n("extinguish")); return; @@ -43,7 +42,6 @@ public class Commandext extends EssentialsCommand { for (Player p : server.matchPlayer(name)) { - charge(sender); p.setFireTicks(0); sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java index 73c314935..19e7eddf1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java @@ -17,7 +17,6 @@ public class Commandfireball extends EssentialsCommand @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - charge(user); final Vector direction = user.getEyeLocation().getDirection().multiply(2); user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java index dd3cf35f4..28164bd78 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java @@ -16,7 +16,6 @@ public class Commandgc extends EssentialsCommand @Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - charge(sender); sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024))); sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024))); sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024))); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java index 517ef0c9a..bf5cff75d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java @@ -15,7 +15,6 @@ public class Commandgetpos extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); Location coords = user.getLocation(); user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)"); user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)"); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 68bfe8a30..065b76d03 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -36,8 +36,7 @@ public class Commandgive extends EssentialsCommand : (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt") && !ess.getUser(sender).canSpawnItem(stack.getTypeId())))) { - sender.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname); - return; + throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname); } if (args.length > 2 && Integer.parseInt(args[2]) > 0) { @@ -46,13 +45,11 @@ public class Commandgive extends EssentialsCommand if (stack.getType() == Material.AIR) { - sender.sendMessage(ChatColor.RED + "You can't give air."); - return; + throw new Exception(ChatColor.RED + "You can't give air."); } User giveTo = getPlayer(server, args, 0); String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); - charge(sender); sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + "."); giveTo.getInventory().addItem(stack); giveTo.updateInventory(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java index 6bb9f1390..d4c35e113 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java @@ -28,7 +28,6 @@ public class Commandgod extends EssentialsCommand @Override protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); if (args.length > 0 && user.isAuthorized("essentials.god.others")) { godOtherPlayers(server, user, args[0]); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java index effe64604..d60fc09fe 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java @@ -25,7 +25,6 @@ public class Commandheal extends EssentialsCommand { user.healCooldown(); } - charge(user); healOtherPlayers(server, user, args[0]); return; } @@ -34,7 +33,6 @@ public class Commandheal extends EssentialsCommand { user.healCooldown(); } - charge(user); user.setHealth(20); user.sendMessage(Util.i18n("heal")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java index 261cad062..158b0d40b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java @@ -22,7 +22,6 @@ public class Commandhelpop extends EssentialsCommand throw new NotEnoughArgumentsException(); } - charge(user); final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)); logger.log(Level.INFO, message); for (Player p : server.getOnlinePlayers()) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 2649a9cb0..f556ea360 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.Trade; import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.List; public class Commandhome extends EssentialsCommand @@ -18,24 +19,44 @@ public class Commandhome extends EssentialsCommand { Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); - if(args.length > 0 && user.isAuthorized("essentials.home.others")) + User u = user; + String homeName = ""; + String[] nameParts; + if (args.length > 0) { - User u; - try + nameParts = args[0].split(":"); + if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others")) { - u = getPlayer(server, args, 0); + homeName = nameParts[0]; } - catch(NoSuchFieldException ex) + else { - u = ess.getOfflineUser(args[0]); + u = getPlayer(server, nameParts[0].split(" "), 0, true); + if (nameParts.length > 1) + { + homeName = nameParts[1]; + } + } + } + try + { + user.getTeleport().home(u, homeName.toLowerCase(), charge); + } + catch (NotEnoughArgumentsException e) + { + List homes = u.getHomes(); + if (homes.isEmpty()) + { + throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); + } + else if ((homes.size() == 1) && u == user) + { + user.getTeleport().home(u, homes.get(0), charge); + } + else + { + user.sendMessage(Util.format("homes", Util.joinList(homes))); } - if (u == null) - { - throw new Exception(Util.i18n("playerNotFound")); - } - user.getTeleport().home(u, charge); - return; } - user.getTeleport().home(charge); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java index 4db469b58..97dd71d35 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java @@ -68,9 +68,8 @@ public class Commandinfo extends EssentialsCommand } else { - sender.sendMessage(Util.i18n("infoFileDoesNotExist")); file.createNewFile(); - return; + throw new Exception(Util.i18n("infoFileDoesNotExist")); } if (bookmarks.isEmpty()) @@ -88,7 +87,6 @@ public class Commandinfo extends EssentialsCommand int start = (page - 1) * 9; int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); - charge(sender); sender.sendMessage(Util.format("infoPages", page, pages )); for (int i = start; i < lines.size() && i < start + 9; i++) { @@ -140,7 +138,6 @@ public class Commandinfo extends EssentialsCommand } int pages = end / 9 + (end % 9 > 0 ? 1 : 0); - charge(sender); sender.sendMessage(Util.format("infoPages", page, pages )); for (int i = start; i < end && i < start + 9; i++) { @@ -182,7 +179,6 @@ public class Commandinfo extends EssentialsCommand int page = chapterpage + 1; int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0); - charge(sender); sender.sendMessage(Util.format("infoChapterPages", pageStr, page , pages)); for (int i = start; i < chapterend && i < start + 9; i++) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index e5877fe40..8b6dc8182 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -31,11 +31,9 @@ public class Commandinvsee extends EssentialsCommand { invUser.getInventory().setContents(user.getSavedInventory()); user.setSavedInventory(null); - user.sendMessage(Util.i18n("invRestored")); - return; + throw new Exception(Util.i18n("invRestored")); } - charge(user); if (user.getSavedInventory() == null) { user.setSavedInventory(user.getInventory().getContents()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 79e8344f1..352ce18eb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -31,8 +31,7 @@ public class Commanditem extends EssentialsCommand : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))) { - user.sendMessage(Util.format("cantSpawnItem", itemname)); - return; + throw new Exception(Util.format("cantSpawnItem", itemname)); } if (args.length > 1 && Integer.parseInt(args[1]) > 0) @@ -42,12 +41,10 @@ public class Commanditem extends EssentialsCommand if (stack.getType() == Material.AIR) { - user.sendMessage(Util.format("cantSpawnItem", "Air")); - return; + throw new Exception(Util.format("cantSpawnItem", "Air")); } String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); - charge(user); user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName)); user.getInventory().addItem(stack); user.updateInventory(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java index b91a1c985..36eb633fc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand @Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - StringBuilder jailList = new StringBuilder(); - for (String j : ess.getJail().getJails()) - { - jailList.append(j); - jailList.append(' '); - } - sender.sendMessage("§7" + jailList); + sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index e9b3720fe..fd0d4a8e0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -26,10 +26,8 @@ public class Commandkick extends EssentialsCommand User player = getPlayer(server, args, 0); if (player.isAuthorized("essentials.kick.exempt")) { - sender.sendMessage(Util.i18n("kickExempt")); - return; + throw new Exception(Util.i18n("kickExempt")); } - charge(sender); final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault"); player.kickPlayer(kickReason); String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java index c52dc8d14..8d36f50d5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java @@ -16,8 +16,6 @@ public class Commandkickall extends EssentialsCommand @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - charge(sender); - for (Player p : server.getOnlinePlayers()) { if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName())) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java index c849463b7..03afeadc4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java @@ -21,7 +21,6 @@ public class Commandkill extends EssentialsCommand throw new NotEnoughArgumentsException(); } - charge(sender); for (Player p : server.matchPlayer(args[0])) { p.setHealth(0); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java index 849ec2398..75cc83887 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java @@ -9,6 +9,7 @@ import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.GregorianCalendar; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -124,7 +125,7 @@ public class Commandkit extends EssentialsCommand for (String d : items) { String[] parts = d.split("[^0-9]+", 3); - int id = Integer.parseInt(parts[0]); + int id = Material.getMaterial(Integer.parseInt(parts[0])).getId(); int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1; short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0; HashMap overfilled = user.getInventory().addItem(new ItemStack(id, amount, data)); @@ -140,7 +141,6 @@ public class Commandkit extends EssentialsCommand } try { - charge(user); charge.charge(user); } catch (Exception ex) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java index c9135d61e..dc4387833 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java @@ -26,20 +26,14 @@ public class Commandlightning extends EssentialsCommand if (args.length < 1 & user != null) { user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation()); - charge(user); return; } if (server.matchPlayer(args[0]).isEmpty()) { - sender.sendMessage(Util.i18n("playerNotFound")); - return; + throw new Exception(Util.i18n("playerNotFound")); } - if (user != null) - { - charge(user); - } for (Player p : server.matchPlayer(args[0])) { sender.sendMessage(Util.format("lightningUse", p.getDisplayName())); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index ef7d6e9f8..98066d7e7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -44,7 +44,6 @@ public class Commandlist extends EssentialsCommand playerHidden++; } } - charge(sender); //TODO: move these to messages file StringBuilder online = new StringBuilder(); online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index b54b88a12..a98fabbd2 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -23,22 +23,19 @@ public class Commandmail extends EssentialsCommand List mail = user.getMails(); if (mail.isEmpty()) { - user.sendMessage(Util.i18n("noMail")); - return; + throw new Exception(Util.i18n("noMail")); } for (String s : mail) { user.sendMessage(s); } - user.sendMessage(Util.i18n("mailClear")); - return; + throw new Exception(Util.i18n("mailClear")); } if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) { if (!user.isAuthorized("essentials.mail.send")) { - user.sendMessage(Util.i18n("noMailSendPerm")); - return; + throw new Exception(Util.i18n("noMailSendPerm")); } Player player = server.getPlayer(args[1]); @@ -53,10 +50,8 @@ public class Commandmail extends EssentialsCommand } if (u == null) { - user.sendMessage(Util.format("playerNeverOnServer", args[1])); - return; + throw new Exception(Util.format("playerNeverOnServer", args[1])); } - charge(user); if (!u.isIgnoredPlayer(user.getName())) { u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2)); @@ -67,8 +62,7 @@ public class Commandmail extends EssentialsCommand if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) { user.setMails(null); - user.sendMessage(Util.i18n("mailCleared")); - return; + throw new Exception(Util.i18n("mailCleared")); } throw new NotEnoughArgumentsException(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java index 098558f11..7441b723b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -17,8 +17,7 @@ public class Commandme extends EssentialsCommand { if (user.isMuted()) { - user.sendMessage(Util.i18n("voiceSilenced")); - return; + throw new Exception(Util.i18n("voiceSilenced")); } if (args.length < 1) @@ -31,7 +30,6 @@ public class Commandme extends EssentialsCommand message.append(args[i]); message.append(' '); } - charge(user); ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java index 4712c331b..c695338f6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java @@ -15,7 +15,6 @@ public class Commandmotd extends EssentialsCommand @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - charge(sender); for (String m : ess.getMotd(sender, Util.i18n("noMotd"))) { sender.sendMessage(m); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java index 42f17bed2..f14935648 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java @@ -30,8 +30,7 @@ public class Commandmsg extends EssentialsCommand User user = ess.getUser(sender); if (user.isMuted()) { - user.sendMessage(Util.i18n("voiceSilenced")); - return; + throw new Exception(Util.i18n("voiceSilenced")); } } @@ -55,8 +54,7 @@ public class Commandmsg extends EssentialsCommand if (matches.isEmpty()) { - sender.sendMessage(Util.i18n("playerNotFound")); - return; + throw new Exception(Util.i18n("playerNotFound")); } int i = 0; @@ -70,11 +68,9 @@ public class Commandmsg extends EssentialsCommand } if (i == matches.size()) { - sender.sendMessage(Util.i18n("playerNotFound")); - return; + throw new Exception(Util.i18n("playerNotFound")); } - charge(sender); for (Player p : matches) { sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index e56ddc42c..1777c5b48 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -24,8 +24,7 @@ public class Commandmute extends EssentialsCommand User p = getPlayer(server, args, 0, true); if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt")) { - sender.sendMessage(Util.i18n("muteExempt")); - return; + throw new Exception(Util.i18n("muteExempt")); } long muteTimestamp = 0; if (args.length > 1) @@ -34,7 +33,6 @@ public class Commandmute extends EssentialsCommand muteTimestamp = Util.parseDateDiff(time, true); } p.setMuteTimeout(muteTimestamp); - charge(sender); boolean muted = p.toggleMuted(); sender.sendMessage( muted diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java index 3731b24c5..253ec7646 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java @@ -21,13 +21,16 @@ public class Commandnick extends EssentialsCommand { throw new NotEnoughArgumentsException(); } + + if (!ess.getSettings().changeDisplayName()) { + throw new Exception(Util.i18n("nickDisplayName")); + } if (args.length > 1) { if (!user.isAuthorized("essentials.nick.others")) { - user.sendMessage(Util.i18n("nickOthersPermission")); - return; + throw new Exception(Util.i18n("nickOthersPermission")); } setOthersNickname(server, user, args); @@ -46,8 +49,7 @@ public class Commandnick extends EssentialsCommand if (nick.matches("[^a-zA-Z_0-9]")) { - user.sendMessage(Util.i18n("nickNamesAlpha")); - return; + throw new Exception(Util.i18n("nickNamesAlpha")); } for (Player p : server.getOnlinePlayers()) @@ -61,12 +63,10 @@ public class Commandnick extends EssentialsCommand String nk = nick.toLowerCase(); if (nk.equals(dn) || nk.equals(n)) { - user.sendMessage(Util.i18n("nickInUse")); - return; + throw new Exception(Util.i18n("nickInUse")); } } - charge(user); user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick); user.setNickname(nick); user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7.")); @@ -80,6 +80,11 @@ public class Commandnick extends EssentialsCommand throw new NotEnoughArgumentsException(); } + if (!ess.getSettings().changeDisplayName()) { + sender.sendMessage(Util.i18n("nickDisplayName")); + return; + } + setOthersNickname(server, sender, args); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandplugin.java b/Essentials/src/com/earth2me/essentials/commands/Commandplugin.java deleted file mode 100644 index 9e7939d57..000000000 --- a/Essentials/src/com/earth2me/essentials/commands/Commandplugin.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.earth2me.essentials.commands; - -import java.io.File; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginManager; - - -public class Commandplugin extends EssentialsCommand -{ - private Server server; - - public Commandplugin() - { - super("plugin"); - } - - @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception - { - this.server = server; - - PluginCommands sub = null; - try - { - sub = PluginCommands.valueOf(args[0].toUpperCase()); - } - catch (Exception ex) - { - sender.sendMessage("§cUsage: /plugin [load|reload|enable|disable|list] [PluginName]"); - return; - } - - switch (sub) - { - case LOAD: // All disable functions are broken until - // http://leaky.bukkit.org/issues/641 is fixed. - sender.sendMessage("This function is broken. Performing /reload now."); - server.reload(); - /*if (args.length < 2) return; - User.charge(sender, this); - loadPlugin(args[1], sender);*/ - return; - - case RELOAD: - sender.sendMessage("This function is broken. Performing /reload now."); - server.reload(); - /*if (args.length < 2) return; - User.charge(sender, this); - reloadPlugin(args[1], sender);*/ - return; - - case ENABLE: - sender.sendMessage("This function is broken. Performing /reload now."); - server.reload(); - /*if (args.length < 2) return; - User.charge(sender, this); - enablePlugin(args[1], sender);*/ - return; - - case DISABLE: - sender.sendMessage("This function is broken."); - /*if (args.length < 2) return; - User.charge(sender, this); - disablePlugin(args[1], sender);*/ - return; - - case LIST: - charge(sender); - listPlugins(sender); - return; - } - } - - private void listPlugins(CommandSender player) - { - StringBuilder plugins = new StringBuilder(); - for (Plugin p : server.getPluginManager().getPlugins()) - { - plugins.append(p.isEnabled() ? " §a" : " §c"); - plugins.append(p.getDescription().getName()); - } - - plugins.insert(0, "§7Plugins:§f"); - player.sendMessage(plugins.toString()); - } - - private boolean reloadPlugin(String name, CommandSender player) - { - return disablePlugin(name, player) && enablePlugin(name, player); - } - - private boolean loadPlugin(String name, CommandSender sender) - { - try - { - PluginManager pm = server.getPluginManager(); - pm.loadPlugin(new File("plugins", name + ".jar")); - sender.sendMessage("§7Plugin loaded."); - return enablePlugin(name, sender); - } - catch (Throwable ex) - { - sender.sendMessage("§cCould not load plugin. Is the file named properly?"); - return false; - } - } - - private boolean enablePlugin(String name, CommandSender sender) - { - try - { - final PluginManager pm = server.getPluginManager(); - final Plugin plugin = pm.getPlugin(name); - if (!plugin.isEnabled()) - { - new Thread(new Runnable() - { - public void run() - { - synchronized (pm) - { - pm.enablePlugin(plugin); - } - } - }).start(); - } - sender.sendMessage("§7Plugin enabled."); - return true; - } - catch (Throwable ex) - { - listPlugins(sender); - return false; - } - } - - private boolean disablePlugin(String name, CommandSender sender) - { - try - { - final PluginManager pm = server.getPluginManager(); - final Plugin plugin = pm.getPlugin(name); - if (plugin.isEnabled()) - { - new Thread(new Runnable() - { - public void run() - { - synchronized (pm) - { - pm.disablePlugin(plugin); - } - } - }).start(); - } - sender.sendMessage("§7Plugin disabled."); - return true; - } - catch (Throwable ex) - { - listPlugins(sender); - return false; - } - } - - - private enum PluginCommands - { - LOAD, RELOAD, LIST, ENABLE, DISABLE - } -} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java index c7bd34705..742535a77 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java @@ -2,6 +2,8 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.inventory.ItemStack; @@ -17,23 +19,78 @@ public class Commandpowertool extends EssentialsCommand @Override protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { - ItemStack is = user.getItemInHand(); + List powertools = user.getPowertool(is); if (is == null || is.getType() == Material.AIR) { - user.sendMessage(Util.i18n("powerToolAir")); - return; + throw new Exception(Util.i18n("powerToolAir")); } + + String itemName = is.getType().toString().toLowerCase().replaceAll("_", " "); String command = getFinalArg(args, 0); if (command != null && !command.isEmpty()) { - user.sendMessage(Util.format("powerToolAttach",is.getType().toString().toLowerCase().replaceAll("_", " "))); + if (command.equalsIgnoreCase("l:")) + { + if (powertools == null || powertools.isEmpty()) + { + throw new Exception(Util.format("powerToolListEmpty", itemName)); + } + else + { + user.sendMessage(Util.format("powerToolList", Util.joinList(powertools), itemName)); + } + return; + } + if (command.startsWith("r:")) + { + try + { + command = command.substring(2); + if (!powertools.contains(command)) + { + throw new Exception(Util.format("powerToolNoSuchCommandAssigned", command, itemName)); + } + + powertools.remove(command); + user.sendMessage(Util.format("powerToolRemove", command, itemName)); + } + catch (Exception e) + { + user.sendMessage(e.getMessage()); + return; + } + } + else + { + if (command.startsWith("a:")) + { + command = command.substring(2); + if(powertools.contains(command)) + { + throw new Exception(Util.format("powerToolAlreadySet", command, itemName)); + } + } + else if (powertools != null && !powertools.isEmpty()) + { + // Replace all commands with this one + powertools.clear(); + } + else + { + powertools = new ArrayList(); + } + + powertools.add(command); + user.sendMessage(Util.format("powerToolAttach", Util.joinList(powertools), itemName)); + } } else { - user.sendMessage(Util.format("powerToolRemove", is.getType().toString().toLowerCase().replaceAll("_", " "))); + powertools.clear(); + user.sendMessage(Util.format("powerToolRemoveAll", itemName)); } - charge(user); - user.setPowertool(is, command); + + user.setPowertool(is, powertools); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java index d89947500..daf83034a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -32,11 +32,9 @@ public class Commandr extends EssentialsCommand if (target == null) { - sender.sendMessage(Util.i18n("foreverAlone")); - return; + throw new Exception(Util.i18n("foreverAlone")); } - charge(sender); sender.sendMessage(Util.format("msgFormat", Util.i18n("me"), targetName, message)); if (target instanceof Player) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java index e16d59198..5e12c535d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java @@ -22,7 +22,6 @@ public class Commandrealname extends EssentialsCommand throw new NotEnoughArgumentsException(); } final String whois = args[0].toLowerCase(); - charge(user); for (Player p : server.getOnlinePlayers()) { final User u = ess.getUser(p); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandreloadall.java b/Essentials/src/com/earth2me/essentials/commands/Commandreloadall.java index eeee08e11..bd4f59dcc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandreloadall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandreloadall.java @@ -15,7 +15,6 @@ public class Commandreloadall extends EssentialsCommand @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - charge(sender); server.reload(); sender.sendMessage(Util.i18n("reloadAllPlugins")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index e98deeab7..029901867 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -1,21 +1,17 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package com.earth2me.essentials.commands; +import com.earth2me.essentials.ChargeException; +import com.earth2me.essentials.IUser; +import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; -/** - * - * @author Seiji - */ public class Commandrepair extends EssentialsCommand { public Commandrepair() @@ -24,7 +20,7 @@ public class Commandrepair extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -33,46 +29,32 @@ public class Commandrepair extends EssentialsCommand if (args[0].equalsIgnoreCase("hand")) { - ItemStack item = user.getItemInHand(); - try - { - repairItem(item); - } - catch (Exception e) - { - user.sendMessage(e.getMessage()); - return; - } + final ItemStack item = user.getItemInHand(); + final String itemName = item.getType().toString().toLowerCase(); + final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess); - String itemName = item.getType().toString().toLowerCase().replace('_', ' '); - charge(user); - user.sendMessage(Util.format("repair", itemName)); + charge.isAffordableFor(user); + + repairItem(item); + + charge.charge(user); + + user.sendMessage(Util.format("repair", itemName.replace('_', ' '))); } else if (args[0].equalsIgnoreCase("all")) { - StringBuilder itemList = new StringBuilder(); - itemList.append(repairItems(user.getInventory().getContents())); + final List repaired = new ArrayList(); + repairItems(user.getInventory().getContents(), user, repaired); - String armor = repairItems(user.getInventory().getArmorContents()); + repairItems(user.getInventory().getArmorContents(), user, repaired); - if (armor.length() > 0) + if (repaired.isEmpty()) { - if (itemList.length() > 0) - { - itemList.append(", "); - } - - itemList.append(armor); - } - - if (itemList.length() == 0) - { - user.sendMessage(Util.format("repairNone")); + throw new Exception(Util.format("repairNone")); } else { - charge(user); - user.sendMessage(Util.format("repair", itemList.toString())); + user.sendMessage(Util.format("repair", Util.joinList(repaired))); } } @@ -82,10 +64,9 @@ public class Commandrepair extends EssentialsCommand } } - private void repairItem(ItemStack item) throws Exception + private void repairItem(final ItemStack item) throws Exception { - Material material = Material.getMaterial(item.getTypeId()); - String error = null; + final Material material = Material.getMaterial(item.getTypeId()); if (material.isBlock() || material.getMaxDurability() < 0) { throw new Exception(Util.i18n("repairInvalidType")); @@ -99,28 +80,39 @@ public class Commandrepair extends EssentialsCommand item.setDurability((short)0); } - private String repairItems(ItemStack[] items) + private void repairItems(final ItemStack[] items, final IUser user, final List repaired) { - StringBuilder itemList = new StringBuilder(); for (ItemStack item : items) { + final String itemName = item.getType().toString().toLowerCase(); + final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess); + try + { + charge.isAffordableFor(user); + } + catch (ChargeException ex) + { + user.sendMessage(ex.getMessage()); + continue; + } + try { repairItem(item); - if (itemList.length() > 0) - { - itemList.append(", "); - } - - String itemName = item.getType().toString().toLowerCase().replace('_', ' '); - itemList.append(itemName); } catch (Exception e) { + continue; } - + try + { + charge.charge(user); + } + catch (ChargeException ex) + { + user.sendMessage(ex.getMessage()); + } + repaired.add(itemName.replace('_', ' ')); } - - return itemList.toString(); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java index 1b00bea47..39f7de68e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java @@ -15,7 +15,6 @@ public class Commandrules extends EssentialsCommand @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - charge(sender); for (String m : ess.getLines(sender, "rules", Util.i18n("noRules"))) { sender.sendMessage(m); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index f471364d5..658782b9a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -145,11 +145,9 @@ public class Commandsell extends EssentialsCommand { user.sendMessage(Util.i18n("itemNotEnough1")); user.sendMessage(Util.i18n("itemNotEnough2")); - user.sendMessage(Util.i18n("itemNotEnough3")); - return; + throw new Exception(Util.i18n("itemNotEnough3")); } - charge(user); final ItemStack ris = new ItemStack(is.getType(), amount, is.getDurability()); InventoryWorkaround.removeItem(user.getInventory(), true, ris); user.updateInventory(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index 154017d43..d9bd32c30 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -17,16 +17,35 @@ public class Commandsethome extends EssentialsCommand { if (args.length > 0) { + //Allowing both formats /sethome khobbits house | /sethome khobbits:house + final String[] nameParts = args[0].split(":"); + if (nameParts[0].length() != args[0].length()) + { + args = nameParts; + } + if (args.length < 2) { - user.setHome(args[0].equalsIgnoreCase("default")); + if (user.isAuthorized("essentials.sethome.multiple")) + { + if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes()) + || (user.getHomes().contains(args[0].toLowerCase()))) + { + user.setHome(args[0].toLowerCase()); + } + else + { + throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes())); + } + + } } else { if (user.isAuthorized("essentials.sethome.others")) { User usersHome = ess.getUser(ess.getServer().getPlayer(args[0])); - if(usersHome == null) + if (usersHome == null) { usersHome = ess.getOfflineUser(args[0]); } @@ -34,15 +53,19 @@ public class Commandsethome extends EssentialsCommand { throw new Exception(Util.i18n("playerNotFound")); } - usersHome.setHome(user.getLocation(), args[1].equalsIgnoreCase("default")); + String name = args[1].toLowerCase(); + if (!user.isAuthorized("essentials.sethome.multiple")) + { + name = "home"; + } + usersHome.setHome(name, user.getLocation()); } } } else { - user.setHome(false); + user.setHome(); } - charge(user); user.sendMessage(Util.i18n("homeSet")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java index 76fe766c3..d9b0eac4d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java @@ -15,12 +15,10 @@ public class Commandsetjail extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - if (args.length < 1) { throw new NotEnoughArgumentsException(); } - charge(user); ess.getJail().setJail(user.getLocation(), args[0]); user.sendMessage(Util.format("jailSet",args[0])); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java index 4e799d6c0..ccdacab57 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java @@ -21,7 +21,6 @@ public class Commandsetwarp extends EssentialsCommand throw new NotEnoughArgumentsException(); } - charge(user); Location loc = user.getLocation(); ess.getWarps().setWarp(args[0], loc); user.sendMessage(Util.format("warpSet", args[0])); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java index e6b741c43..086b1549d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java @@ -22,7 +22,6 @@ public class Commandsetworth extends EssentialsCommand } ItemStack stack = ess.getItemDb().get(args[0]); - charge(user); ess.getWorth().setPrice(stack, Double.parseDouble(args[1])); user.sendMessage(Util.i18n("worthSet")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java index 33efffeef..8e95e8237 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java @@ -15,9 +15,6 @@ public class Commandsocialspy extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - - charge(user); user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? Util.i18n("enabled") : Util.i18n("disabled"))); - } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java index 15f5910af..d3b14970a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java @@ -6,8 +6,7 @@ import com.earth2me.essentials.Util; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.block.CraftCreatureSpawner; -import org.bukkit.entity.CreatureType; +import org.bukkit.block.CreatureSpawner; public class Commandspawner extends EssentialsCommand @@ -32,7 +31,6 @@ public class Commandspawner extends EssentialsCommand throw new Exception(Util.i18n("mobSpawnTarget")); } - charge(user); try { String name = args[0]; @@ -45,7 +43,7 @@ public class Commandspawner extends EssentialsCommand user.sendMessage(Util.i18n("invalidMob")); return; } - new CraftCreatureSpawner(target).setCreatureType(mob.getType()); + ((CreatureSpawner)target.getState()).setCreatureType(mob.getType()); user.sendMessage(Util.format("setSpawner", mob.name)); } catch (Throwable ex) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index 9514bc767..87a22c59f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -8,16 +8,13 @@ import com.earth2me.essentials.Mob.MobException; import com.earth2me.essentials.TargetBlock; import com.earth2me.essentials.Util; import java.util.Random; -import net.minecraft.server.EntityWolf; -import net.minecraft.server.PathEntity; import org.bukkit.DyeColor; -import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.entity.CraftCreeper; -import org.bukkit.craftbukkit.entity.CraftSheep; -import org.bukkit.craftbukkit.entity.CraftSlime; -import org.bukkit.craftbukkit.entity.CraftWolf; +import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Slime; +import org.bukkit.entity.Wolf; public class Commandspawnmob extends EssentialsCommand @@ -62,8 +59,7 @@ public class Commandspawnmob extends EssentialsCommand if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase()) || (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase()))) { - user.sendMessage(Util.i18n("unableToSpawnMob")); - return; + throw new Exception(Util.i18n("unableToSpawnMob")); } Entity spawnedMob = null; @@ -74,15 +70,18 @@ public class Commandspawnmob extends EssentialsCommand mob = Mob.fromName(mobType); if (mob == null) { - user.sendMessage(Util.i18n("invalidMob")); - return; + throw new Exception(Util.i18n("invalidMob")); } - charge(user); int[] ignore = { 8, 9 }; - Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock(); + if(block == null) { + user.sendMessage(Util.i18n("unableToSpawnMob")); + return; + } + Location loc = block.getLocation(); Location sloc = Util.getSafeDestination(loc); try { @@ -185,7 +184,7 @@ public class Commandspawnmob extends EssentialsCommand { try { - ((CraftSlime)spawned).setSize(Integer.parseInt(data)); + ((Slime)spawned).setSize(Integer.parseInt(data)); } catch (Exception e) { @@ -199,11 +198,11 @@ public class Commandspawnmob extends EssentialsCommand if (data.equalsIgnoreCase("random")) { Random rand = new Random(); - ((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); + ((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); } else { - ((CraftSheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase())); + ((Sheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase())); } } catch (Exception e) @@ -213,21 +212,18 @@ public class Commandspawnmob extends EssentialsCommand } if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed")) { - EntityWolf wolf = ((CraftWolf)spawned).getHandle(); + Wolf wolf = ((Wolf)spawned); wolf.setTamed(true); - wolf.setPathEntity((PathEntity)null); + wolf.setOwner(user); wolf.setSitting(true); - wolf.health = 20; - wolf.setOwnerName(user.getName()); - wolf.world.a(wolf, (byte)7); } if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("angry")) { - ((CraftWolf)spawned).setAngry(true); + ((Wolf)spawned).setAngry(true); } if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered")) { - ((CraftCreeper)spawned).setPowered(true); + ((Creeper)spawned).setPowered(true); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java index 57e5e3fd5..90f40a4bf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java @@ -15,7 +15,6 @@ public class Commandsuicide extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); user.setHealth(0); user.sendMessage(Util.i18n("suicideMessage")); ess.broadcastMessage(user.getName(), diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java index b1ffd3f7f..34f5c3fed 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java @@ -16,13 +16,11 @@ public class Commandthunder extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - if (args.length < 1) { throw new NotEnoughArgumentsException(); } - charge(user); World world = user.getWorld(); boolean setThunder = args[0].equalsIgnoreCase("true"); if (args.length > 1) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 75abda4bb..6f60f7f43 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -45,7 +45,6 @@ public class Commandtogglejail extends EssentialsCommand return; } } - charge(sender); if (!(p.getBase() instanceof OfflinePlayer)) { ess.getJail().sendToJail(p, args[1]); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java index 8c0c687d0..ee5bfbe45 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java @@ -20,7 +20,6 @@ public class Commandtop extends EssentialsCommand int topX = user.getLocation().getBlockX(); int topZ = user.getLocation().getBlockZ(); int topY = user.getWorld().getHighestBlockYAt(topX, topZ); - charge(user); user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess)); user.sendMessage(Util.i18n("teleportTop")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java index c147c5d25..c3cc8f7e5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -41,7 +41,6 @@ public class Commandtp extends EssentialsCommand throw new Exception("You need access to /tpohere to teleport other players."); } user.sendMessage(Util.i18n("teleporting")); - charge(user); User target = getPlayer(server, args, 0); User toPlayer = getPlayer(server, args, 1); target.getTeleport().now(toPlayer, false); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java index f3b7ae505..32cbe3bd9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java @@ -25,7 +25,6 @@ public class Commandtpa extends EssentialsCommand { throw new Exception(Util.format("teleportDisabled", p.getDisplayName())); } - charge(user); if (!p.isIgnoredPlayer(user.getName())) { p.requestTeleport(user, false); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java index 25c5d2892..97897852f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java @@ -21,7 +21,6 @@ public class Commandtpaall extends EssentialsCommand { if (sender instanceof Player) { - charge(sender); teleportAAllPlayers(server, sender, ess.getUser(sender)); return; } @@ -29,7 +28,6 @@ public class Commandtpaall extends EssentialsCommand } User p = getPlayer(server, args, 0); - charge(sender); teleportAAllPlayers(server, sender, p); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java index 2003bbf73..935721345 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java @@ -25,7 +25,6 @@ public class Commandtpahere extends EssentialsCommand { throw new Exception(Util.format("teleportDisabled", p.getDisplayName())); } - charge(user); p.requestTeleport(user, true); p.sendMessage(Util.format("teleportHereRequest", user.getDisplayName())); p.sendMessage(Util.i18n("typeTpaccept")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java index cc58944d7..1cb6321ea 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java @@ -21,7 +21,6 @@ public class Commandtpall extends EssentialsCommand { if (sender instanceof Player) { - charge(sender); teleportAllPlayers(server, sender, ess.getUser(sender)); return; } @@ -29,7 +28,6 @@ public class Commandtpall extends EssentialsCommand } User p = getPlayer(server, args, 0); - charge(sender); teleportAllPlayers(server, sender, p); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java index e31d7ae3c..5d7764ae6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java @@ -21,7 +21,6 @@ public class Commandtpdeny extends EssentialsCommand throw new Exception(Util.i18n("noPendingRequest")); } - charge(user); user.sendMessage(Util.i18n("requestDenied")); p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName())); user.requestTeleport(null, false); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java index 18d818ea1..5a4e082e0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java @@ -32,7 +32,6 @@ public class Commandtpo extends EssentialsCommand // Verify permission if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden")) { - charge(user); user.getTeleport().now(p, false); user.sendMessage(Util.i18n("teleporting")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java index 186476a50..7af39854f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java @@ -33,7 +33,6 @@ public class Commandtpohere extends EssentialsCommand // Verify permission if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden")) { - charge(user); p.getTeleport().now(user, false); user.sendMessage(Util.i18n("teleporting")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java index 38236d475..f880c5d34 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java @@ -15,7 +15,6 @@ public class Commandtptoggle extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); user.sendMessage(user.toggleTeleportEnabled() ? Util.i18n("teleportationEnabled") : Util.i18n("teleportationDisabled")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java index 81be2a329..8013453ab 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java @@ -51,7 +51,6 @@ public class Commandtree extends EssentialsCommand final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); if (success) { - charge(user); user.sendMessage(Util.i18n("treeSpawned")); } else diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index 122891e02..cebbcaf8c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -93,8 +93,7 @@ public class Commandunlimited extends EssentialsCommand && !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET) && user.isAuthorized("essentials.unlimited.item-bucket")))) { - user.sendMessage(Util.format("unlimitedItemPermission", itemname)); - return false; + throw new Exception(Util.format("unlimitedItemPermission", itemname)); } String message = "disableUnlimited"; @@ -103,7 +102,6 @@ public class Commandunlimited extends EssentialsCommand { message = "enableUnlimited"; enableUnlimited = true; - charge(user); if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack)) { target.getInventory().addItem(stack); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 17d55faee..b93355f5a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -55,16 +55,7 @@ public class Commandwarp extends EssentialsCommand user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); } final int warpPage = (page - 1) * WARPS_PER_PAGE; - final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE); i++) - { - if (i > 0) - { - sb.append(", "); - } - sb.append(warpNameList.get(i + warpPage)); - } - user.sendMessage(sb.toString()); + user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE)))); return; } if (args.length > 0) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java index eec1d9575..45c62d787 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java @@ -23,7 +23,6 @@ public class Commandweather extends EssentialsCommand boolean isStorm = args[0].equalsIgnoreCase("storm"); World world = user.getWorld(); - charge(user); if (args.length > 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index ef815dd87..1769202f5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -35,7 +35,6 @@ public class Commandwhois extends EssentialsCommand showhidden = true; } String whois = args[0].toLowerCase(); - charge(sender); int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length(); for (Player p : server.getOnlinePlayers()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index f2d6ed954..b59070320 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -43,7 +43,6 @@ public class Commandworth extends EssentialsCommand throw new Exception(Util.i18n("itemCannotBeSold")); } - charge(user); user.sendMessage(is.getDurability() != 0 ? Util.format("worthMeta", is.getType().toString().toLowerCase().replace("_", ""), diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java index c99cdfdc9..58da18c21 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java @@ -79,7 +79,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand @Override public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception { + final Trade charge = new Trade(this.getName(), ess); + charge.isAffordableFor(user); run(server, user, commandLabel, args); + charge.charge(user); } protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception @@ -111,13 +114,4 @@ public abstract class EssentialsCommand implements IEssentialsCommand } return bldr.toString(); } - - protected void charge(final CommandSender sender) throws ChargeException - { - if (sender instanceof Player) - { - final Trade charge = new Trade(this.getName(), ess); - charge.charge(ess.getUser((Player)sender)); - } - } } diff --git a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java new file mode 100644 index 000000000..82f793ee0 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java @@ -0,0 +1,50 @@ +package com.earth2me.essentials.perm; + +import de.bananaco.permissions.Permissions; +import de.bananaco.permissions.interfaces.PermissionSet; +import de.bananaco.permissions.worlds.WorldPermissionsManager; +import java.util.List; +import org.bukkit.entity.Player; + + +public class BPermissionsHandler extends SuperpermsHandler +{ + private final transient WorldPermissionsManager wpm; + + public BPermissionsHandler() + { + wpm = Permissions.getWorldPermissionsManager(); + } + + @Override + public String getGroup(final Player base) + { + final PermissionSet pset = wpm.getPermissionSet(base.getWorld()); + if (pset == null) + { + return "default"; + } + final List groups = pset.getGroups(base); + if (groups == null || groups.isEmpty()) + { + return "default"; + } + return groups.get(0); + } + + @Override + public boolean inGroup(final Player base, final String group) + { + final PermissionSet pset = wpm.getPermissionSet(base.getWorld()); + if (pset == null) + { + return false; + } + final List groups = pset.getGroups(base); + if (groups == null || groups.isEmpty()) + { + return false; + } + return groups.contains(group); + } +} diff --git a/Essentials/src/com/earth2me/essentials/ConfigPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java similarity index 77% rename from Essentials/src/com/earth2me/essentials/ConfigPermissionsHandler.java rename to Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java index 200aa34f8..82d285b1f 100644 --- a/Essentials/src/com/earth2me/essentials/ConfigPermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java @@ -1,5 +1,6 @@ -package com.earth2me.essentials; +package com.earth2me.essentials.perm; +import com.earth2me.essentials.IEssentials; import org.bukkit.entity.Player; @@ -12,33 +13,39 @@ public class ConfigPermissionsHandler implements IPermissionsHandler this.ess = ess; } + @Override public String getGroup(final Player base) { return "default"; } + @Override public boolean canBuild(final Player base, final String group) { return true; } + @Override public boolean inGroup(final Player base, final String group) { return false; } + @Override public boolean hasPermission(final Player base, final String node) { final String[] cmds = node.split("\\.", 2); - return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]) - && ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]); + return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]) + && ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]); } + @Override public String getPrefix(final Player base) { return ""; } + @Override public String getSuffix(final Player base) { return ""; diff --git a/Essentials/src/com/earth2me/essentials/IPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/IPermissionsHandler.java similarity index 89% rename from Essentials/src/com/earth2me/essentials/IPermissionsHandler.java rename to Essentials/src/com/earth2me/essentials/perm/IPermissionsHandler.java index a7bcc80b7..c7fddb6c8 100644 --- a/Essentials/src/com/earth2me/essentials/IPermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/IPermissionsHandler.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials; +package com.earth2me.essentials.perm; import org.bukkit.entity.Player; diff --git a/Essentials/src/com/earth2me/essentials/Permissions2Handler.java b/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java similarity index 89% rename from Essentials/src/com/earth2me/essentials/Permissions2Handler.java rename to Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java index 71d7da58b..0d7b45cb7 100644 --- a/Essentials/src/com/earth2me/essentials/Permissions2Handler.java +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials; +package com.earth2me.essentials.perm; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; @@ -10,38 +10,44 @@ public class Permissions2Handler implements IPermissionsHandler { private final transient PermissionHandler permissionHandler; - Permissions2Handler(final Plugin permissionsPlugin) + public Permissions2Handler(final Plugin permissionsPlugin) { permissionHandler = ((Permissions)permissionsPlugin).getHandler(); } + @Override public String getGroup(final Player base) { final String group = permissionHandler.getGroup(base.getWorld().getName(), base.getName()); return group == null ? "default" : group; } + @Override public boolean canBuild(final Player base, final String group) { return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base)); } + @Override public boolean inGroup(final Player base, final String group) { return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group); } + @Override public boolean hasPermission(final Player base, final String node) { return permissionHandler.permission(base, node); } + @Override public String getPrefix(final Player base) { final String prefix = permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base)); return prefix == null ? "" : prefix; } + @Override public String getSuffix(final Player base) { final String suffix = permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base)); diff --git a/Essentials/src/com/earth2me/essentials/Permissions3Handler.java b/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java similarity index 88% rename from Essentials/src/com/earth2me/essentials/Permissions3Handler.java rename to Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java index 99c95da0a..c0ac249a8 100644 --- a/Essentials/src/com/earth2me/essentials/Permissions3Handler.java +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials; +package com.earth2me.essentials.perm; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; @@ -10,36 +10,42 @@ public class Permissions3Handler implements IPermissionsHandler { private final transient PermissionHandler permissionHandler; - Permissions3Handler(final Plugin permissionsPlugin) + public Permissions3Handler(final Plugin permissionsPlugin) { permissionHandler = ((Permissions)permissionsPlugin).getHandler(); } + @Override public String getGroup(final Player base) { return permissionHandler.getPrimaryGroup(base.getWorld().getName(), base.getName()); } + @Override public boolean canBuild(final Player base, final String group) { return permissionHandler.canUserBuild(base.getWorld().getName(), base.getName()); } + @Override public boolean inGroup(final Player base, final String group) { return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group); } + @Override public boolean hasPermission(final Player base, final String node) { return permissionHandler.has(base, node); } + @Override public String getPrefix(final Player base) { return permissionHandler.getUserPrefix(base.getWorld().getName(), base.getName()); } + @Override public String getSuffix(final Player base) { return permissionHandler.getUserSuffix(base.getWorld().getName(), base.getName()); diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java new file mode 100644 index 000000000..9fd87905e --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java @@ -0,0 +1,58 @@ +package com.earth2me.essentials.perm; + +import com.platymuus.bukkit.permissions.Group; +import com.platymuus.bukkit.permissions.PermissionInfo; +import com.platymuus.bukkit.permissions.PermissionsPlugin; +import java.util.List; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + + +public class PermissionsBukkitHandler extends SuperpermsHandler +{ + private final transient PermissionsPlugin plugin; + + public PermissionsBukkitHandler(final Plugin plugin) + { + this.plugin = (PermissionsPlugin)plugin; + } + + @Override + public String getGroup(final Player base) + { + final PermissionInfo info = plugin.getPlayerInfo(base.getName()); + if (info == null) + { + return "default"; + } + final List groups = info.getGroups(); + if (groups == null || groups.isEmpty()) + { + return "default"; + } + return groups.get(0).getName(); + } + + @Override + public boolean inGroup(final Player base, final String group) + { + final PermissionInfo info = plugin.getPlayerInfo(base.getName()); + if (info == null) + { + return false; + } + final List groups = info.getGroups(); + if (groups == null || groups.isEmpty()) + { + return false; + } + for (Group group1 : groups) + { + if (group1.getName().equalsIgnoreCase(group)) + { + return true; + } + } + return false; + } +} diff --git a/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java similarity index 70% rename from Essentials/src/com/earth2me/essentials/PermissionsExHandler.java rename to Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java index f9151c77e..28b056c0a 100644 --- a/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials; +package com.earth2me.essentials.perm; import org.bukkit.entity.Player; import ru.tehkode.permissions.PermissionManager; @@ -6,7 +6,7 @@ import ru.tehkode.permissions.PermissionUser; import ru.tehkode.permissions.bukkit.PermissionsEx; -class PermissionsExHandler implements IPermissionsHandler +public class PermissionsExHandler implements IPermissionsHandler { private final transient PermissionManager manager; @@ -15,7 +15,8 @@ class PermissionsExHandler implements IPermissionsHandler manager = PermissionsEx.getPermissionManager(); } - public String getGroup(Player base) + @Override + public String getGroup(final Player base) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -25,7 +26,8 @@ class PermissionsExHandler implements IPermissionsHandler return user.getGroupsNames()[0]; } - public boolean canBuild(Player base, String group) + @Override + public boolean canBuild(final Player base, final String group) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -36,7 +38,8 @@ class PermissionsExHandler implements IPermissionsHandler return user.getOptionBoolean("build", base.getWorld().getName(), true); } - public boolean inGroup(Player base, String group) + @Override + public boolean inGroup(final Player base, final String group) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -47,12 +50,14 @@ class PermissionsExHandler implements IPermissionsHandler return user.inGroup(group); } - public boolean hasPermission(Player base, String node) + @Override + public boolean hasPermission(final Player base, final String node) { return manager.has(base.getName(), node, base.getWorld().getName()); } - public String getPrefix(Player base) + @Override + public String getPrefix(final Player base) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -62,7 +67,8 @@ class PermissionsExHandler implements IPermissionsHandler return user.getPrefix(); } - public String getSuffix(Player base) + @Override + public String getSuffix(final Player base) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) diff --git a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java new file mode 100644 index 000000000..60b1c5a3d --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java @@ -0,0 +1,57 @@ +package com.earth2me.essentials.perm; + +import org.bukkit.entity.Player; + + +public class SuperpermsHandler implements IPermissionsHandler +{ + @Override + public String getGroup(final Player base) + { + return "default"; + } + + @Override + public boolean canBuild(final Player base, final String group) + { + return hasPermission(base, "essentials.build"); + } + + @Override + public boolean inGroup(final Player base, final String group) + { + return false; + } + + @Override + public boolean hasPermission(final Player base, final String node) + { + if (base.hasPermission("-" + node)) + { + return false; + } + final String[] parts = node.split("\\."); + final StringBuilder sb = new StringBuilder(); + for (String part : parts) + { + if (base.hasPermission(sb.toString() + "*")) + { + return true; + } + sb.append(part).append("."); + } + return base.hasPermission(node); + } + + @Override + public String getPrefix(final Player base) + { + return ""; + } + + @Override + public String getSuffix(final Player base) + { + return ""; + } +} diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index fc5dd8553..f4109b3bb 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -11,7 +11,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; -import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.entity.Player; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.inventory.ItemStack; @@ -21,6 +20,7 @@ public class EssentialsSign { private static final Set EMPTY_SET = new HashSet(); protected transient final String signName; + //TODO: Add these settings to messages private static final String FORMAT_SUCCESS = "§1[%s]"; private static final String FORMAT_TEMPLATE = "[%s]"; private static final String FORMAT_FAIL = "§4[%s]"; @@ -191,8 +191,13 @@ public class EssentialsSign { return true; } + + public boolean onBlockIgnite(final Block block, final IEssentials ess) + { + return true; + } - public boolean onBlockPush(Block block, IEssentials ess) + public boolean onBlockPush(final Block block, final IEssentials ess) { return true; } @@ -450,7 +455,7 @@ public class EssentialsSign public BlockSign(final Block block) { this.block = block; - this.sign = new CraftSign(block); + this.sign = (Sign)block.getState(); } public final String getLine(final int index) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 6f07b67b2..7320f27a4 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -7,7 +7,6 @@ import java.util.logging.Logger; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; -import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; @@ -48,7 +47,7 @@ public class SignBlockListener extends BlockListener final int mat = block.getTypeId(); if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) { - final Sign csign = new CraftSign(block); + final Sign csign = (Sign)block.getState(); for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); @@ -184,9 +183,24 @@ public class SignBlockListener extends BlockListener return; } - if (protectSignsAndBlocks(event.getBlock(), event.getPlayer())) + final Block block = event.getBlock(); + if (((block.getType() == Material.WALL_SIGN + || block.getType() == Material.SIGN_POST) + && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) + || EssentialsSign.checkIfBlockBreaksSigns(block)) { event.setCancelled(true); + return; + } + for (Signs signs : Signs.values()) + { + final EssentialsSign sign = signs.getSign(); + if (sign.getBlocks().contains(block.getType()) + && !sign.onBlockIgnite(block, ess)) + { + event.setCancelled(true); + return; + } } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index a97c234fa..5d7900508 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -4,7 +4,6 @@ import com.earth2me.essentials.IEssentials; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; -import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerListener; @@ -39,7 +38,7 @@ public class SignPlayerListener extends PlayerListener { return; } - final Sign csign = new CraftSign(block); + final Sign csign = (Sign)block.getState(); for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index c595d9b03..8ecf34e01 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -15,7 +15,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; -import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.inventory.ItemStack; @@ -204,7 +203,7 @@ public class SignProtection extends EssentialsSign { if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN) { - final Sign sign = new CraftSign(b); + final Sign sign = (Sign)b.getState(); if (sign.getLine(0).equalsIgnoreCase("§1[Protection]")) { return true; @@ -218,7 +217,7 @@ public class SignProtection extends EssentialsSign { if (a.getType() == Material.SIGN_POST || a.getType() == Material.WALL_SIGN) { - final Sign sign = new CraftSign(a); + final Sign sign = (Sign)a.getState(); if (sign.getLine(0).equalsIgnoreCase("§1[Protection]")) { return true; @@ -313,6 +312,14 @@ public class SignProtection extends EssentialsSign return state == SignProtectionState.NOSIGN; } + + @Override + public boolean onBlockIgnite(final Block block, final IEssentials ess) + { + final SignProtectionState state = isBlockProtected(block, null, null, false); + + return state == SignProtectionState.NOSIGN; + } @Override public boolean onBlockPush(final Block block, final IEssentials ess) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 5e3f581b8..6884960c1 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -91,7 +91,7 @@ nether: # Mob limit on spawnmob spawnmob-limit: 10 -#Shall we notify users when using /lightning +# Shall we notify users when using /lightning warn-on-smite: true # The message of the day, displayed on connect and by typing /motd. @@ -207,7 +207,7 @@ backup: # Interval in minutes interval: 60 # Add a command that backups your data, e.g. - # command: 'rdiff-backup World1 backups/World1' + #command: 'rdiff-backup World1 backups/World1' # Set this true to enable permission per warp. per-warp-permission: false @@ -223,13 +223,35 @@ debug: false # Don't forget to remove the # infront of the line #locale: de_DE -#turn off god mode when people exit +# Turn off god mode when people exit remove-god-on-disconnect: false # Use the permission system of bukkit # This only works if no other permission plugins are installed use-bukkit-permissions: false +# Check for updates +# We do not recommend to disable this unless you are using CraftbukkitUpToDate or Bukget. +# If you don't like the notices in game, remove the permission +# essentials.admin.notices.update from your user. +update-check: true + +# Auto-AFK +# After this timeout in seconds, the user will be set as afk. +# Set to -1 for no timeout. +auto-afk: 300 + +# Auto-AFK Kick +# After this timeout in seconds, the user will be kicked from the server. +# Set to -1 for no timeout. +auto-afk-kick: -1 + +# Set this to true, if you want to freeze the player, if he is afk. +# Other players or monsters can't push him out of afk mode then. +# This will also enable temporary god mode for the afk player. +# The player has to use the command /afk to leave the afk mode. +freeze-afk-players: false + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | # @@ -243,9 +265,13 @@ respawn-at-home: false # If you enable this and remove default user access to the /sethome command, you can make beds the only way for players to set their home location. bed-sethome: false -#if no home is set send you to spawn when /home is used +# If no home is set send you to spawn when /home is used spawn-if-no-home: false +# If users have essentials.sethome.multiple how many homes can they have +# People with essentials.sethome.multiple.unlimited are not limited by this number +multiple-homes: 5 + ############################################################ # +------------------------------------------------------+ # @@ -282,13 +308,13 @@ economy-log-enabled: false # +------------------------------------------------------+ # ############################################################ -#Show other plugins commands in help +# Show other plugins commands in help non-ess-in-help: true -#Hide plugins which dont give a permission -#You can override a true value here for a single plugin by adding a permission to a user/group. -#The indervidual permission is: essentials.help., anyone with essentials.* or '*' will see all help this setting reguardless. -#You can use negitive permissions to remove access to just a single plugins help if the following is enabled. +# Hide plugins which dont give a permission +# You can override a true value here for a single plugin by adding a permission to a user/group. +# The indervidual permission is: essentials.help., anyone with essentials.* or '*' will see all help this setting reguardless. +# You can use negitive permissions to remove access to just a single plugins help if the following is enabled. hide-permissionless-help: true ############################################################ @@ -420,10 +446,10 @@ protect: # This only has an effect if "rails" or "signs" is also enabled. block-below: true - # Prevent placing blocks above protected rails, this is to stop a potential griefing + # Prevent placing blocks above protected rails, this is to stop a potential griefing prevent-block-on-rails: false - #Store blocks / signs in memory before writing + # Store blocks / signs in memory before writing memstore: false # Disable various default physics and behaviors @@ -463,11 +489,11 @@ protect: # Set true to disable useing for those people use: true - #Should we tell people they are not allowed to build + # Should we tell people they are not allowed to build warn-on-build-disallow: false - #disable weather options + # Disable weather options weather: storm: false thunder: false diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 3a9dd2d23..5190c6968 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -8,6 +8,7 @@ alertBroke = broke: alertFormat = \u00a73[{0}] \u00a7f {1} \u00a76 {2} at: {3} alertPlaced = placed: alertUsed = used: +autoAfkKickReason=You have been kicked for idling more than {0} minutes. backAfterDeath = \u00a77Use the /back command to return to your death point. backUsageMsg = \u00a77Returning to previous location. backupFinished = Backup finished @@ -48,6 +49,7 @@ day = day days = days defaultBanReason = The Ban Hammer has spoken! deleteFileError = Could not delete file: {0} +deleteHome = \u00a77Home {0} has been removed. deleteJail = \u00a77Jail {0} has been removed. deleteWarp = \u00a77Warp {0} has been removed. deniedAccessCommand = {0} was denied access to command. @@ -63,7 +65,6 @@ disabled = disabled dontMoveMessage = \u00a77Teleportation will commence in {0}. Don''t move. downloadingGeoIp = Downloading GeoIP database ... this might take a while (country: 0.6 MB, city: 20MB) duplicatedUserdata = Duplicated userdata: {0} and {1} -emptyWorldName = Set Home: World name is null or empty. enableUnlimited = \u00a77Giving unlimited amount of {0} to {1}. enabled = enabled errorCallingCommand = Error calling command /{0} @@ -98,6 +99,7 @@ helpPages = Page \u00a7c{0}\u00a7f of \u00a7c{1}\u00a7f: holeInFloor = Hole in floor homeSet = \u00a77Home set. homeSetToBed = \u00a77Your home is now set to this bed. +homes = Homes: {0} hour = hour hours = hours ignorePlayer = You ignore player {0} from now on. @@ -146,7 +148,7 @@ kits = \u00a77Kits: {0} lightningSmited = \u00a77You have just been smited lightningUse = \u00a77Smiting {0} loadWarpError = Failed to load warp {0} -loadinfo = Loaded {0} build {1} by {2} +loadinfo = Loaded {0} build {1} by: {2} localFormat = Local: <{0}> {1} mailClear = \u00a7cTo mark your mail as read, type /mail clear mailCleared = \u00a77Mail Cleared! @@ -154,6 +156,7 @@ mailSent = \u00a77Mail sent! markMailAsRead = \u00a7cTo mark your mail as read, type /mail clear markedAsAway = \u00a77You are now marked as away. markedAsNotAway = \u00a77You are no longer marked as away. +maxHomes=You cannot set more than {0} homes. mayNotJail = \u00a7cYou may not jail that person me = me minute = minute @@ -177,6 +180,7 @@ mutedUserSpeaks = {0} tried to speak, but is muted. needTpohere = You need access to /tpohere to teleport other players. negativeBalanceError = User is not allowed to have a negative balance. nickChanged = Nickname changed. +nickDisplayName=\u00a77You have to enable change-displayname in Essentials config. nickInUse = \u00a7cThat name is already in use. nickNamesAlpha = \u00a7cNicknames must be alphanumeric. nickNoMore = \u00a77You no longer have a nickname. @@ -209,6 +213,14 @@ numberRequired = A number goes there, silly. onlyDayNight = /time only supports day/night. onlyPlayers = Only in-game players can use {0}. onlySunStorm = /weather only supports sun/storm. +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} parseError = Error parsing {0} on line {1} pendingTeleportCancelled = \u00a7cPending teleportation request cancelled. permissionsError = Missing Permissions/GroupManager; chat prefixes/suffixes will be disabled. @@ -225,17 +237,14 @@ playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}. powerToolAir = Command can''t be attached to air. -powerToolAttach = Command assigned to {0} -powerToolRemove = Command removed from {0} +powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. +powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. +powerToolListEmpty = {0} has no commands assigned. +powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. +powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. +powerToolRemoveAll = All commands removed from {0}. protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0} -pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. -pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. -pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. -pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. -pTimePlayers = These players have their own time: -pTimeReset = Player time has been reset for: \u00a7e{0} -pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} -pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. repair = You have successfully repaired your: \u00a7e{0}. @@ -325,10 +334,10 @@ voiceSilenced = \u00a77Your voice has been silenced warpDeleteError = Problem deleting the warp file. warpListPermission = \u00a7cYou do not have Permission to list that warps. warpNotExist = That warp does not exist. -warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} set. warpUsePermission = \u00a7cYou do not have Permission to use that warp. warpingTo = \u00a77Warping to {0}. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. weatherStorm = \u00a77You set the weather to storm in your world weatherStormFor = \u00a77You set the weather to storm in your world for {0} seconds weatherSun = \u00a77You set the weather to sun in your world diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 870f24c5a..b27154190 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -8,14 +8,15 @@ alertBroke = \u00f8delagde: alertFormat = \u00a73[{0}] \u00a7f {1} \u00a76 {2} ved: {3} alertPlaced = placerede: alertUsed = brugte: +autoAfkKickReason=You have been kicked for idling more than {0} minutes. backAfterDeath = \u00a77Brug /back kommandoen for at retunere til dit d\u00f8ds punkt. backUsageMsg = \u00a77Returnere til tidligere placering. backupFinished = Backup sluttede backupStarted = Backup startede balance = \u00a77Balance: {0} balanceTop = \u00a77 Top {0} saldi -banIpAddress = \u00a77Bannede IP addresse banExempt = \u00a7cDu kan ikke forbyde den p\u00e5g\u00e6ldende spiller. +banIpAddress = \u00a77Bannede IP addresse bannedIpsFileError = Fejl i l\u00e6sning af banned-ips.txt bannedIpsFileNotFound = banned-ips.txt ikke fundet bannedPlayersFileError = Fejl i l\u00e6sning af banned-players.txt @@ -48,6 +49,7 @@ day = dag days = dage defaultBanReason = Ban hammeren har talt! deleteFileError = Kunne ikke slette fil: {0} +deleteHome = \u00a77Home {0} has been removed. deleteJail = \u00a77F\u00e6ngsel {0} er fjernet. deleteWarp = \u00a77Warp {0} er fjernet. deniedAccessCommand = {0} var n\u00e6gtet adgang til kommando. @@ -63,7 +65,6 @@ disabled = deaktiveret dontMoveMessage = \u00a77Teleportering vil begynde om {0}. Bev\u00e6g dig ikke. downloadingGeoIp = Downloader GeoIP database ... det her kan tage et stykke tid (land: 0.6 MB, by: 20MB) duplicatedUserdata = Duplikerede userdata: {0} og {1} -emptyWorldName = S\u00e6t Hjem: World navn er null eller tom. enableUnlimited = \u00a77Giver ubegr\u00e6nset m\u00e6ngde af {0} til {1}. enabled = aktiveret errorCallingCommand = Fejl ved opkald af kommando /{0} @@ -98,6 +99,7 @@ helpPages = Side \u00a7c{0}\u00a7f af \u00a7c{1}\u00a7f: holeInFloor = Hul i gulv homeSet = \u00a77Hjem sat. homeSetToBed = \u00a77Dit hjem er nu sat til denne seng. +homes = Homes: {0} hour = time hours = timer ignorePlayer = Du ignorere spiller {0} fra nu af. @@ -154,6 +156,7 @@ mailSent = \u00a77Post sendt! markMailAsRead = \u00a7cTo marker din post som l\u00e6st, skriv /post ryd markedAsAway = \u00a77Du er nu markeret som v\u00e6k. markedAsNotAway = \u00a77Du er ikke l\u00e6ngere markeret som v\u00e6k. +maxHomes=You cannot set more than {0} homes. mayNotJail = \u00a7cDu m\u00e5 ikke f\u00e6ngsle den person me = mig minute = minut @@ -177,6 +180,7 @@ mutedUserSpeaks = {0} pr\u00f8vede at snakke, men er muted. needTpohere = Du skal have adgang til /tpohere for at teleporter andre spillere. negativeBalanceError = Brugeren er ikke tilladt at have en negativ saldo. nickChanged = Kaldenavn \u00e6ndret. +nickDisplayName=\u00a77You have to enable change-displayname in Essentials config. nickInUse = \u00a7cDet navn er allerede i brug. nickNamesAlpha = \u00a7cKaldenavne skal v\u00e6re alfanumeriske. nickNoMore = \u00a7Du har ikke l\u00e6ngere et kaldenavn. @@ -209,6 +213,14 @@ numberRequired = Der skal v\u00e6re et nummer, fjolle. onlyDayNight = /time underst\u00f8tter kun day/night. onlyPlayers = Kun in-game spillere kan bruge {0}. onlySunStorm = /weather only supports sun/storm. +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} parseError = Fejl ved parsing {0} p\u00e5 linje {1} pendingTeleportCancelled = \u00a7cVentende teleportations anmodning aflyst. permissionsError = Mangler Permissions/GroupManager; chat pr\u00e6fikser/suffikser vil v\u00e6re sl\u00e5et fra. @@ -225,17 +237,14 @@ playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Mulige verdener er numrene 0 igennem {0}. powerToolAir = Kommando kan ikke blive tildelt luft. -powerToolAttach = Kommando tildelt til {0} -powerToolRemove = Kommando fjernet fra {0} +powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. +powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. +powerToolListEmpty = {0} has no commands assigned. +powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. +powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. +powerToolRemoveAll = All commands removed from {0}. protectionOwner = \u00a76[EssentialsProtect] Beskyttelses ejer: {0} -pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. -pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. -pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. -pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. -pTimePlayers = These players have their own time: -pTimeReset = Player time has been reset for: \u00a7e{0} -pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} -pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Sp\u00f8rgsm\u00e5l]\u00a7f {0} reloadAllPlugins = \u00a77Genindl\u00e6ste alle tilf\u00f8jelser. repair = You have successfully repaired your: \u00a7e{0}. @@ -325,10 +334,10 @@ voiceSilenced = \u00a77Din stemme er blevet d\u00e6mpet warpDeleteError = Problem ved sletning af warp filen. warpListPermission = \u00a7cDu har ikke tilladelse til at liste de warps. warpNotExist = Den warp eksisterer ikke. -warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} sat. warpUsePermission = \u00a7cDu har ikke tilladelse til at benytte den warp. warpingTo = \u00a77Warper til {0}. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. weatherStorm = \u00a77Du har sat vejret til storm i din verden weatherStormFor = \u00a77Du har sat vejret til storm i din verden i {0} sekunder weatherSun = \u00a77Du har sat vejret til sol diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 31c9c3eb2..a38ba3d6e 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -8,14 +8,15 @@ alertBroke = zerst\u00f6rt: alertFormat = \u00a73[{0}] \u00a7f {1} \u00a76 {2} bei: {3} alertPlaced = platziert: alertUsed = benutzt: +autoAfkKickReason=You have been kicked for idling more than {0} minutes. backAfterDeath = \u00a77Benutze den Befehl /back um zu deinem Todespunkt zur\u00fcck zu kehren. backUsageMsg = \u00a77Kehre zur letzten Position zur\u00fcck. backupFinished = Backup beendet backupStarted = Backup gestartet balance = \u00a77Geldb\u00f6rse: {0} balanceTop = \u00a77 Top {0} Guthaben -banIpAddress = \u00a77IP-Adresse gesperrt. banExempt = \u00a7cDu kannst diesen Spieler nicht sperren. +banIpAddress = \u00a77IP-Adresse gesperrt. bannedIpsFileError = Fehler beim Lesen von banned-ips.txt bannedIpsFileNotFound = banned-ips.txt nicht gefunden bannedPlayersFileError = Fehler beim Lesen von banned-players.txt @@ -48,6 +49,7 @@ day = Tag days = Tage defaultBanReason = Der Bann-Hammer hat gesprochen! deleteFileError = Konnte Datei nicht l\u00f6schen: {0} +deleteHome = \u00a77Home {0} has been removed. deleteJail = \u00a77Gef\u00e4ngnis {0} wurde gel\u00f6scht. deleteWarp = \u00a77Warp-Punkt {0} wurde gel\u00f6scht. deniedAccessCommand = {0} hat keinen Zugriff auf diesen Befehl. @@ -63,7 +65,6 @@ disabled = deaktiviert dontMoveMessage = \u00a77Teleportvorgang startet in {0}. Beweg dich nicht. downloadingGeoIp = Lade GeoIP-Datenbank ... dies kann etwas dauern (country: 0.6 MB, city: 20MB) duplicatedUserdata = Doppelte Datei in userdata: {0} und {1} -emptyWorldName = /sethome: Weltname ist null oder leer. enableUnlimited = \u00a77Gebe {1} unendliche Mengen von {0}. enabled = aktiviert errorCallingCommand = Fehler beim Aufrufen des Befehls /{0} @@ -98,6 +99,7 @@ helpPages = Seite \u00a7c{0}\u00a7f von \u00a7c{1}\u00a7f: holeInFloor = Loch im Boden homeSet = \u00a77Zuhause gesetzt. homeSetToBed = \u00a77Dein Zuhause ist nun an diesem Bett. +homes = Homes: {0} hour = Stunde hours = Stunden ignorePlayer = Du ignorierst ab jetzt Spieler {0}. @@ -154,6 +156,7 @@ mailSent = \u00a77Nachricht gesendet! markMailAsRead = \u00a7cUm deine Nachrichten zu l\u00f6schen, schreibe /mail clear markedAsAway = \u00a77Du wirst als abwesend angezeigt. markedAsNotAway = \u00a77Du wirst nicht mehr als abwesend angezeigt. +maxHomes=You cannot set more than {0} homes. mayNotJail = \u00a7cDu kannst diese Person nicht einsperren. me = mir minute = Minute @@ -177,6 +180,7 @@ mutedUserSpeaks = {0} versuchte zu sprechen, aber ist stumm geschalt. needTpohere = Du brauchst Zugriff auf /tpohere um andere Spieler teleportieren zu k\u00f6nnen. negativeBalanceError = Spieler darf keine Schulden machen. nickChanged = Nickname ge\u00e4ndert. +nickDisplayName=\u00a77You have to enable change-displayname in Essentials config. nickInUse = \u00a7cDieser Name wird bereits verwendet. nickNamesAlpha = \u00a7cNicknamen d\u00fcrfen nur alphanumerische Zeichen enthalten. nickNoMore = \u00a7Du hast keinen Nicknamen mehr. @@ -209,6 +213,14 @@ numberRequired = Ein Zahl wird ben\u00f6tigt. onlyDayNight = /time unterst\u00fctzt nur day und night. onlyPlayers = Nur Spieler k\u00f6nnen {0} benutzen. onlySunStorm = /weather unterst\u00fctzt nur sun und storm. +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} parseError = Fehler beim Parsen von {0} in Zeile {1} pendingTeleportCancelled = \u00a7cLaufende Teleportierung abgebrochen. permissionsError = Permissions/GroupManager fehlt; Chat-Prefixe/-Suffixe sind ausgeschaltet. @@ -225,17 +237,14 @@ playerUnmuted = \u00a77Du bist nicht mehr stumm. pong = Pong! possibleWorlds = \u00a77M\u00f6gliche Welten sind nummeriet von 0 bis {0}. powerToolAir = Befehl kann nicht mit Luft verbunden werden. -powerToolAttach = Befehl verbunden mit {0} -powerToolRemove = Befehl entfernt von {0} +powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. +powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. +powerToolListEmpty = {0} has no commands assigned. +powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. +powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. +powerToolRemoveAll = All commands removed from {0}. protectionOwner = \u00a76[EssentialsProtect] Besitzer dieses Blocks: {0} -pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. -pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. -pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. -pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. -pTimePlayers = These players have their own time: -pTimeReset = Player time has been reset for: \u00a7e{0} -pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} -pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Frage]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins neu geladen. repair = You have successfully repaired your: \u00a7e{0}. @@ -325,10 +334,10 @@ voiceSilenced = \u00a77Du bist stumm warpDeleteError = Fehler beim L\u00f6schen der Warp-Datei. warpListPermission = \u00a7cDu hast keine Berechtigung, die Warp-Punkte anzuzeigen. warpNotExist = Warp-Punkt existiert nicht. -warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp-Punkt {0} wurde erstellt. warpUsePermission = \u00a7cDu hast keinen Zugriff f\u00fcr diesen Warp-Punkt. warpingTo = \u00a77Teleportiere zu Warp-Punkt {0}. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. weatherStorm = \u00a77In deiner Welt st\u00fcrmt es nun. weatherStormFor = \u00a77In deiner Welt st\u00fcrmt es nun f\u00fcr {0} Sekunden. weatherSun = \u00a77In deiner Welt scheint nun die Sonne. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 057d06869..6f1809c05 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -8,14 +8,15 @@ alertBroke = broke: alertFormat = \u00a73[{0}] \u00a7f {1} \u00a76 {2} at: {3} alertPlaced = placed: alertUsed = used: +autoAfkKickReason=You have been kicked for idling more than {0} minutes. backAfterDeath = \u00a77Use the /back command to return to your death point. backUsageMsg = \u00a77Returning to previous location. backupFinished = Backup finished backupStarted = Backup started balance = \u00a77Balance: {0} balanceTop = \u00a77 Top {0} balances -banIpAddress = \u00a77Banned IP address banExempt = \u00a7cYou can not ban that player. +banIpAddress = \u00a77Banned IP address bannedIpsFileError = Error reading banned-ips.txt bannedIpsFileNotFound = banned-ips.txt not found bannedPlayersFileError = Error reading banned-players.txt @@ -48,6 +49,7 @@ day = day days = days defaultBanReason = The Ban Hammer has spoken! deleteFileError = Could not delete file: {0} +deleteHome = \u00a77Home {0} has been removed. deleteJail = \u00a77Jail {0} has been removed. deleteWarp = \u00a77Warp {0} has been removed. deniedAccessCommand = {0} was denied access to command. @@ -63,7 +65,6 @@ disabled = disabled dontMoveMessage = \u00a77Teleportation will commence in {0}. Don''t move. downloadingGeoIp = Downloading GeoIP database ... this might take a while (country: 0.6 MB, city: 20MB) duplicatedUserdata = Duplicated userdata: {0} and {1} -emptyWorldName = Set Home: World name is null or empty. enableUnlimited = \u00a77Giving unlimited amount of {0} to {1}. enabled = enabled errorCallingCommand = Error calling command /{0} @@ -98,6 +99,7 @@ helpPages = Page \u00a7c{0}\u00a7f of \u00a7c{1}\u00a7f: holeInFloor = Hole in floor homeSet = \u00a77Home set. homeSetToBed = \u00a77Your home is now set to this bed. +homes = Homes: {0} hour = hour hours = hours ignorePlayer = You ignore player {0} from now on. @@ -146,7 +148,7 @@ kits = \u00a77Kits: {0} lightningSmited = \u00a77You have just been smited lightningUse = \u00a77Smiting {0} loadWarpError = Failed to load warp {0} -loadinfo = Loaded {0} build {1} by {2} +loadinfo = Loaded {0} build {1} by: {2} localFormat = Local: <{0}> {1} mailClear = \u00a7cTo mark your mail as read, type /mail clear mailCleared = \u00a77Mail Cleared! @@ -154,6 +156,7 @@ mailSent = \u00a77Mail sent! markMailAsRead = \u00a7cTo mark your mail as read, type /mail clear markedAsAway = \u00a77You are now marked as away. markedAsNotAway = \u00a77You are no longer marked as away. +maxHomes=You cannot set more than {0} homes. mayNotJail = \u00a7cYou may not jail that person me = me minute = minute @@ -177,6 +180,7 @@ mutedUserSpeaks = {0} tried to speak, but is muted. needTpohere = You need access to /tpohere to teleport other players. negativeBalanceError = User is not allowed to have a negative balance. nickChanged = Nickname changed. +nickDisplayName=\u00a77You have to enable change-displayname in Essentials config. nickInUse = \u00a7cThat name is already in use. nickNamesAlpha = \u00a7cNicknames must be alphanumeric. nickNoMore = \u00a77You no longer have a nickname. @@ -209,6 +213,14 @@ numberRequired = A number goes there, silly. onlyDayNight = /time only supports day/night. onlyPlayers = Only in-game players can use {0}. onlySunStorm = /weather only supports sun/storm. +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} parseError = Error parsing {0} on line {1} pendingTeleportCancelled = \u00a7cPending teleportation request cancelled. permissionsError = Missing Permissions/GroupManager; chat prefixes/suffixes will be disabled. @@ -225,17 +237,14 @@ playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}. powerToolAir = Command can''t be attached to air. -powerToolAttach = Command assigned to {0} -powerToolRemove = Command removed from {0} +powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. +powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. +powerToolListEmpty = {0} has no commands assigned. +powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. +powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. +powerToolRemoveAll = All commands removed from {0}. protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0} -pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. -pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. -pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. -pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. -pTimePlayers = These players have their own time: -pTimeReset = Player time has been reset for: \u00a7e{0} -pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} -pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. repair = You have successfully repaired your: \u00a7e{0}. @@ -325,10 +334,10 @@ voiceSilenced = \u00a77Your voice has been silenced warpDeleteError = Problem deleting the warp file. warpListPermission = \u00a7cYou do not have Permission to list that warps. warpNotExist = That warp does not exist. -warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} set. warpUsePermission = \u00a7cYou do not have Permission to use that warp. warpingTo = \u00a77Warping to {0}. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. weatherStorm = \u00a77You set the weather to storm in your world weatherStormFor = \u00a77You set the weather to storm in your world for {0} seconds weatherSun = \u00a77You set the weather to sun in your world diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index da166c8d9..c564d0d76 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -8,14 +8,15 @@ alertBroke = a cass\u00e9: alertFormat = \u00a73[{0}] \u00a7f {1} \u00a76 {2} \u00e0:{3} alertPlaced = a plac\u00e9: alertUsed = a utilis\u00e9: +autoAfkKickReason=You have been kicked for idling more than {0} minutes. backAfterDeath = \u00a77Utilisez la commande /back pour retourner \u00e0 l''endroit ou vous \u00eates mort. backUsageMsg = \u00a77Retour a votre emplacement pr\u00e9c\u00e8dent. backupFinished = Backup termin\u00e9 backupStarted = D\u00e9but du backup balance = \u00a77Solde: {0} balanceTop = \u00a77 Top {0} soldes -banIpAddress = \u00a77Adresse IP banni banExempt = \u00a77Vous ne pouvez pas interdire ce joueur. +banIpAddress = \u00a77Adresse IP banni bannedIpsFileError = Erreur de lecture de banned-ips.txt bannedIpsFileNotFound = Fichier banned-ips.txt introuvable bannedPlayersFileError = Erreur lors de la lecture de banned-players.txt @@ -48,6 +49,7 @@ day = jour days = jours defaultBanReason = Le marteau du ban a frapp\u00e9! deleteFileError = Le fichier n''a pas pu \u00eatre supprim\u00e9: {0} +deleteHome = \u00a77Home {0} has been removed. deleteJail = \u00a77La prison {0} a \u00e9t\u00e9 supprim\u00e9e. deleteWarp = \u00a77Warp {0} supprim\u00e9. deniedAccessCommand = L''acc\u00e8s \u00e0 la commande a \u00e9t\u00e9 refus\u00e9 pour {0}. @@ -63,7 +65,6 @@ disabled = d\u00e9sactiv\u00e9 dontMoveMessage = \u00a77La t\u00e9l\u00e9portation commence dans {0}. Ne bougez pas. downloadingGeoIp = T\u00e9l\u00e9chargement de la base de donn\u00e9es GeoIP ... cela peut prendre un moment (campagne : 0.6 Mo, ville : 20Mo) duplicatedUserdata = Donn\u00e9e utilisateur dupliqu\u00e9e: {0} et {1} -emptyWorldName = Set Home: Le nom du monte est nul ou vide. enableUnlimited = \u00a77Donner un nombre illimit\u00e9 de {0} \u00e0 {1}. enabled = activ\u00e9 errorCallingCommand = Erreur en appelant la commande /{0} @@ -98,6 +99,7 @@ helpPages = Page \u00a7c{0}\u00a7f sur \u00a7c{1}\u00a7f. holeInFloor = Trou dans le Sol. homeSet = \u00a77Home d\u00e9fini. homeSetToBed = \u00a77Votre home est d\u00e9sormais d\u00e9fini sur ce lit. +homes = Homes: {0} hour = heure hours = heures ignorePlayer = Vous ignorez d\u00e9sormais {0}. @@ -154,6 +156,7 @@ mailSent = \u00a77Courrier envoy\u00e9 ! markMailAsRead = \u00a7cPour marquer votre courrier en tant que lu, entrez /mail clear markedAsAway = \u00a77Vous \u00eates d\u00e9sormais AFK. markedAsNotAway = \u00a77Vous n''\u00eates d\u00e9sormais plus AFK. +maxHomes=You cannot set more than {0} homes. mayNotJail = \u00a7cVous ne pouvez pas emprisonner cette personne. me = moi minute = minute @@ -177,6 +180,7 @@ mutedUserSpeaks = {0} a essay\u00e9 de parler mais est muet. needTpohere = Vous avez besoin de l''acc\u00e8s \u00e0 /tpohere pour t\u00e9l\u00e9porter d''autres joueurs. negativeBalanceError = L''utilisateur n''est pas autoris\u00e9 \u00e0 avoir un solde n\u00e9gatif. nickChanged = Pseudo modifi\u00e9. +nickDisplayName=\u00a77You have to enable change-displayname in Essentials config. nickInUse = \u00a7cCe nom est d\u00e9j\u00e0 utilis\u00e9. nickNamesAlpha = \u00a7cLes pseudos doivent \u00eatre alphanum\u00e9riques. nickNoMore = \u00a7Vous n''avez plus de surnom. @@ -209,6 +213,14 @@ numberRequired = On a besoin d''un nombre ici, idiot. onlyDayNight = /time ne supporte que (jour) day/night (nuit). onlyPlayers = Seulement les joueurs en jeu peuvent utiliser {0}. onlySunStorm = /weather only supports sun/storm. +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} parseError = Erreur de conversion {0} \u00e0 la ligne {1} pendingTeleportCancelled = \u00a7cRequete de t\u00e9l\u00e9portation annul\u00e9e. permissionsError = Permissions/GroupManager manquant, les pr\u00e9fixes et suffixes ne seront pas affich\u00e9s. @@ -225,17 +237,14 @@ playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Les mondes possibles sont les nombres 0 par {0}. powerToolAir = La commande ne peut pas \u00eatre attach\u00e9e \u00e0 l''air. -powerToolAttach = Commande assign\u00e9e \u00e0 {0} -powerToolRemove = Commande enlev\u00e9e \u00e0 {0} +powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. +powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. +powerToolListEmpty = {0} has no commands assigned. +powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. +powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. +powerToolRemoveAll = All commands removed from {0}. protectionOwner = \u00a76[EssentialsProtect] Propri\u00e9taire de la protection : {0} -pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. -pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. -pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. -pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. -pTimePlayers = These players have their own time: -pTimeReset = Player time has been reset for: \u00a7e{0} -pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} -pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Tous les plugins ont \u00e9t\u00e9 recharg\u00e9s. repair = You have successfully repaired your: \u00a7e{0}. @@ -325,10 +334,10 @@ voiceSilenced = \u00a77Votre voix a \u00e9t\u00e9 r\u00e9duite au silence warpDeleteError = Probl\u00e8me concernant la suppression du fichier warp. warpListPermission = \u00a7cVous n''avez pas la permission d''afficher la liste des warps. warpNotExist = Ce warp n''existe pas. -warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Le warp {0} a \u00e9t\u00e9 cr\u00e9\u00e9. warpUsePermission = \u00a7cVous n''avez pas la permission d''utiliser ce warp. warpingTo = \u00a77T\u00e9l\u00e9portation au warp {0}. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. weatherStorm = \u00a77Vous avez d\u00e9fini l''orage dans votre monde weatherStormFor = \u00a77Vous avez d\u00e9fini l''orage dans votre monde pour {0} secondes. weatherSun = \u00a77Vous avez mis le beau temps dans votre monde diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 173698b1f..cd214b5d4 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -8,14 +8,15 @@ alertBroke = gebroken: alertFormat = \u00a73[{0}] \u00a7f {1} \u00a76 {2} bij: {3} alertPlaced = geplaatst: alertUsed = gebruikt: +autoAfkKickReason=You have been kicked for idling more than {0} minutes. backAfterDeath = \u00a77Gebruik het /back command om terug te keren naar je sterfplaats. backUsageMsg = \u00a77Naar de vorige locatie aan het gaan. backupFinished = Backup voltooid backupStarted = Backup gestart balance = \u00a77Saldo: {0} balanceTop = \u00a77 Top {0} saldi -banIpAddress = \u00a77Verbannen IP-adres banExempt = \u00a77Je kunt deze speler niet verbannen. +banIpAddress = \u00a77Verbannen IP-adres bannedIpsFileError = Fout bij het lezen van banned-ips.txt bannedIpsFileNotFound = banned-ips.txt werd niet gevonden bannedPlayersFileError = Fout bij het lezen van banned-players.txt @@ -48,6 +49,7 @@ day = dag days = dagen defaultBanReason = De Ban Hamer heeft gesproken! deleteFileError = Het bestand kon niet verwijderd worden: {0} +deleteHome = \u00a77Home {0} has been removed. deleteJail = \u00a77Gevangenis {0} is verwijderd. deleteWarp = \u00a77Warp {0} is verwijderd. deniedAccessCommand = {0} was de toegang verboden tot het commando. @@ -63,7 +65,6 @@ disabled = uitgeschakeld dontMoveMessage = \u00a77Beginnen met teleporteren in {0}. Niet bewegen. downloadingGeoIp = Bezig met downloaden van GeoIP database ... Dit kan een tijdje duren (country: 0.6 MB, city: 20MB) duplicatedUserdata = Dubbele userdata: {0} en {1}. -emptyWorldName = Set Home: Naam van wereld is leeg. enableUnlimited = \u00a77Oneindig aantal {0} aan {1} gegeven. enabled = ingeschakeld errorCallingCommand = Fout bij het aanroepen van de opdracht /{0} @@ -98,6 +99,7 @@ helpPages = Pagina \u00a7c{0}\u00a7f van de \u00a7c{1}\u00a7f: holeInFloor = Gat in de vloer homeSet = \u00a77Home ingesteld. homeSetToBed = \u00a77Je home is is nu verplaatst naar dit bed. +homes = Homes: {0} hour = uur hours = uren ignorePlayer = Je negeert {0} vanaf nu. @@ -154,6 +156,7 @@ mailSent = \u00a77Bericht verzonden! markMailAsRead = \u00a7cType /mail clear, om je berichten als gelezen te markeren markedAsAway = \u00a77Je staat nu als afwezig gemeld. markedAsNotAway = \u00a77Je staat niet meer als afwezig gemeld. +maxHomes=You cannot set more than {0} homes. mayNotJail = \u00a7cJe mag die speler niet in de gevangenis zetten. me = me minute = minuut @@ -177,6 +180,7 @@ mutedUserSpeaks = {0} probeerde te praten, maar is gemute. needTpohere = Je moet toegang krijgen tot /tpohere om naar andere spelers te teleporteren. negativeBalanceError = Speler is niet toegestaan om een negatief saldo te hebben. nickChanged = Nickname veranderd. +nickDisplayName=\u00a77You have to enable change-displayname in Essentials config. nickInUse = \u00a7cDie naam is al in gebruik. nickNamesAlpha = \u00a7cNicknames moeten alfanumeriek zijn. nickNoMore = \u00a7Je hebt geen nickname meer. @@ -209,6 +213,14 @@ numberRequired = Er moet daar een nummer, grapjas. onlyDayNight = /time ondersteund alleen day/night. onlyPlayers = Alleen in-game spelers kunnen {0} gebruiken. onlySunStorm = /weather only supports sun/storm. +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} parseError = Fout bij ontleding {0} op regel {1} pendingTeleportCancelled = \u00a7cAangevraagde teleportatie afgelast. permissionsError = Permissions/GroupManager ontbreekt; chat prefixes/suffixes worden uitgeschakeld. @@ -225,17 +237,14 @@ playerUnmuted = \u00a77Speler mag weer praten pong = Pong! possibleWorlds = \u00a77Mogelijk zijn de werelden de nummer 0 tot en met {0}. powerToolAir = Command kan niet worden bevestigd aan lucht. -powerToolAttach = Command toegewezen aan {0} -powerToolRemove = Command verwijderd van {0} +powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. +powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. +powerToolListEmpty = {0} has no commands assigned. +powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. +powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. +powerToolRemoveAll = All commands removed from {0}. protectionOwner = \u00a76[EssentialsProtect] Beschermingeigenaar: {0} -pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. -pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. -pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. -pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. -pTimePlayers = These players have their own time: -pTimeReset = Player time has been reset for: \u00a7e{0} -pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} -pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Vraag]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins zijn herladen. repair = You have successfully repaired your: \u00a7e{0}. @@ -325,10 +334,10 @@ voiceSilenced = \u00a77Je kan niet meer praten warpDeleteError = Fout bij het verwijderen van het warp bestand. warpListPermission = \u00a7cJe hebt geen toegang om die warp te maken. warpNotExist = Die warp bestaat niet. -warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} ingesteld. warpUsePermission = \u00a7cOnbevoegd om die warp te gebruiken. warpingTo = \u00a77Aan het warpen naar {0}. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. weatherStorm = \u00a77Je hebt het weer naar storm gezet in de wereld weatherStormFor = \u00a77Je hebt het weer in de wereld naar storm gezet voor {0} seconde weatherSun = \u00a77Je hebt het weer naar zon gezet in de wereld diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 2406c337d..63e9b9aa8 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -59,6 +59,10 @@ commands: description: Describes your current bearing. usage: / aliases: [ecompass] + delhome: + description: Removes a home + usage: / [player] + aliases: [edelhome,remhome,rmhome,eremhome,ermhome] deljail: description: Removes a jail usage: / [jailname] @@ -204,7 +208,7 @@ commands: aliases: [pong,eping,epong] powertool: description: Assigns a command to the item in hand, {player} will be replaced by the name of the player that you click. - usage: / [command] + usage: / [l:|a:|r:][command] aliases: [pt,epowertool,ept] ptime: description: Adjust player's client time. Add @ prefix to fix. @@ -223,9 +227,9 @@ commands: usage: / aliases: [rel,ereloadall,ereload,erel] repair: - description: Repairs the item in hand, or all items in the current inventory. + description: Repairs the durability of all or one item. usage: / [hand|all] - aliases: [fix] + aliases: [fix,erepair,efix] rules: description: Views the server rules. usage: / diff --git a/Essentials/test/com/earth2me/essentials/UserTest.java b/Essentials/test/com/earth2me/essentials/UserTest.java index 4724c96d6..35244ac90 100644 --- a/Essentials/test/com/earth2me/essentials/UserTest.java +++ b/Essentials/test/com/earth2me/essentials/UserTest.java @@ -46,7 +46,7 @@ public class UserTest extends TestCase OfflinePlayer base1alt = server.createPlayer(base1.getName(), ess); assertEquals(base1alt, ess.getUser(base1alt).getBase()); } - + public void testHome() { User user = ess.getUser(base1); @@ -54,13 +54,21 @@ public class UserTest extends TestCase user.setHome(); OfflinePlayer base2 = server.createPlayer(base1.getName(), ess); User user2 = ess.getUser(base2); - Location home = user2.getHome(loc); - assertEquals(loc.getWorld().getName(), home.getWorld().getName()); - assertEquals(loc.getX(), home.getX()); - assertEquals(loc.getY(), home.getY()); - assertEquals(loc.getZ(), home.getZ()); - assertEquals(loc.getYaw(), home.getYaw()); - assertEquals(loc.getPitch(), home.getPitch()); + try + { + Location home = user2.getHome(loc); + assertEquals(loc.getWorld().getName(), home.getWorld().getName()); + assertEquals(loc.getX(), home.getX()); + assertEquals(loc.getY(), home.getY()); + assertEquals(loc.getZ(), home.getZ()); + assertEquals(loc.getYaw(), home.getYaw()); + assertEquals(loc.getPitch(), home.getPitch()); + } + catch (Exception ex) + { + fail("Exception"); + } + } public void testMoney() diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index 7b5f93d0e..8717825b3 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -61,7 +61,7 @@ public class EssentialsProtectBlockListener extends BlockListener } final Block below = blockPlaced.getRelative(BlockFace.DOWN); - if (below.getType() == Material.RAILS + if ((below.getType() == Material.RAILS || below.getType() == Material.POWERED_RAIL || below.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.prevent_block_on_rail) && prot.getStorage().isProtected(below, user.getName())) { @@ -70,7 +70,7 @@ public class EssentialsProtectBlockListener extends BlockListener } final List protect = new ArrayList(); - if (blockPlaced.getType() == Material.RAILS + if ((blockPlaced.getType() == Material.RAILS || blockPlaced.getType() == Material.POWERED_RAIL || blockPlaced.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails) && user.isAuthorized("essentials.protect")) { @@ -103,8 +103,8 @@ public class EssentialsProtectBlockListener extends BlockListener { return; } - Block block = event.getBlock(); - if (block.getType() == Material.RAILS + final Block block = event.getBlock(); + if ((block.getType() == Material.RAILS || block.getType() == Material.POWERED_RAIL || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) { event.setCancelled(true); @@ -155,7 +155,7 @@ public class EssentialsProtectBlockListener extends BlockListener return; } final Block toBlock = event.getToBlock(); - if (toBlock.getType() == Material.RAILS + if ((toBlock.getType() == Material.RAILS || toBlock.getType() == Material.POWERED_RAIL || toBlock.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) { event.setCancelled(true); @@ -196,7 +196,7 @@ public class EssentialsProtectBlockListener extends BlockListener return; } final Block block = event.getBlock(); - if (block.getType() == Material.RAILS && prot.getSettingBool(ProtectConfig.protect_rails)) + if ((block.getType() == Material.RAILS || block.getType() == Material.POWERED_RAIL || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) { event.setCancelled(true); return; @@ -257,10 +257,10 @@ public class EssentialsProtectBlockListener extends BlockListener if (user.isAuthorized("essentials.protect.admin")) { - if (type == Material.WALL_SIGN || type == Material.SIGN_POST || type == Material.RAILS) + if (type == Material.WALL_SIGN || type == Material.SIGN_POST || type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL) { storage.unprotectBlock(block); - if (type == Material.RAILS || type == Material.SIGN_POST) + if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL || type == Material.SIGN_POST) { final Block below = block.getRelative(BlockFace.DOWN); storage.unprotectBlock(below); @@ -293,10 +293,10 @@ public class EssentialsProtectBlockListener extends BlockListener } else { - if (type == Material.WALL_SIGN || type == Material.SIGN_POST || type == Material.RAILS) + if (type == Material.WALL_SIGN || type == Material.SIGN_POST || type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL) { storage.unprotectBlock(block); - if (type == Material.RAILS || type == Material.SIGN_POST) + if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL || type == Material.SIGN_POST) { final Block below = block.getRelative(BlockFace.DOWN); storage.unprotectBlock(below); @@ -337,7 +337,11 @@ public class EssentialsProtectBlockListener extends BlockListener return; } if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS - || block.getType() == Material.RAILS) + || block.getType() == Material.RAILS + || block.getRelative(BlockFace.UP).getType() == Material.POWERED_RAIL + || block.getType() == Material.POWERED_RAIL + || block.getRelative(BlockFace.UP).getType() == Material.DETECTOR_RAIL + || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) { event.setCancelled(true); @@ -385,7 +389,11 @@ public class EssentialsProtectBlockListener extends BlockListener return; } if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS - || block.getType() == Material.RAILS) + || block.getType() == Material.RAILS + || block.getRelative(BlockFace.UP).getType() == Material.POWERED_RAIL + || block.getType() == Material.POWERED_RAIL + || block.getRelative(BlockFace.UP).getType() == Material.DETECTOR_RAIL + || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) { event.setCancelled(true); diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java index d85d2b3d7..f28fd1185 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java @@ -1,10 +1,11 @@ package com.earth2me.essentials.protect; -import com.earth2me.essentials.EssentialsBlockListener; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import java.util.HashSet; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import net.minecraft.server.ChunkPosition; import net.minecraft.server.Packet60Explosion; import org.bukkit.Location; @@ -13,19 +14,16 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.entity.CraftFireball; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.entity.CraftTNTPrimed; import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; import org.bukkit.entity.Fireball; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityExplodeEvent; @@ -39,15 +37,15 @@ public class EssentialsProtectEntityListener extends EntityListener { private final transient IProtect prot; private final transient IEssentials ess; - + public EssentialsProtectEntityListener(final IProtect prot) { this.prot = prot; this.ess = prot.getEssentials(); } - + @Override - public void onEntityDamage(EntityDamageEvent event) + public void onEntityDamage(final EntityDamageEvent event) { if (event.isCancelled()) { @@ -58,7 +56,7 @@ public class EssentialsProtectEntityListener extends EntityListener if (event instanceof EntityDamageByBlockEvent) { final DamageCause cause = event.getCause(); - + if (prot.getSettingBool(ProtectConfig.disable_contactdmg) && cause == DamageCause.CONTACT && !(target instanceof Player @@ -87,7 +85,7 @@ public class EssentialsProtectEntityListener extends EntityListener return; } } - + if (event instanceof EntityDamageByEntityEvent) { final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event; @@ -102,7 +100,7 @@ public class EssentialsProtectEntityListener extends EntityListener event.setCancelled(true); return; } - + //Creeper explode prevention if (eAttack instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_explosion) && !(target instanceof Player @@ -112,7 +110,7 @@ public class EssentialsProtectEntityListener extends EntityListener event.setCancelled(true); return; } - + if (eAttack instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_playerdmg) && !(target instanceof Player && user.isAuthorized("essentials.protect.damage.creeper") @@ -139,19 +137,22 @@ public class EssentialsProtectEntityListener extends EntityListener event.setCancelled(true); return; } + + if (edEvent.getDamager() instanceof Projectile + && target instanceof Player + && ((prot.getSettingBool(ProtectConfig.disable_projectiles) + && !(user.isAuthorized("essentials.protect.damage.projectiles") + && !user.isAuthorized("essentials.protect.damage.disable"))) + || (((Projectile)edEvent.getDamager()).getShooter() instanceof Player + && prot.getSettingBool(ProtectConfig.disable_pvp) + && (!user.isAuthorized("essentials.protect.pvp") + || !ess.getUser(((Projectile)edEvent.getDamager()).getShooter()).isAuthorized("essentials.protect.pvp"))))) + { + event.setCancelled(true); + return; + } } - - if (event instanceof EntityDamageByProjectileEvent - && target instanceof Player - && prot.getSettingBool(ProtectConfig.disable_projectiles) - && !(user.isAuthorized("essentials.protect.damage.projectiles") - && !user.isAuthorized("essentials.protect.damage.disable"))) - { - event.setCancelled(true); - ((EntityDamageByProjectileEvent)event).setBounce(true); - return; - } - + final DamageCause cause = event.getCause(); if (target instanceof Player) { @@ -163,7 +164,7 @@ public class EssentialsProtectEntityListener extends EntityListener event.setCancelled(true); return; } - + if (cause == DamageCause.SUFFOCATION && prot.getSettingBool(ProtectConfig.disable_suffocate) && !(user.isAuthorized("essentials.protect.damage.suffocation") @@ -199,9 +200,9 @@ public class EssentialsProtectEntityListener extends EntityListener } } } - + @Override - public void onEntityExplode(EntityExplodeEvent event) + public void onEntityExplode(final EntityExplodeEvent event) { if (event.isCancelled()) { @@ -214,43 +215,50 @@ public class EssentialsProtectEntityListener extends EntityListener || prot.getSettingBool(ProtectConfig.prevent_creeper_blockdmg) || (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight))) { - final Set set = new HashSet(event.blockList().size()); - final Player[] players = ess.getServer().getOnlinePlayers(); - final Set blocksUnderPlayers = new HashSet(players.length); - final Location loc = event.getLocation(); - for (Player player : players) + try { - if (player.getWorld().equals(loc.getWorld())) + final Set set = new HashSet(event.blockList().size()); + final Player[] players = ess.getServer().getOnlinePlayers(); + final Set blocksUnderPlayers = new HashSet(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())); + } } + ChunkPosition cp; + for (Block block : event.blockList()) + { + 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.0D, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, + new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set)); } - ChunkPosition cp; - for (Block block : event.blockList()) + catch (Throwable ex) { - cp = new ChunkPosition(block.getX(), block.getY(), block.getZ()); - if (!blocksUnderPlayers.contains(cp)) - { - set.add(cp); - } + Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex); } - - ((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0D, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, - new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set)); event.setCancelled(true); return; } - else if (event.getEntity() instanceof CraftTNTPrimed + else if (event.getEntity() instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)) { event.setCancelled(true); return; } - else if (event.getEntity() instanceof CraftFireball + else if (event.getEntity() instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) { event.setCancelled(true); @@ -261,7 +269,12 @@ public class EssentialsProtectEntityListener extends EntityListener for (Block block : event.blockList()) { - if ((block.getType() == Material.RAILS || block.getRelative(BlockFace.UP).getType() == Material.RAILS) + if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS + || block.getType() == Material.RAILS + || block.getRelative(BlockFace.UP).getType() == Material.POWERED_RAIL + || block.getType() == Material.POWERED_RAIL + || block.getRelative(BlockFace.UP).getType() == Material.DETECTOR_RAIL + || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) { event.setCancelled(true); @@ -279,19 +292,13 @@ public class EssentialsProtectEntityListener extends EntityListener event.setCancelled(true); return; } - /*if (EssentialsBlockListener.protectedBlocks.contains(block.getType()) - && EssentialsBlockListener.isBlockProtected(block)) - { - event.setCancelled(true); - return; - }*/ } } - + @Override public void onCreatureSpawn(final CreatureSpawnEvent event) { - if (event.getEntity() instanceof CraftPlayer) + if (event.getEntity() instanceof Player) { return; } @@ -309,7 +316,7 @@ public class EssentialsProtectEntityListener extends EntityListener event.setCancelled(true); } } - + @Override public void onEntityTarget(final EntityTargetEvent event) { @@ -335,12 +342,12 @@ public class EssentialsProtectEntityListener extends EntityListener return; } } - + @Override public void onExplosionPrime(ExplosionPrimeEvent event) { - if (event.getEntity() instanceof CraftFireball - && prot.getSettingBool(ProtectConfig.prevent_fireball_fire)) + if (event.getEntity() instanceof Fireball + && prot.getSettingBool(ProtectConfig.prevent_fireball_fire)) { event.setFire(false); } diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java index 6f538ac92..9ffc1c3f0 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java @@ -16,7 +16,6 @@ public class Commandsetspawn extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - charge(user); final String group = args.length > 0 ? getFinalArg(args, 0) : "default"; ess.getSpawn().setSpawn(user.getLocation(), group); user.sendMessage(Util.format("spawnSet", group)); diff --git a/lib/PermissionsBukkit-1.2.jar b/lib/PermissionsBukkit-1.2.jar new file mode 100644 index 000000000..3f5caf1b4 Binary files /dev/null and b/lib/PermissionsBukkit-1.2.jar differ diff --git a/lib/bPermissions.jar b/lib/bPermissions.jar new file mode 100644 index 000000000..b3b38e425 Binary files /dev/null and b/lib/bPermissions.jar differ