diff --git a/.gitignore b/.gitignore index c1c78f213..adc931227 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,4 @@ /EssentialsUpdate/dist/ /EssentialsUpdate/build/ /WebPush/apikey.php - -/WebPush/apikey.php -/WebPush/apikey.php \ No newline at end of file +/WebPush/nbproject/private \ No newline at end of file diff --git a/Essentials/nbproject/pmd.settings b/Essentials/nbproject/pmd.settings index 824aa3ac9..29baf7ea1 100644 --- a/Essentials/nbproject/pmd.settings +++ b/Essentials/nbproject/pmd.settings @@ -1,2 +1,3 @@ DoNotUseThreads +LongVariable SignatureDeclareThrowsException diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 079cf2b0c..8e7ea3314 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -29,6 +29,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blank auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2 auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*;static * auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4 auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE @@ -37,6 +38,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.place auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateStaticImports=true auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4 auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4 diff --git a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java new file mode 100644 index 000000000..1ec545b69 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java @@ -0,0 +1,113 @@ +package com.earth2me.essentials; + +import java.util.*; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.PluginCommand; +import org.bukkit.command.PluginCommandYamlParser; +import org.bukkit.plugin.Plugin; + + +public class AlternativeCommandsHandler +{ + private final transient Map> altcommands = new HashMap>(); + private final transient IEssentials ess; + + public AlternativeCommandsHandler(final IEssentials ess) + { + this.ess = ess; + for (Plugin plugin : ess.getServer().getPluginManager().getPlugins()) + { + if (plugin.isEnabled()) { + addPlugin(plugin); + } + } + } + + public final void addPlugin(final Plugin plugin) + { + if (plugin.getDescription().getMain().contains("com.earth2me.essentials")) + { + return; + } + final List commands = PluginCommandYamlParser.parse(plugin); + final String pluginName = plugin.getDescription().getName().toLowerCase(); + + for (Command command : commands) + { + final PluginCommand pc = (PluginCommand)command; + final List labels = new ArrayList(pc.getAliases()); + labels.add(pc.getName()); + + PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase()); + if (reg == null) + { + reg = Bukkit.getServer().getPluginCommand(pc.getName().toLowerCase()); + } + for (String label : labels) + { + List plugincommands = altcommands.get(label.toLowerCase()); + if (plugincommands == null) + { + plugincommands = new ArrayList(); + altcommands.put(label.toLowerCase(), plugincommands); + } + boolean found = false; + for (PluginCommand pc2 : plugincommands) + { + if (pc2.getPlugin().equals(plugin)) + { + found = true; + } + } + if (!found) + { + plugincommands.add(reg); + } + } + } + } + + public void removePlugin(final Plugin plugin) + { + final Iterator>> iterator = altcommands.entrySet().iterator(); + while (iterator.hasNext()) + { + final Map.Entry> entry = iterator.next(); + final Iterator pcIterator = entry.getValue().iterator(); + while (pcIterator.hasNext()) + { + final PluginCommand pc = pcIterator.next(); + if (pc.getPlugin().equals(plugin)) + { + pcIterator.remove(); + } + } + if (entry.getValue().isEmpty()) + { + iterator.remove(); + } + } + } + + public PluginCommand getAlternative(final String label) + { + final List commands = altcommands.get(label); + if (commands == null || commands.isEmpty()) + { + return null; + } + if (commands.size() == 1) + { + return commands.get(0); + } + // return the first command that is not an alias + for (PluginCommand command : commands) { + if (command.getName().equalsIgnoreCase(label)) { + return command; + } + } + // return the first alias + return commands.get(0); + } +} diff --git a/Essentials/src/com/earth2me/essentials/Backup.java b/Essentials/src/com/earth2me/essentials/Backup.java index 02a3d54ba..1527991b9 100644 --- a/Essentials/src/com/earth2me/essentials/Backup.java +++ b/Essentials/src/com/earth2me/essentials/Backup.java @@ -7,7 +7,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Server; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.CraftServer; public class Backup implements Runnable @@ -48,6 +47,7 @@ public class Backup implements Runnable } } + @Override public void run() { if (active) @@ -68,6 +68,7 @@ public class Backup implements Runnable ess.scheduleAsyncDelayedTask( new Runnable() { + @Override public void run() { try @@ -109,6 +110,7 @@ public class Backup implements Runnable ess.scheduleSyncDelayedTask( new Runnable() { + @Override public void run() { server.dispatchCommand(cs, "save-on"); diff --git a/Essentials/src/com/earth2me/essentials/Console.java b/Essentials/src/com/earth2me/essentials/Console.java index dcdb65a0d..d07171c63 100644 --- a/Essentials/src/com/earth2me/essentials/Console.java +++ b/Essentials/src/com/earth2me/essentials/Console.java @@ -19,11 +19,13 @@ public final class Console implements IReplyTo return server.getConsoleSender(); } + @Override public void setReplyTo(CommandSender user) { replyTo = user; } + @Override public CommandSender getReplyTo() { return replyTo; diff --git a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java index 0fd2e9047..acdfbb291 100644 --- a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java +++ b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java @@ -1,6 +1,5 @@ package com.earth2me.essentials; -import com.earth2me.essentials.commands.Commandtime; import java.text.SimpleDateFormat; import java.util.*; diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 392321f9f..6ab23e8fb 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -19,12 +19,6 @@ package com.earth2me.essentials; import com.earth2me.essentials.api.Economy; import com.earth2me.essentials.commands.EssentialsCommand; -import java.io.*; -import java.util.*; -import java.util.logging.*; -import org.bukkit.*; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.commands.NotEnoughArgumentsException; @@ -33,14 +27,29 @@ import com.earth2me.essentials.register.payment.Methods; import com.earth2me.essentials.signs.SignBlockListener; import com.earth2me.essentials.signs.SignEntityListener; import com.earth2me.essentials.signs.SignPlayerListener; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.bukkit.Server; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Type; -import org.bukkit.plugin.*; -import org.bukkit.plugin.java.*; +import org.bukkit.plugin.InvalidDescriptionException; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; @@ -59,6 +68,7 @@ public class Essentials extends JavaPlugin implements IEssentials private transient ItemDb itemDb; private transient final Methods paymentMethod = new Methods(); private transient PermissionsHandler permissionsHandler; + private transient AlternativeCommandsHandler alternativeCommandsHandler; private transient UserMap userMap; private transient ExecuteTimer execTimer; @@ -93,11 +103,6 @@ public class Essentials extends JavaPlugin implements IEssentials { execTimer = new ExecuteTimer(); execTimer.start(); - final String[] javaversion = System.getProperty("java.version").split("\\.", 3); - if (javaversion == null || javaversion.length < 2 || Integer.parseInt(javaversion[1]) < 6) - { - LOGGER.log(Level.SEVERE, "Java version not supported! Please install Java 1.6. You have " + System.getProperty("java.version")); - } final EssentialsUpgrade upgrade = new EssentialsUpgrade(this); upgrade.beforeSettings(); execTimer.mark("Upgrade"); @@ -148,6 +153,7 @@ public class Essentials extends JavaPlugin implements IEssentials } permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions()); + alternativeCommandsHandler = new AlternativeCommandsHandler(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); @@ -237,120 +243,6 @@ public class Essentials extends JavaPlugin implements IEssentials } Util.updateLocale(settings.getLocale(), this); - - // for motd - getConfiguration().load(); - } - - @Override - public String[] getMotd(final CommandSender sender, final String def) - { - return getLines(sender, "motd", def); - } - - @Override - public String[] getLines(final CommandSender sender, final String node, final String def) - { - List lines = (List)getConfiguration().getProperty(node); - if (lines == null) - { - return new String[0]; - } - String[] retval = new String[lines.size()]; - - if (lines.isEmpty() || lines.get(0) == null) - { - try - { - lines = new ArrayList(); - // "[]" in YaML indicates empty array, so respect that - if (!getConfiguration().getString(node, def).equals("[]")) - { - lines.add(getConfiguration().getString(node, def)); - retval = new String[lines.size()]; - } - } - catch (Throwable ex2) - { - LOGGER.log(Level.WARNING, Util.format("corruptNodeInConfig", node)); - return new String[0]; - } - } - - // if still empty, call it a day - if (lines == null || lines.isEmpty() || lines.get(0) == null) - { - return new String[0]; - } - - for (int i = 0; i < lines.size(); i++) - { - String m = lines.get(i); - if (m == null) - { - continue; - } - m = m.replace('&', '§').replace("§§", "&"); - - if (sender instanceof User || sender instanceof Player) - { - User user = getUser(sender); - m = m.replace("{PLAYER}", user.getDisplayName()); - m = m.replace("{IP}", user.getAddress().toString()); - m = m.replace("{BALANCE}", Double.toString(user.getMoney())); - m = m.replace("{MAILS}", Integer.toString(user.getMails().size())); - m = m.replace("{WORLD}", user.getLocation().getWorld().getName()); - } - int playerHidden = 0; - for (Player p : getServer().getOnlinePlayers()) - { - if (getUser(p).isHidden()) - { - playerHidden++; - } - } - m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden)); - m = m.replace("{UNIQUE}", Integer.toString(userMap.getUniqueUsers())); - - if (m.matches(".*\\{PLAYERLIST\\}.*")) - { - StringBuilder online = new StringBuilder(); - for (Player p : getServer().getOnlinePlayers()) - { - if (getUser(p).isHidden()) - { - continue; - } - if (online.length() > 0) - { - online.append(", "); - } - online.append(p.getDisplayName()); - } - m = m.replace("{PLAYERLIST}", online.toString()); - } - - if (sender instanceof Player) - { - try - { - Class User = getClassLoader().loadClass("bukkit.Vandolis.User"); - Object vuser = User.getConstructor(User.class).newInstance((Player)sender); - m = m.replace("{RED:BALANCE}", User.getMethod("getMoney").invoke(vuser).toString()); - m = m.replace("{RED:BUYS}", User.getMethod("getNumTransactionsBuy").invoke(vuser).toString()); - m = m.replace("{RED:SELLS}", User.getMethod("getNumTransactionsSell").invoke(vuser).toString()); - } - catch (Throwable ex) - { - m = m.replace("{RED:BALANCE}", "N/A"); - m = m.replace("{RED:BUYS}", "N/A"); - m = m.replace("{RED:SELLS}", "N/A"); - } - } - - retval[i] = m + " "; - } - return retval; } @Override @@ -365,29 +257,11 @@ public class Essentials extends JavaPlugin implements IEssentials // Allow plugins to override the command via onCommand if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e")) { - for (Plugin p : getServer().getPluginManager().getPlugins()) + final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel); + if (pc != null) { - if (p.getDescription().getMain().contains("com.earth2me.essentials")) - { - continue; - } - - final PluginDescriptionFile desc = p.getDescription(); - if (desc == null) - { - continue; - } - - if (desc.getName() == null) - { - continue; - } - - final PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel); - if (pc != null) - { - return pc.execute(sender, commandLabel, args); - } + LOGGER.info("Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel()); + return pc.execute(sender, commandLabel, args); } } @@ -663,6 +537,12 @@ public class Essentials extends JavaPlugin implements IEssentials return permissionsHandler; } + @Override + public AlternativeCommandsHandler getAlternativeCommandsHandler() + { + return alternativeCommandsHandler; + } + @Override public ItemDb getItemDb() { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java index 72c308655..88e536015 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java @@ -99,6 +99,7 @@ public class EssentialsBlockListener extends BlockListener ess.scheduleSyncDelayedTask( new Runnable() { + @Override public void run() { user.getInventory().addItem(is); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index c48f9f987..edd3aad6b 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -1,12 +1,6 @@ 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; -import java.io.OutputStream; +import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -148,7 +142,6 @@ public class EssentialsConf extends Configuration catch (IOException ex) { LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex); - return; } finally { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index fed7a2956..f1bcd34f2 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -1,19 +1,11 @@ package com.earth2me.essentials; import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityListener; -import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.*; import org.bukkit.inventory.ItemStack; diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 8ddc540ba..2768b566e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -1,5 +1,10 @@ package com.earth2me.essentials; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.TextInput; +import com.earth2me.essentials.textreader.TextPager; +import java.io.IOException; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -8,26 +13,10 @@ import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Server; -import org.bukkit.World; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerAnimationType; -import org.bukkit.event.player.PlayerBedEnterEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerEggThrowEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerListener; -import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; @@ -135,6 +124,7 @@ public class EssentialsPlayerListener extends PlayerListener } final Thread thread = new Thread(new Runnable() { + @Override public void run() { try @@ -150,7 +140,6 @@ public class EssentialsPlayerListener extends PlayerListener } catch (InterruptedException ex) { - return; } } }); @@ -177,13 +166,16 @@ public class EssentialsPlayerListener extends PlayerListener if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd")) { - for (String m : ess.getMotd(user, null)) + try { - if (m == null) - { - continue; - } - user.sendMessage(m); + final IText input = new TextInput(user, "motd", true, ess); + final IText output = new KeywordReplacer(input, user, ess); + final TextPager pager = new TextPager(output, false); + pager.showPage("1", null, user); + } + catch (IOException ex) + { + LOGGER.log(Level.WARNING, ex.getMessage(), ex); } } @@ -308,6 +300,7 @@ public class EssentialsPlayerListener extends PlayerListener event.getItemStack().setType(event.getBucket()); ess.scheduleSyncDelayedTask(new Runnable() { + @Override public void run() { user.updateInventory(); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java index 6b92d7aa2..b0ee0b543 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java @@ -21,6 +21,7 @@ public class EssentialsPluginListener extends ServerListener implements IConf public void onPluginEnable(final PluginEnableEvent event) { ess.getPermissionsHandler().checkPermissions(); + ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin()); if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager())) { LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")"); @@ -31,6 +32,7 @@ public class EssentialsPluginListener extends ServerListener implements IConf public void onPluginDisable(final PluginDisableEvent event) { ess.getPermissionsHandler().checkPermissions(); + ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin()); // Check to see if the plugin thats being disabled is the one we are using if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin())) { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java index 409250a00..9127ec61b 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -1,21 +1,10 @@ package com.earth2me.essentials; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; import java.math.BigInteger; import java.security.DigestInputStream; import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; @@ -82,6 +71,50 @@ public class EssentialsUpgrade } } + private void moveMotdRulesToFile(String name) + { + if (doneFile.getBoolean("move"+name+"ToFile", false)) + { + return; + } + try + { + final File file = new File(ess.getDataFolder(), name+".txt"); + if (file.exists()) + { + return; + } + final File configFile = new File(ess.getDataFolder(), "config.yml"); + if (!configFile.exists()) + { + return; + } + final EssentialsConf conf = new EssentialsConf(configFile); + conf.load(); + List lines = conf.getStringList(name, null); + if (lines != null && !lines.isEmpty()) + { + if (!file.createNewFile()) + { + throw new IOException("Failed to create file " + file); + } + PrintWriter writer = new PrintWriter(file); + + for (String line : lines) + { + writer.println(line); + } + writer.close(); + } + doneFile.setProperty("move"+name+"ToFile", true); + doneFile.save(); + } + catch (Throwable e) + { + LOGGER.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e); + } + } + private void removeLinesFromConfig(File file, String regex, String info) throws Exception { boolean needUpdate = false; @@ -654,6 +687,8 @@ public class EssentialsUpgrade ess.getDataFolder().mkdirs(); } moveWorthValuesToWorthYml(); + moveMotdRulesToFile("motd"); + moveMotdRulesToFile("rules"); } public void afterSettings() diff --git a/Essentials/src/com/earth2me/essentials/ExecuteTimer.java b/Essentials/src/com/earth2me/essentials/ExecuteTimer.java index 7a88018c2..301669428 100644 --- a/Essentials/src/com/earth2me/essentials/ExecuteTimer.java +++ b/Essentials/src/com/earth2me/essentials/ExecuteTimer.java @@ -1,12 +1,17 @@ package com.earth2me.essentials; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.ArrayList; import java.util.List; +import java.util.Locale; public class ExecuteTimer { - private final List times; + private final transient List times; + private final transient DecimalFormat decimalFormat = new DecimalFormat("#0.000", DecimalFormatSymbols.getInstance(Locale.US)); + public ExecuteTimer() { @@ -24,7 +29,7 @@ public class ExecuteTimer { if (!times.isEmpty() || "start".equals(label)) { - times.add(new ExecuteRecord(label, System.currentTimeMillis())); + times.add(new ExecuteRecord(label, System.nanoTime())); } } @@ -36,7 +41,7 @@ public class ExecuteTimer long time0 = 0; long time1 = 0; long time2 = 0; - long duration; + double duration; for (ExecuteRecord pair : times) { @@ -44,8 +49,8 @@ public class ExecuteTimer time2 = (Long)pair.getTime(); if (time1 > 0) { - duration = time2 - time1; - output.append(mark).append(": ").append(duration).append("ms - "); + duration = (time2 - time1)/1000000.0; + output.append(mark).append(": ").append(decimalFormat.format(duration)).append("ms - "); } else { @@ -53,8 +58,8 @@ public class ExecuteTimer } time1 = time2; } - duration = time1 - time0; - output.append("Total: ").append(duration).append("ms"); + duration = (time1 - time0)/1000000.0; + output.append("Total: ").append(decimalFormat.format(duration)).append("ms"); times.clear(); return output.toString(); } diff --git a/Essentials/src/com/earth2me/essentials/FakeWorld.java b/Essentials/src/com/earth2me/essentials/FakeWorld.java index 0b5d68be1..c22a04c5a 100644 --- a/Essentials/src/com/earth2me/essentials/FakeWorld.java +++ b/Essentials/src/com/earth2me/essentials/FakeWorld.java @@ -2,23 +2,10 @@ package com.earth2me.essentials; import java.util.List; import java.util.UUID; -import org.bukkit.BlockChangeDelegate; -import org.bukkit.Chunk; -import org.bukkit.ChunkSnapshot; -import org.bukkit.Difficulty; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.TreeType; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Biome; import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.CreatureType; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LightningStrike; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import org.bukkit.entity.*; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.inventory.ItemStack; @@ -36,367 +23,440 @@ public class FakeWorld implements World this.env = environment; } + @Override public Block getBlockAt(int i, int i1, int i2) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Block getBlockAt(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public int getBlockTypeIdAt(int i, int i1, int i2) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public int getBlockTypeIdAt(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public int getHighestBlockYAt(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public int getHighestBlockYAt(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Chunk getChunkAt(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Chunk getChunkAt(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Chunk getChunkAt(Block block) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isChunkLoaded(Chunk chunk) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Chunk[] getLoadedChunks() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void loadChunk(Chunk chunk) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isChunkLoaded(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void loadChunk(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean loadChunk(int i, int i1, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean unloadChunk(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean unloadChunk(int i, int i1, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean unloadChunk(int i, int i1, boolean bln, boolean bln1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean unloadChunkRequest(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean unloadChunkRequest(int i, int i1, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean regenerateChunk(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean refreshChunk(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Item dropItem(Location lctn, ItemStack is) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Item dropItemNaturally(Location lctn, ItemStack is) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Arrow spawnArrow(Location lctn, Vector vector, float f, float f1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean generateTree(Location lctn, TreeType tt) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean generateTree(Location lctn, TreeType tt, BlockChangeDelegate bcd) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public LivingEntity spawnCreature(Location lctn, CreatureType ct) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public LightningStrike strikeLightning(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public LightningStrike strikeLightningEffect(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public List getEntities() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public List getLivingEntities() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public List getPlayers() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public String getName() { return name; } + @Override public long getId() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Location getSpawnLocation() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean setSpawnLocation(int i, int i1, int i2) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getTime() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setTime(long l) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getFullTime() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setFullTime(long l) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean hasStorm() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setStorm(boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public int getWeatherDuration() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setWeatherDuration(int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isThundering() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setThundering(boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public int getThunderDuration() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setThunderDuration(int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Environment getEnvironment() { return env; } + @Override public long getSeed() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean getPVP() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setPVP(boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void save() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean createExplosion(double d, double d1, double d2, float f) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean createExplosion(Location lctn, float f) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public ChunkGenerator getGenerator() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public List getPopulators() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void playEffect(Location lctn, Effect effect, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void playEffect(Location lctn, Effect effect, int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean createExplosion(double d, double d1, double d2, float f, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean createExplosion(Location lctn, float f, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public T spawn(Location lctn, Class type) throws IllegalArgumentException { throw new UnsupportedOperationException("Not supported yet."); } + @Override public ChunkSnapshot getEmptyChunkSnapshot(int i, int i1, boolean bln, boolean bln1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setSpawnFlags(boolean bln, boolean bln1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean getAllowAnimals() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean getAllowMonsters() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public UUID getUID() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Block getHighestBlockAt(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Block getHighestBlockAt(Location lctn) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Biome getBiome(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public double getTemperature(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public double getHumidity(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); diff --git a/Essentials/src/com/earth2me/essentials/I18n.java b/Essentials/src/com/earth2me/essentials/I18n.java new file mode 100644 index 000000000..bef8764b1 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/I18n.java @@ -0,0 +1,162 @@ +package com.earth2me.essentials; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.text.MessageFormat; +import java.util.*; +import java.util.logging.Level; +import org.bukkit.Bukkit; + + +public class I18n +{ + private static I18n instance; + private static final String MESSAGES = "messages"; + private final transient Locale defaultLocale = Locale.getDefault(); + private transient Locale currentLocale = defaultLocale; + private transient ResourceBundle customBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale); + private transient ResourceBundle localeBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale); + private final transient ResourceBundle defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH); + private final transient Map messageFormatCache = new HashMap(); + + public I18n() + { + instance = this; + } + + public Locale getCurrentLocale() + { + return currentLocale; + } + + public String translate(final String string) + { + try + { + try + { + return customBundle.getString(string); + } + catch (MissingResourceException ex) + { + return localeBundle.getString(string); + } + } + catch (MissingResourceException ex) + { + Bukkit.getLogger().log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), localeBundle.getLocale().toString()), ex); + return defaultBundle.getString(string); + } + } + + public static String _(final String string, final Object... objects) + { + if (objects.length == 0) + { + return instance.translate(string); + } + else + { + return instance.format(string, objects); + } + } + + public String format(final String string, final Object... objects) + { + final String format = translate(string); + MessageFormat messageFormat = messageFormatCache.get(format); + if (messageFormat == null) + { + messageFormat = new MessageFormat(format); + messageFormatCache.put(format, messageFormat); + } + return messageFormat.format(objects); + } + + public void updateLocale(final String loc, final IEssentials ess) + { + if (loc == null || loc.isEmpty()) + { + return; + } + final String[] parts = loc.split("[_\\.]"); + if (parts.length == 1) + { + currentLocale = new Locale(parts[0]); + } + if (parts.length == 2) + { + currentLocale = new Locale(parts[0], parts[1]); + } + if (parts.length == 3) + { + currentLocale = new Locale(parts[0], parts[1], parts[2]); + } + Bukkit.getLogger().log(Level.INFO, String.format("Using locale %s", currentLocale.toString())); + customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess)); + localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale); + } + + public static String lowerCase(final String input) + { + return input == null ? null : input.toLowerCase(Locale.ENGLISH); + } + + public static String capitalCase(final String input) + { + return input == null || input.length() == 0 + ? input + : input.toUpperCase(Locale.ENGLISH).charAt(0) + + input.toLowerCase(Locale.ENGLISH).substring(1); + } + + + private static class FileResClassLoader extends ClassLoader + { + private final transient File dataFolder; + + public FileResClassLoader(final ClassLoader classLoader, final IEssentials ess) + { + super(classLoader); + this.dataFolder = ess.getDataFolder(); + } + + @Override + public URL getResource(final String string) + { + final File file = new File(dataFolder, string); + if (file.exists()) + { + try + { + return file.toURI().toURL(); + } + catch (MalformedURLException ex) + { + } + } + return super.getResource(string); + } + + @Override + public InputStream getResourceAsStream(final String string) + { + final File file = new File(dataFolder, string); + if (file.exists()) + { + try + { + return new FileInputStream(file); + } + catch (FileNotFoundException ex) + { + } + } + return super.getResourceAsStream(string); + } + } +} diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 9dca96e81..ef54b0776 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -29,10 +29,6 @@ public interface IEssentials extends Plugin BukkitScheduler getScheduler(); - String[] getMotd(CommandSender sender, String def); - - String[] getLines(CommandSender sender, String node, String def); - Jail getJail(); Warps getWarps(); @@ -56,6 +52,8 @@ public interface IEssentials extends Plugin TNTExplodeListener getTNTListener(); PermissionsHandler getPermissionsHandler(); + + AlternativeCommandsHandler getAlternativeCommandsHandler(); void showError(final CommandSender sender, final Throwable exception, final String commandLabel); diff --git a/Essentials/src/com/earth2me/essentials/Jail.java b/Essentials/src/com/earth2me/essentials/Jail.java index ff3bec2f7..3ccfcb337 100644 --- a/Essentials/src/com/earth2me/essentials/Jail.java +++ b/Essentials/src/com/earth2me/essentials/Jail.java @@ -60,6 +60,7 @@ public class Jail extends BlockListener implements IConf return config.getKeys(null); } + @Override public void reloadConfig() { config.load(); diff --git a/Essentials/src/com/earth2me/essentials/JailPlayerListener.java b/Essentials/src/com/earth2me/essentials/JailPlayerListener.java index da8c165cb..c801780fe 100644 --- a/Essentials/src/com/earth2me/essentials/JailPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/JailPlayerListener.java @@ -2,11 +2,7 @@ package com.earth2me.essentials; import java.util.logging.Level; import java.util.logging.Logger; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerListener; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.*; public class JailPlayerListener extends PlayerListener diff --git a/Essentials/src/com/earth2me/essentials/ManagedFile.java b/Essentials/src/com/earth2me/essentials/ManagedFile.java index 759261e02..9176024ae 100644 --- a/Essentials/src/com/earth2me/essentials/ManagedFile.java +++ b/Essentials/src/com/earth2me/essentials/ManagedFile.java @@ -1,15 +1,6 @@ package com.earth2me.essentials; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; +import java.io.*; import java.math.BigInteger; import java.security.DigestInputStream; import java.security.DigestOutputStream; @@ -138,12 +129,12 @@ public class ManagedFile try { String hash = reader.readLine(); - if (hash.matches("#[a-f0-9]{32}")) + if (hash != null && hash.matches("#[a-f0-9]{32}")) { hash = hash.substring(1); bais.reset(); final String versionline = reader.readLine(); - if (versionline.matches("#version: .+")) + if (versionline != null && versionline.matches("#version: .+")) { final String versioncheck = versionline.substring(10); if (!versioncheck.equalsIgnoreCase(version)) diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index 8e50aa1bd..229406273 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -6,23 +6,9 @@ import java.util.List; import java.util.Set; import java.util.UUID; import lombok.Delegate; -import org.bukkit.Achievement; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Instrument; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Note; -import org.bukkit.Server; -import org.bukkit.Statistic; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Egg; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.Vehicle; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -66,77 +52,93 @@ public class OfflinePlayer implements Player { } + @Override public void setCompassTarget(Location lctn) { } + @Override public InetSocketAddress getAddress() { return null; } + @Override public void kickPlayer(String string) { } + @Override public PlayerInventory getInventory() { return null; } + @Override public ItemStack getItemInHand() { return null; } + @Override public void setItemInHand(ItemStack is) { } + @Override public int getHealth() { return 0; } + @Override public void setHealth(int i) { } + @Override public Egg throwEgg() { return null; } + @Override public Snowball throwSnowball() { return null; } + @Override public Arrow shootArrow() { return null; } + @Override public boolean isInsideVehicle() { return false; } + @Override public boolean leaveVehicle() { return false; } + @Override public Vehicle getVehicle() { return null; } + @Override public Location getLocation() { return location; } + @Override public World getWorld() { return world; @@ -156,11 +158,13 @@ public class OfflinePlayer implements Player { } + @Override public int getEntityId() { return -1; } + @Override public boolean performCommand(String string) { return false; @@ -171,91 +175,109 @@ public class OfflinePlayer implements Player return false; } + @Override public int getRemainingAir() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setRemainingAir(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getMaximumAir() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setMaximumAir(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean isSneaking() { return false; } + @Override public void setSneaking(boolean bln) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void updateInventory() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void chat(String string) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public double getEyeHeight() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public double getEyeHeight(boolean bln) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public List getLineOfSight(HashSet hs, int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public Block getTargetBlock(HashSet hs, int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public List getLastTwoTargetBlocks(HashSet hs, int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getFireTicks() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getMaxFireTicks() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setFireTicks(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void remove() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public Server getServer() { return ess == null ? null : ess.getServer(); @@ -271,295 +293,354 @@ public class OfflinePlayer implements Player throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setVelocity(Vector vector) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public Vector getVelocity() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void damage(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void damage(int i, Entity entity) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public Location getEyeLocation() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void sendRawMessage(String string) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public Location getCompassTarget() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getMaximumNoDamageTicks() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setMaximumNoDamageTicks(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getLastDamage() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setLastDamage(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getNoDamageTicks() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setNoDamageTicks(int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean teleport(Location lctn) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean teleport(Entity entity) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public Entity getPassenger() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean setPassenger(Entity entity) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean isEmpty() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean eject() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void saveData() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void loadData() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean isSleeping() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public int getSleepTicks() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public List getNearbyEntities(double d, double d1, double d2) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean isDead() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public float getFallDistance() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setFallDistance(float f) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setSleepingIgnored(boolean bln) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean isSleepingIgnored() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void awardAchievement(Achievement a) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc, int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc, Material mtrl) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc, Material mtrl, int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void playNote(Location lctn, byte b, byte b1) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void sendBlockChange(Location lctn, Material mtrl, byte b) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void sendBlockChange(Location lctn, int i, byte b) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void setLastDamageCause(EntityDamageEvent ede) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public EntityDamageEvent getLastDamageCause() { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public void playEffect(Location lctn, Effect effect, int i) { throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); } + @Override public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes) { return true; } + @Override public UUID getUniqueId() { return uniqueId; } + @Override public void playNote(Location lctn, Instrument i, Note note) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setPlayerTime(long l, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getPlayerTime() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getPlayerTimeOffset() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isPlayerTimeRelative() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void resetPlayerTime() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isPermissionSet(String string) { return false; } + @Override public boolean isPermissionSet(Permission prmsn) { return false; } + @Override public boolean hasPermission(String string) { return false; } + @Override public boolean hasPermission(Permission prmsn) { return false; } + @Override public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void removeAttachment(PermissionAttachment pa) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void recalculatePermissions() { } + @Override public Set getEffectivePermissions() { throw new UnsupportedOperationException("Not supported yet."); diff --git a/Essentials/src/com/earth2me/essentials/PlayerExtension.java b/Essentials/src/com/earth2me/essentials/PlayerExtension.java index 11c17761c..aef0aeebb 100644 --- a/Essentials/src/com/earth2me/essentials/PlayerExtension.java +++ b/Essentials/src/com/earth2me/essentials/PlayerExtension.java @@ -1,11 +1,11 @@ package com.earth2me.essentials; import lombok.Delegate; -import org.bukkit.craftbukkit.entity.CraftPlayer; import net.minecraft.server.EntityPlayer; import net.minecraft.server.IInventory; import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.ConfigurationSerializable; +import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.HumanEntity; diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index c19314e24..d3cc96f73 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -1,13 +1,13 @@ package com.earth2me.essentials; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.ChatColor; import com.earth2me.essentials.commands.IEssentialsCommand; import java.io.File; 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.ChatColor; import org.bukkit.inventory.ItemStack; @@ -466,6 +466,7 @@ public class Settings implements ISettings } private final static double MAXMONEY = 10000000000000.0; + @Override public double getMaxMoney() { double max = config.getDouble("max-money", MAXMONEY); @@ -476,36 +477,43 @@ public class Settings implements ISettings return max; } + @Override public boolean isEcoLogEnabled() { return config.getBoolean("economy-log-enabled", false); } + @Override public boolean removeGodOnDisconnect() { return config.getBoolean("remove-god-on-disconnect", false); } + @Override public boolean changeDisplayName() { return config.getBoolean("change-displayname", true); } + @Override public boolean useBukkitPermissions() { return config.getBoolean("use-bukkit-permissions", false); } + @Override public boolean addPrefixSuffix() { return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat")); } + @Override public boolean disablePrefix() { return config.getBoolean("disablePrefix", false); } + @Override public boolean disableSuffix() { return config.getBoolean("disableSuffix", false); diff --git a/Essentials/src/com/earth2me/essentials/Spawn.java b/Essentials/src/com/earth2me/essentials/Spawn.java index b1e06d50c..ab2d21c03 100644 --- a/Essentials/src/com/earth2me/essentials/Spawn.java +++ b/Essentials/src/com/earth2me/essentials/Spawn.java @@ -95,6 +95,7 @@ public class Spawn implements IConf return retval; } + @Override public void reloadConfig() { config.load(); diff --git a/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java b/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java index 0f3ca01cc..5f207fd51 100644 --- a/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java +++ b/Essentials/src/com/earth2me/essentials/TNTExplodeListener.java @@ -85,6 +85,7 @@ public class TNTExplodeListener extends EntityListener implements Runnable event.setCancelled(true); } + @Override public void run() { enabled = false; diff --git a/Essentials/src/com/earth2me/essentials/TargetBlock.java b/Essentials/src/com/earth2me/essentials/TargetBlock.java index 3d45afc55..fb6bfabb6 100644 --- a/Essentials/src/com/earth2me/essentials/TargetBlock.java +++ b/Essentials/src/com/earth2me/essentials/TargetBlock.java @@ -1,9 +1,9 @@ package com.earth2me.essentials; import java.util.List; -import org.bukkit.block.Block; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Player; diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 845f9c3a3..8c6b2c671 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -67,6 +67,7 @@ public class Teleport implements Runnable this.chargeFor = chargeFor; } + @Override public void run() { @@ -106,7 +107,6 @@ public class Teleport implements Runnable { ess.showError(user.getBase(), ex, "teleport"); } - return; } catch (Exception ex) { diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 2bbd32259..f4ded533c 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -4,6 +4,8 @@ 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.Level; +import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.CommandSender; @@ -20,6 +22,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser private transient long lastActivity = System.currentTimeMillis(); private boolean hidden = false; private transient Location afkPosition; + private static final Logger logger = Logger.getLogger("Minecraft"); User(final Player base, final IEssentials ess) { @@ -284,7 +287,18 @@ public class User extends UserData implements Comparable, IReplyTo, IUser public void setDisplayNick(String name) { setDisplayName(name); - setPlayerListName(name.length() > 16 ? name.substring(0, 16) : name); + if (name.length() > 16) + { + name = name.substring(0, name.charAt(15) == '§' ? 15 : 16); + } + try + { + setPlayerListName(name); + } + catch (IllegalArgumentException e) + { + logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix."); + } } @Override @@ -375,6 +389,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser return now; } + @Override public boolean isHidden() { return hidden; diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index dcf67bfc8..54bb31cdc 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -1,6 +1,5 @@ package com.earth2me.essentials; -import com.earth2me.essentials.commands.NotEnoughArgumentsException; import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -30,6 +29,7 @@ public abstract class UserData extends PlayerExtension implements IConf reloadConfig(); } + @Override public final void reloadConfig() { config.load(); @@ -278,7 +278,7 @@ public abstract class UserData extends PlayerExtension implements IConf public boolean hasPowerTools() { - return powertools.size() > 0; + return !powertools.isEmpty(); } private Location lastLocation; diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index 580b2aaf9..dc6d310e6 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -1,24 +1,27 @@ package com.earth2me.essentials; -import com.google.common.base.Function; -import com.google.common.collect.ComputationException; -import com.google.common.collect.MapMaker; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.collect.ConcurrentHashMultiset; import java.io.File; import java.util.HashSet; import java.util.Set; -import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -public class UserMap implements Function, IConf +public class UserMap extends CacheLoader implements IConf { private final transient IEssentials ess; - private final transient ConcurrentMap users = new MapMaker().softValues().makeComputingMap(this); + private final transient Cache users = CacheBuilder.newBuilder().softValues().build(this); + private final transient ConcurrentHashMultiset keys = ConcurrentHashMultiset.create(); public UserMap(final IEssentials ess) { + super(); this.ess = ess; loadAllUsersAsync(ess); } @@ -35,6 +38,8 @@ public class UserMap implements Function, IConf { return; } + keys.clear(); + users.invalidateAll(); for (String string : userdir.list()) { if (!string.endsWith(".yml")) @@ -42,18 +47,7 @@ public class UserMap implements Function, IConf continue; } final String name = string.substring(0, string.length() - 4); - try - { - users.get(name.toLowerCase()); - } - catch (NullPointerException ex) - { - // Ignore these - } - catch (ComputationException ex) - { - Bukkit.getLogger().log(Level.INFO, "Failed to preload user " + name, ex); - } + keys.add(name.toLowerCase()); } } }); @@ -61,21 +55,29 @@ public class UserMap implements Function, IConf public boolean userExists(final String name) { - return users.containsKey(name.toLowerCase()); + return keys.contains(name.toLowerCase()); } public User getUser(final String name) throws NullPointerException { - return users.get(name.toLowerCase()); + try + { + return users.get(name.toLowerCase()); + } + catch (ExecutionException ex) + { + throw new NullPointerException(); + } } @Override - public User apply(final String name) + public User load(final String name) throws Exception { for (Player player : ess.getServer().getOnlinePlayers()) { if (player.getName().equalsIgnoreCase(name)) { + keys.add(name.toLowerCase()); return new User(player, ess); } } @@ -83,37 +85,43 @@ public class UserMap implements Function, IConf final File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml"); if (userFile.exists()) { + keys.add(name.toLowerCase()); return new User(new OfflinePlayer(name, ess), ess); } - return null; + throw new Exception("User not found!"); } @Override public void reloadConfig() { - for (User user : users.values()) - { - user.reloadConfig(); - } + loadAllUsersAsync(ess); } public void removeUser(final String name) { - users.remove(name.toLowerCase()); + keys.remove(name.toLowerCase()); + users.invalidate(name.toLowerCase()); } public Set getAllUsers() { final Set userSet = new HashSet(); - for (String name : users.keySet()) + for (String name : keys) { - userSet.add(users.get(name)); + try + { + userSet.add(users.get(name)); + } + catch (ExecutionException ex) + { + Bukkit.getLogger().log(Level.INFO, "Failed to load user " + name, ex); + } } return userSet; } public int getUniqueUsers() { - return users.size(); + return keys.size(); } } diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 067c8115f..a710b6240 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -1,25 +1,12 @@ package com.earth2me.essentials; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.MessageFormat; -import java.util.Calendar; -import java.util.Enumeration; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Set; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; @@ -29,7 +16,6 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; public class Util diff --git a/Essentials/src/com/earth2me/essentials/Warps.java b/Essentials/src/com/earth2me/essentials/Warps.java index adf665f2a..fd532e211 100644 --- a/Essentials/src/com/earth2me/essentials/Warps.java +++ b/Essentials/src/com/earth2me/essentials/Warps.java @@ -1,12 +1,7 @@ package com.earth2me.essentials; import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Location; @@ -90,6 +85,7 @@ public class Warps implements IConf warpPoints.remove(new StringIgnoreCase(name)); } + @Override public final void reloadConfig() { warpPoints.clear(); diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index fd1426f10..e79f22444 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -52,6 +52,7 @@ public class Worth implements IConf config.save(); } + @Override public void reloadConfig() { config.load(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java index 8bf70873d..437318c09 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandafk extends EssentialsCommand @@ -29,7 +29,7 @@ public class Commandafk extends EssentialsCommand } } - private final void toggleAfk(User user) + private void toggleAfk(User user) { if (!user.toggleAfk()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java index 5bfdd3835..54277d466 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import org.bukkit.Location; import org.bukkit.Server; -import com.earth2me.essentials.User; -import com.earth2me.essentials.TargetBlock; import org.bukkit.entity.TNTPrimed; @@ -20,7 +20,7 @@ public class Commandantioch extends EssentialsCommand ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,"); ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it."); - final Location loc = new TargetBlock(user).getTargetBlock().getLocation(); + final Location loc = Util.getTarget(user); loc.getWorld().spawn(loc, TNTPrimed.class); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java index 26456a5d7..fa57f7a29 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java @@ -14,9 +14,9 @@ public class Commandback extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); user.sendMessage(Util.i18n("backUsageMsg")); user.getTeleport().back(charge); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java index 6bbf8361c..3498d6cdf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java @@ -14,9 +14,9 @@ public class Commandbackup extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - Backup backup = ess.getBackup(); + final Backup backup = ess.getBackup(); if (backup == null) { throw new Exception(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java index d26df68cb..988ec6b7f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -14,7 +14,7 @@ public class Commandbalance extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -24,13 +24,13 @@ public class Commandbalance 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 { - double bal = (args.length < 1 - || !(user.isAuthorized("essentials.balance.others") - || user.isAuthorized("essentials.balance.other")) - ? user - : getPlayer(server, args, 0, true)).getMoney(); + final double bal = (args.length < 1 + || !(user.isAuthorized("essentials.balance.others") + || user.isAuthorized("essentials.balance.other")) + ? user + : getPlayer(server, args, 0, true)).getMoney(); user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess))); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java index a162ea73f..1a3c7324c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java @@ -1,15 +1,10 @@ package com.earth2me.essentials.commands; -import java.util.Map.Entry; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.Map.Entry; +import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -21,7 +16,7 @@ public class Commandbalancetop extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { int max = 10; if (args.length > 0) @@ -47,6 +42,7 @@ public class Commandbalancetop extends EssentialsCommand final List> sortedEntries = new ArrayList>(balances.entrySet()); Collections.sort(sortedEntries, new Comparator>() { + @Override public int compare(final Entry entry1, final Entry entry2) { return -entry1.getValue().compareTo(entry2.getValue()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index a4a5e2839..2091ac4cd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -2,10 +2,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; import com.earth2me.essentials.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -23,8 +23,8 @@ public class Commandban extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - final User player = getPlayer(server, args, 0, true); - if (player.getBase() instanceof OfflinePlayer) + final User user = getPlayer(server, args, 0, true); + if (user.getBase() instanceof OfflinePlayer) { if (sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.ban.offline")) @@ -35,7 +35,7 @@ public class Commandban extends EssentialsCommand } else { - if (player.isAuthorized("essentials.ban.exempt")) + if (user.isAuthorized("essentials.ban.exempt")) { sender.sendMessage(Util.i18n("banExempt")); return; @@ -46,22 +46,22 @@ public class Commandban extends EssentialsCommand if (args.length > 1) { banReason = getFinalArg(args, 1); - player.setBanReason(banReason); + user.setBanReason(banReason); } else { banReason = Util.i18n("defaultBanReason"); } - player.setBanned(true); - player.kickPlayer(banReason); - String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - - for(Player p : server.getOnlinePlayers()) + user.setBanned(true); + user.kickPlayer(banReason); + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; + + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if(u.isAuthorized("essentials.ban.notify")) + final User player = ess.getUser(onlinePlayer); + if (player.isAuthorized("essentials.ban.notify")) { - p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason)); + onlinePlayer.sendMessage(Util.format("playerBanned", senderName, user.getName(), banReason)); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index eab34b122..05cd0aa3e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -21,21 +21,21 @@ public class Commandbanip extends EssentialsCommand throw new NotEnoughArgumentsException(); } - final User u = ess.getUser(args[0]); + final User player = ess.getUser(args[0]); - if (u == null) + if (player == null) { ess.getServer().banIP(args[0]); sender.sendMessage(Util.i18n("banIpAddress")); } else { - final String ipAddress = u.getLastLoginAddress(); + final String ipAddress = player.getLastLoginAddress(); if (ipAddress.length() == 0) { throw new Exception(Util.i18n("playerNotFound")); } - ess.getServer().banIP(u.getLastLoginAddress()); + ess.getServer().banIP(player.getLastLoginAddress()); sender.sendMessage(Util.i18n("banIpAddress")); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index c6cf83df4..f1dc4c7b4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.TreeType; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import org.bukkit.Location; +import org.bukkit.Server; +import org.bukkit.TreeType; public class Commandbigtree extends EssentialsCommand @@ -15,7 +15,7 @@ public class Commandbigtree 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 { TreeType tree; if (args.length > 0 && args[0].equalsIgnoreCase("redwood")) @@ -30,7 +30,7 @@ public class Commandbigtree extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - + final Location loc = Util.getTarget(user); final Location safeLocation = Util.getSafeDestination(loc); final boolean success = user.getWorld().generateTree(safeLocation, tree); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java index 9b92434a4..258741ad4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java @@ -3,7 +3,6 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; public class Commandbroadcast extends EssentialsCommand @@ -21,7 +20,6 @@ public class Commandbroadcast extends EssentialsCommand throw new NotEnoughArgumentsException(); } - ess.broadcastMessage(null, - Util.format("broadcast", getFinalArg(args, 0))); + ess.broadcastMessage(null, 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 5df3cb5d8..5c35c7486 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java @@ -14,7 +14,7 @@ public class Commandburn extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java index 447689691..a60f8960f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.List; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandclearinventory extends EssentialsCommand @@ -15,6 +15,7 @@ public class Commandclearinventory extends EssentialsCommand super("clearinventory"); } + //TODO: Cleanup @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java index eae10f0a5..31cfea6a0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandcompass extends EssentialsCommand @@ -13,39 +13,39 @@ public class Commandcompass 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 { - int r = (int)(user.getLocation().getYaw() + 180 + 360) % 360; + final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360; String dir; - if (r < 23) + if (bearing < 23) { dir = "N"; } - else if (r < 68) + else if (bearing < 68) { dir = "NE"; } - else if (r < 113) + else if (bearing < 113) { dir = "E"; } - else if (r < 158) + else if (bearing < 158) { dir = "SE"; } - else if (r < 203) + else if (bearing < 203) { dir = "S"; } - else if (r < 248) + else if (bearing < 248) { dir = "SW"; } - else if (r < 293) + else if (bearing < 293) { dir = "W"; } - else if (r < 338) + else if (bearing < 338) { dir = "NW"; } @@ -53,6 +53,6 @@ public class Commandcompass extends EssentialsCommand { dir = "N"; } - user.sendMessage(Util.format("compassBearing", dir, r)); + user.sendMessage(Util.format("compassBearing", dir, bearing)); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java index 1d80b6a17..a213c4f0e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; -import com.earth2me.essentials.Util; public class Commanddelhome extends EssentialsCommand @@ -14,25 +14,21 @@ public class Commanddelhome extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final 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; - } + final String[] expandedArgs = args[0].split(":"); User user = ess.getUser(sender); String name; - if (args.length < 1) + if (expandedArgs.length < 1) { throw new NotEnoughArgumentsException(); } - else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) + else if (expandedArgs.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) { - user = getPlayer(server, args, 0, true); - name = args[1]; + user = getPlayer(server, expandedArgs, 0, true); + name = expandedArgs[1]; } else { @@ -40,7 +36,7 @@ public class Commanddelhome extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - name = args[0]; + name = expandedArgs[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 23ec04c4e..ebede7e00 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java @@ -4,14 +4,17 @@ import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; -public class Commanddeljail extends EssentialsCommand { - public Commanddeljail() { +public class Commanddeljail extends EssentialsCommand +{ + public Commanddeljail() + { super("deljail"); } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { if (args.length < 1) { throw new NotEnoughArgumentsException(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java index 7c2795dda..115637827 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; -import com.earth2me.essentials.Util; public class Commanddelwarp extends EssentialsCommand @@ -13,7 +13,7 @@ public class Commanddelwarp extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java index 5ceb62591..f6de7c674 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commanddepth extends EssentialsCommand @@ -13,16 +13,16 @@ public class Commanddepth 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 { - int y = user.getLocation().getBlockY() - 63; - if (y > 0) + final int depth = user.getLocation().getBlockY() - 63; + if (depth > 0) { - user.sendMessage(Util.format("depthAboveSea", y)); + user.sendMessage(Util.format("depthAboveSea", depth)); } - else if (y < 0) + else if (depth < 0) { - user.sendMessage(Util.format("depthBelowSea", (-y))); + user.sendMessage(Util.format("depthBelowSea", (-depth))); } else { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java index 2aa883bbf..f4a653ce3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.earth2me.essentials.User; public class Commandeco extends EssentialsCommand @@ -14,7 +14,7 @@ public class Commandeco extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { @@ -34,45 +34,46 @@ public class Commandeco extends EssentialsCommand if (args[1].contentEquals("*")) { - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); + final User player = ess.getUser(onlinePlayer); switch (cmd) { case GIVE: - u.giveMoney(amount); + player.giveMoney(amount); break; case TAKE: - u.takeMoney(amount); + player.takeMoney(amount); break; case RESET: - u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); + player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); break; } } } else { - User u = getPlayer(server, args, 1, true); + final User player = getPlayer(server, args, 1, true); switch (cmd) { case GIVE: - u.giveMoney(amount, sender); + player.giveMoney(amount, sender); break; case TAKE: - u.takeMoney(amount, sender); + player.takeMoney(amount, sender); break; case RESET: - u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); + player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); break; } } } + private enum EcoCommands { GIVE, TAKE, RESET diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index a1a66854f..88524020d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -80,6 +80,7 @@ public class Commandessentials extends EssentialsCommand { int i = 0; + @Override public void run() { final String note = tune[i]; @@ -93,14 +94,14 @@ public class Commandessentials extends EssentialsCommand return; } Map noteBlocks = Commandessentials.this.noteBlocks; - for (Player player : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - Block block = noteBlocks.get(player); + final Block block = noteBlocks.get(onlinePlayer); if (block == null || block.getType() != Material.NOTE_BLOCK) { continue; } - player.playNote(block.getLocation(), (byte)0, noteMap.get(note)); + onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note)); } } }, 20, 2); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandext.java b/Essentials/src/com/earth2me/essentials/commands/Commandext.java index afb9fa3a6..44a464430 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandext.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandext.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,7 +15,7 @@ public class Commandext extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -26,7 +26,7 @@ public class Commandext 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) { @@ -38,12 +38,12 @@ public class Commandext extends EssentialsCommand extinguishPlayers(server, user, commandLabel); } - private void extinguishPlayers(Server server, CommandSender sender, String name) throws Exception + private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception { - for (Player p : server.matchPlayer(name)) + for (Player matchPlayer : server.matchPlayer(name)) { - p.setFireTicks(0); - sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName())); + matchPlayer.setFireTicks(0); + sender.sendMessage(Util.format("extinguishOthers", matchPlayer.getDisplayName())); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java index 19e7eddf1..0dc78474b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java @@ -8,7 +8,6 @@ import org.bukkit.util.Vector; public class Commandfireball extends EssentialsCommand { - public Commandfireball() { super("fireball"); @@ -17,7 +16,7 @@ public class Commandfireball extends EssentialsCommand @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - final Vector direction = user.getEyeLocation().getDirection().multiply(2); + 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/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index b19aa5d14..f8cfdf81c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -16,28 +16,43 @@ public class Commandgamemode extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - Player player; - if (args.length == 0) + if (args.length < 1) { - if (sender instanceof Player) - { - player = ess.getUser(sender); } - else - { - throw new NotEnoughArgumentsException(); - } + throw new NotEnoughArgumentsException(); } - else - { - player = server.getPlayer(args[0]); - if (player == null) - { - throw new Exception(Util.i18n("playerNotFound")); - } - } - player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); - sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName())); + + gamemodeOtherPlayers(server, sender, args[0]); } + + @Override + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception + { + if (args.length > 0 && user.isAuthorized("essentials.gamemode.others")) + { + gamemodeOtherPlayers(server, user, args[0]); + return; + } + + user.setGameMode(user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); + user.sendMessage(Util.format("gameMode", Util.i18n(user.getGameMode().toString().toLowerCase()), user.getDisplayName())); + } + + private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name) + { + for (Player matchPlayer : server.matchPlayer(name)) + { + final User player = ess.getUser(matchPlayer); + if (player.isHidden()) + { + continue; + } + + player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); + sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName())); + } + } + + } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java index 28164bd78..24de3b04c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java @@ -14,11 +14,12 @@ public class Commandgc extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { 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))); + sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024))); + for (World w : server.getWorlds()) { sender.sendMessage( diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java index 6f1fd7d6c..b79df021c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; import org.bukkit.Location; import org.bukkit.Server; -import com.earth2me.essentials.User; public class Commandgetpos extends EssentialsCommand @@ -13,9 +13,9 @@ public class Commandgetpos 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 { - Location coords = user.getLocation(); + final Location coords = user.getLocation(); user.sendMessage("§7X: " + coords.getBlockX() + " (+East <-> -West)"); user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)"); user.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)"); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 065b76d03..0bf45d900 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -18,16 +18,16 @@ public class Commandgive extends EssentialsCommand //TODO: move these messages to message file @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { throw new NotEnoughArgumentsException(); } - ItemStack stack = ess.getItemDb().get(args[1]); + final ItemStack stack = ess.getItemDb().get(args[1]); - String itemname = stack.getType().toString().toLowerCase().replace("_", ""); + final String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (sender instanceof Player && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender).isAuthorized("essentials.give.item-all") @@ -48,8 +48,8 @@ public class Commandgive extends EssentialsCommand throw new Exception(ChatColor.RED + "You can't give air."); } - User giveTo = getPlayer(server, args, 0); - String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); + final User giveTo = getPlayer(server, args, 0); + final String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); 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 d4c35e113..67f8b4086 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java @@ -15,7 +15,7 @@ public class Commandgod extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -26,7 +26,7 @@ public class Commandgod extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length > 0 && user.isAuthorized("essentials.god.others")) { @@ -37,18 +37,18 @@ public class Commandgod extends EssentialsCommand user.sendMessage(Util.format("godMode", (user.toggleGodModeEnabled()? Util.i18n("enabled") : Util.i18n("disabled")))); } - private void godOtherPlayers(Server server, CommandSender sender, String name) + private void godOtherPlayers(final Server server, final CommandSender sender, final String name) { - for (Player p : server.matchPlayer(name)) + for (Player matchPlayer : server.matchPlayer(name)) { - User u = ess.getUser(p); - if (u.isHidden()) + final User player = ess.getUser(matchPlayer); + if (player.isHidden()) { continue; } - boolean enabled = u.toggleGodModeEnabled(); - u.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled")))); - sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", p.getDisplayName()))); + final boolean enabled = player.toggleGodModeEnabled(); + player.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled")))); + sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", matchPlayer.getDisplayName()))); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java index 68de488af..89962b01d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.List; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandheal extends EssentialsCommand @@ -16,7 +16,7 @@ public class Commandheal 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 > 0 && user.isAuthorized("essentials.heal.others")) @@ -39,7 +39,7 @@ public class Commandheal extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -49,9 +49,9 @@ public class Commandheal extends EssentialsCommand healOtherPlayers(server, sender, args[0]); } - private void healOtherPlayers(Server server, CommandSender sender, String name) + private void healOtherPlayers(final Server server, final CommandSender sender, final String name) { - List players = server.matchPlayer(name); + final List players = server.matchPlayer(name); if (players.isEmpty()) { sender.sendMessage(Util.i18n("playerNotFound")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 8e99dc1ed..6420bb196 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -1,21 +1,21 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map.Entry; +import java.util.logging.Level; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.util.Map.Entry; -import java.util.logging.Level; public class Commandhelp extends EssentialsCommand @@ -30,6 +30,7 @@ public class Commandhelp extends EssentialsCommand super("help"); } + //TODO: Update to use new text file and command parser classes @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { @@ -100,6 +101,9 @@ public class Commandhelp extends EssentialsCommand while (bufferedReader.ready()) { final String line = bufferedReader.readLine(); + if (line == null) { + break; + } retval.add(line.replace('&', '§')); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java index 158b0d40b..2f92f07d3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.logging.Level; +import org.bukkit.Server; +import org.bukkit.entity.Player; public class Commandhelpop extends EssentialsCommand @@ -15,7 +15,7 @@ public class Commandhelpop 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) { @@ -24,14 +24,14 @@ public class Commandhelpop extends EssentialsCommand final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)); logger.log(Level.INFO, message); - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if (!u.isAuthorized("essentials.helpop.receive")) + final User player = ess.getUser(onlinePlayer); + if (!player.isAuthorized("essentials.helpop.receive")) { continue; } - u.sendMessage(message); + player.sendMessage(message); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 16b9fca2a..e6bbddbd4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.List; +import org.bukkit.Server; public class Commandhome extends EssentialsCommand @@ -15,11 +15,11 @@ public class Commandhome 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 { - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); - User u = user; + User player = user; String homeName = ""; String[] nameParts; if (args.length > 0) @@ -31,7 +31,7 @@ public class Commandhome extends EssentialsCommand } else { - u = getPlayer(server, nameParts[0].split(" "), 0, true); + player = getPlayer(server, nameParts[0].split(" "), 0, true); if (nameParts.length > 1) { homeName = nameParts[1]; @@ -40,22 +40,22 @@ public class Commandhome extends EssentialsCommand } try { - user.getTeleport().home(u, homeName.toLowerCase(), charge); + user.getTeleport().home(player, homeName.toLowerCase(), charge); } catch (NotEnoughArgumentsException e) { - List homes = u.getHomes(); - if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome()) + final List homes = player.getHomes(); + if (homes.isEmpty() && player.equals(user) && ess.getSettings().spawnIfNoHome()) { - user.getTeleport().respawn(ess.getSpawn(), charge); + user.getTeleport().respawn(ess.getSpawn(), charge); } else if (homes.isEmpty()) { - throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); + throw new Exception(player == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); } - else if (homes.size() == 1 && u.equals(user)) + else if (homes.size() == 1 && player.equals(user)) { - user.getTeleport().home(u, homes.get(0), charge); + user.getTeleport().home(player, homes.get(0), charge); } else { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java index 953bf742c..57c68105a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java @@ -14,36 +14,36 @@ public class Commandignore extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - User u; + User player; try { - u = getPlayer(server, args, 0); + player = getPlayer(server, args, 0); } catch(NoSuchFieldException ex) { - u = ess.getOfflineUser(args[0]); + player = ess.getOfflineUser(args[0]); } - if (u == null) + if (player == null) { throw new Exception(Util.i18n("playerNotFound")); } - String name = u.getName(); + final String name = player.getName(); if (user.isIgnoredPlayer(name)) { user.setIgnoredPlayer(name, false); - user.sendMessage(Util.format("unignorePlayer", u.getName())); + user.sendMessage(Util.format("unignorePlayer", player.getName())); } else { user.setIgnoredPlayer(name, true); - user.sendMessage(Util.format("ignorePlayer", u.getName())); + user.sendMessage(Util.format("ignorePlayer", player.getName())); } } - - + + } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java index 97dd71d35..2ae348696 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java @@ -1,17 +1,11 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.TextInput; +import com.earth2me.essentials.textreader.TextPager; import org.bukkit.Server; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; public class Commandinfo extends EssentialsCommand @@ -22,167 +16,11 @@ public class Commandinfo extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - String pageStr = args.length > 0 ? args[0].trim() : null; - - List lines = new ArrayList(); - List chapters = new ArrayList(); - Map bookmarks = new HashMap(); - File file = null; - if (sender instanceof Player) - { - User user = ess.getUser(sender); - file = new File(ess.getDataFolder(), "info_"+Util.sanitizeFileName(user.getName()) +".txt"); - if (!file.exists()) - { - file = new File(ess.getDataFolder(), "info_"+Util.sanitizeFileName(user.getGroup()) +".txt"); - } - } - if (file == null || !file.exists()) - { - file = new File(ess.getDataFolder(), "info.txt"); - } - if (file.exists()) - { - final BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); - try - { - int lineNumber = 0; - while (bufferedReader.ready()) - { - final String line = bufferedReader.readLine(); - if (line.length() > 0 && line.charAt(0) == '#') - { - bookmarks.put(line.substring(1).toLowerCase().replaceAll("&[0-9a-f]", ""), lineNumber); - chapters.add(line.substring(1).replace('&', '§')); - } - lines.add(line.replace('&', '§')); - lineNumber++; - } - } - finally - { - bufferedReader.close(); - } - } - else - { - file.createNewFile(); - throw new Exception(Util.i18n("infoFileDoesNotExist")); - } - - if (bookmarks.isEmpty()) - { - int page = 1; - try - { - page = Integer.parseInt(pageStr); - } - catch (Exception ex) - { - page = 1; - } - - int start = (page - 1) * 9; - int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); - - sender.sendMessage(Util.format("infoPages", page, pages )); - for (int i = start; i < lines.size() && i < start + 9; i++) - { - sender.sendMessage(lines.get(i)); - } - return; - } - - if (pageStr == null || pageStr.isEmpty() || pageStr.matches("[0-9]+")) - { - if (lines.get(0).startsWith("#")) - { - sender.sendMessage(Util.i18n("infoChapter")); - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (String string : chapters) - { - if (!first) - { - sb.append(", "); - } - first = false; - sb.append(string); - } - sender.sendMessage(sb.toString()); - return; - } - else - { - int page = 1; - try - { - page = Integer.parseInt(pageStr); - } - catch (Exception ex) - { - page = 1; - } - - int start = (page - 1) * 9; - int end; - for (end = 0; end < lines.size(); end++) - { - String line = lines.get(end); - if (line.startsWith("#")) - { - break; - } - } - int pages = end / 9 + (end % 9 > 0 ? 1 : 0); - - sender.sendMessage(Util.format("infoPages", page, pages )); - for (int i = start; i < end && i < start + 9; i++) - { - sender.sendMessage(lines.get(i)); - } - return; - } - } - - int chapterpage = 0; - if (args.length >= 2) - { - try - { - chapterpage = Integer.parseInt(args[1]) - 1; - } - catch (Exception ex) - { - chapterpage = 0; - } - } - - if (!bookmarks.containsKey(pageStr.toLowerCase())) - { - sender.sendMessage(Util.i18n("infoUnknownChapter")); - return; - } - int chapterstart = bookmarks.get(pageStr.toLowerCase()) + 1; - int chapterend; - for (chapterend = chapterstart; chapterend < lines.size(); chapterend++) - { - String line = lines.get(chapterend); - if (line.startsWith("#")) - { - break; - } - } - int start = chapterstart + chapterpage * 9; - int page = chapterpage + 1; - int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0); - - sender.sendMessage(Util.format("infoChapterPages", pageStr, page , pages)); - for (int i = start; i < chapterend && i < start + 9; i++) - { - sender.sendMessage(lines.get(i)); - } + final IText input = new TextInput(sender, "info", true, ess); + final IText output = new KeywordReplacer(input, sender, ess); + final TextPager pager = new TextPager(output); + pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, sender); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index 2a730b533..0decb00bf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -15,7 +15,7 @@ public class Commandinvsee extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1 && user.getSavedInventory() == null) @@ -40,7 +40,7 @@ public class Commandinvsee extends EssentialsCommand user.setSavedInventory(user.getInventory().getContents()); } ItemStack[] invUserStack = invUser.getInventory().getContents(); - int userStackLength = user.getInventory().getContents().length; + final int userStackLength = user.getInventory().getContents().length; if (invUserStack.length < userStackLength) { invUserStack = Arrays.copyOf(invUserStack, userStackLength); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 352ce18eb..35b3c09ae 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.inventory.ItemStack; @@ -15,15 +15,15 @@ public class Commanditem 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) { throw new NotEnoughArgumentsException(); } - ItemStack stack = ess.getItemDb().get(args[0]); + final ItemStack stack = ess.getItemDb().get(args[0]); - String itemname = stack.getType().toString().toLowerCase().replace("_", ""); + final String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) @@ -44,8 +44,8 @@ public class Commanditem extends EssentialsCommand throw new Exception(Util.format("cantSpawnItem", "Air")); } - String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); - user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName)); + final String displayName = stack.getType().toString().toLowerCase().replace('_', ' '); + user.sendMessage(Util.format("itemSpawn", stack.getAmount(), displayName)); 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 36eb633fc..c5473e08d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java @@ -13,7 +13,7 @@ public class Commandjails extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java index 5cdcbb2f2..41648a14f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.Trade; -import org.bukkit.Location; -import org.bukkit.Server; import com.earth2me.essentials.TargetBlock; +import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Location; +import org.bukkit.Server; public class Commandjump extends EssentialsCommand @@ -15,11 +15,12 @@ public class Commandjump extends EssentialsCommand super("jump"); } + //TODO: Update to use new target methods @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 { Location loc; - Location cloc = user.getLocation(); + final Location cloc = user.getLocation(); try { @@ -36,7 +37,7 @@ public class Commandjump extends EssentialsCommand throw new Exception(Util.i18n("jumpError"), ex); } - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); user.getTeleport().teleport(loc, charge); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index fd0d4a8e0..5e54424aa 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -14,30 +14,30 @@ public class Commandkick extends EssentialsCommand { super("kick"); } - + @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - - User player = getPlayer(server, args, 0); - if (player.isAuthorized("essentials.kick.exempt")) + + final User user = getPlayer(server, args, 0); + if (user.isAuthorized("essentials.kick.exempt")) { throw new Exception(Util.i18n("kickExempt")); } 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; - - for(Player p : server.getOnlinePlayers()) + user.kickPlayer(kickReason); + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; + + for(Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if(u.isAuthorized("essentials.kick.notify")) + User player = ess.getUser(onlinePlayer); + if(player.isAuthorized("essentials.kick.notify")) { - p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason)); + onlinePlayer.sendMessage(Util.format("playerKicked", senderName, user.getName(), kickReason)); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java index 8d36f50d5..bc294fe71 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java @@ -14,17 +14,17 @@ public class Commandkickall extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName())) + if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName())) { continue; } else { - p.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault")); + onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault")); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java index e976faa42..5f7650aed 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java @@ -15,24 +15,24 @@ public class Commandkill extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - for (Player p : server.matchPlayer(args[0])) + for (Player matchPlayer : server.matchPlayer(args[0])) { - final EntityDamageEvent ede = new EntityDamageEvent(p, sender instanceof Player && ((Player)sender).getName().equals(p.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000); + final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000); server.getPluginManager().callEvent(ede); if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force")) { continue; } - p.setHealth(0); - sender.sendMessage(Util.format("kill", p.getDisplayName())); + matchPlayer.setHealth(0); + sender.sendMessage(Util.format("kill", matchPlayer.getDisplayName())); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java index ae7963c5e..31515b1e7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java @@ -1,15 +1,11 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; -import java.util.GregorianCalendar; +import java.util.*; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.inventory.ItemStack; @@ -29,11 +25,11 @@ public class Commandkit extends EssentialsCommand { final Map kits = ess.getSettings().getKits(); final StringBuilder list = new StringBuilder(); - for (String k : kits.keySet()) + for (String kiteItem : kits.keySet()) { - if (user.isAuthorized("essentials.kit." + k.toLowerCase())) + if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase())) { - list.append(" ").append(k); + list.append(" ").append(kiteItem); } } if (list.length() > 0) @@ -74,9 +70,9 @@ public class Commandkit extends EssentialsCommand final Calendar c = new GregorianCalendar(); c.add(Calendar.SECOND, -(int)delay); c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0)); - + final long mintime = c.getTimeInMillis(); - + final Long lastTime = user.getKitTimestamp(kitName); if (lastTime == null || lastTime < mintime) { final Calendar now = new GregorianCalendar(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java index dc4387833..d2cc53b77 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java @@ -15,7 +15,7 @@ public class Commandlightning extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { User user = null; @@ -34,16 +34,16 @@ public class Commandlightning extends EssentialsCommand throw new Exception(Util.i18n("playerNotFound")); } - for (Player p : server.matchPlayer(args[0])) + for (Player matchPlayer : server.matchPlayer(args[0])) { - sender.sendMessage(Util.format("lightningUse", p.getDisplayName())); - p.getWorld().strikeLightning(p.getLocation()); - if (!ess.getUser(p).isGodModeEnabled()) { - p.setHealth(p.getHealth() < 5 ? 0 : p.getHealth() - 5); + sender.sendMessage(Util.format("lightningUse", matchPlayer.getDisplayName())); + matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation()); + if (!ess.getUser(matchPlayer).isGodModeEnabled()) { + matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5); } if (ess.getSettings().warnOnSmite()) { - p.sendMessage(Util.i18n("lightningSmited")); + matchPlayer.sendMessage(Util.i18n("lightningSmited")); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index 98066d7e7..feb92719d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -1,17 +1,12 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import java.util.*; +import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.bukkit.ChatColor; public class Commandlist extends EssentialsCommand @@ -22,7 +17,7 @@ public class Commandlist extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { boolean showhidden = false; if (sender instanceof Player) @@ -37,15 +32,15 @@ public class Commandlist extends EssentialsCommand showhidden = true; } int playerHidden = 0; - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - if (ess.getUser(p).isHidden()) + if (ess.getUser(onlinePlayer).isHidden()) { playerHidden++; } } //TODO: move these to messages file - StringBuilder online = new StringBuilder(); + final StringBuilder online = new StringBuilder(); online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden); if (showhidden && playerHidden > 0) { @@ -58,29 +53,29 @@ public class Commandlist extends EssentialsCommand if (ess.getSettings().getSortListByGroups()) { Map> sort = new HashMap>(); - for (Player p : server.getOnlinePlayers()) + for (Player OnlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if (u.isHidden() && !showhidden) + final User player = ess.getUser(OnlinePlayer); + if (player.isHidden() && !showhidden) { continue; } - String group = u.getGroup(); + final String group = player.getGroup(); List list = sort.get(group); if (list == null) { list = new ArrayList(); sort.put(group, list); } - list.add(u); + list.add(player); } - String[] groups = sort.keySet().toArray(new String[0]); + final String[] groups = sort.keySet().toArray(new String[0]); Arrays.sort(groups, String.CASE_INSENSITIVE_ORDER); for (String group : groups) { - StringBuilder groupString = new StringBuilder(); + final StringBuilder groupString = new StringBuilder(); groupString.append(group).append(": "); - List users = sort.get(group); + final List users = sort.get(group); Collections.sort(users); boolean first = true; for (User user : users) @@ -109,19 +104,19 @@ public class Commandlist extends EssentialsCommand } else { - List users = new ArrayList(); - for (Player p : server.getOnlinePlayers()) + final List users = new ArrayList(); + for (Player OnlinePlayer : server.getOnlinePlayers()) { - final User u = ess.getUser(p); - if (u.isHidden() && !showhidden) + final User player = ess.getUser(OnlinePlayer); + if (player.isHidden() && !showhidden) { continue; } - users.add(u); + users.add(player); } Collections.sort(users); - StringBuilder onlineUsers = new StringBuilder(); + final StringBuilder onlineUsers = new StringBuilder(); onlineUsers.append(Util.i18n("connectedPlayers")); boolean first = true; for (User user : users) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index ddc26aadc..3914c5a5d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; -import java.util.List; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.List; import org.bukkit.ChatColor; +import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -16,20 +16,21 @@ public class Commandmail extends EssentialsCommand super("mail"); } + //TODO: Tidy this up @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 && "read".equalsIgnoreCase(args[0])) { - List mail = user.getMails(); + final List mail = user.getMails(); if (mail.isEmpty()) { user.sendMessage(Util.i18n("noMail")); throw new NoChargeException(); } - for (String s : mail) + for (String messages : mail) { - user.sendMessage(s); + user.sendMessage(messages); } user.sendMessage(Util.i18n("mailClear")); return; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java index 779e78420..10f542e4a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandme extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java index c695338f6..5d2d6994a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java @@ -1,6 +1,9 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.TextInput; +import com.earth2me.essentials.textreader.TextPager; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -11,13 +14,13 @@ public class Commandmotd extends EssentialsCommand { super("motd"); } - + @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - for (String m : ess.getMotd(sender, Util.i18n("noMotd"))) - { - sender.sendMessage(m); - } + final IText input = new TextInput(sender, "motd", true, ess); + final IText output = new KeywordReplacer(input, sender, ess); + final TextPager pager = new TextPager(output); + pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, sender); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java index f14935648..5042af458 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java @@ -1,13 +1,13 @@ package com.earth2me.essentials.commands; -import java.util.List; -import org.bukkit.Server; -import org.bukkit.entity.Player; import com.earth2me.essentials.Console; import com.earth2me.essentials.IReplyTo; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.List; +import org.bukkit.Server; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandmsg extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index 1777c5b48..002bac7fb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; public class Commandmute extends EssentialsCommand @@ -14,15 +14,15 @@ public class Commandmute extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - User p = getPlayer(server, args, 0, true); - if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt")) + final User player = getPlayer(server, args, 0, true); + if (!player.isMuted() && player.isAuthorized("essentials.mute.exempt")) { throw new Exception(Util.i18n("muteExempt")); } @@ -32,15 +32,15 @@ public class Commandmute extends EssentialsCommand String time = getFinalArg(args, 1); muteTimestamp = Util.parseDateDiff(time, true); } - p.setMuteTimeout(muteTimestamp); - boolean muted = p.toggleMuted(); + player.setMuteTimeout(muteTimestamp); + final boolean muted = player.toggleMuted(); sender.sendMessage( muted ? (muteTimestamp > 0 - ? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp)) - : Util.format("mutedPlayer", p.getDisplayName())) - : Util.format("unmutedPlayer", p.getDisplayName())); - p.sendMessage( + ? Util.format("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp)) + : Util.format("mutedPlayer", player.getDisplayName())) + : Util.format("unmutedPlayer", player.getDisplayName())); + player.sendMessage( muted ? (muteTimestamp > 0 ? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp)) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java index 534547e34..e3e9d0b67 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; public class Commandnick extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java index 9be844996..8359da67a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; +import org.bukkit.entity.Player; public class Commandpay extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandping.java b/Essentials/src/com/earth2me/essentials/commands/Commandping.java index 1f4cdd3dc..de11adb7b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandping.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandping.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandping extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java index 115bb20ef..8f06086af 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java @@ -1,17 +1,12 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.DescParseTickFormat; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; +import org.bukkit.Server; import org.bukkit.World; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -120,8 +115,6 @@ public class Commandptime extends EssentialsCommand } } } - - return; } /** @@ -242,6 +235,7 @@ public class Commandptime extends EssentialsCommand class UserNameComparator implements Comparator { + @Override public int compare(User a, User b) { return a.getName().compareTo(b.getName()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java index daf83034a..6a864ce35 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -4,7 +4,7 @@ import com.earth2me.essentials.Console; import com.earth2me.essentials.IReplyTo; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; -import org.bukkit.*; +import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java index 5ed4ef9e6..291c5b93d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import org.bukkit.ChatColor; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandrealname extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index 26882ded4..9bbcd790d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -1,10 +1,6 @@ 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 com.earth2me.essentials.*; import java.util.ArrayList; import java.util.List; import org.bukkit.Material; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java index 39f7de68e..32cadf69e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java @@ -1,6 +1,9 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.TextInput; +import com.earth2me.essentials.textreader.TextPager; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -13,11 +16,11 @@ public class Commandrules extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception { - for (String m : ess.getLines(sender, "rules", Util.i18n("noRules"))) - { - sender.sendMessage(m); - } + final IText input = new TextInput(sender, "rules", true, ess); + final IText output = new KeywordReplacer(input, sender, ess); + final TextPager pager = new TextPager(output); + pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, sender); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index a8ef83dc0..e28ae8dd1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -1,12 +1,12 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.InventoryWorkaround; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.logging.Level; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.inventory.ItemStack; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index b59984f05..77b18aa31 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandsethome extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java index d9b0eac4d..aeac10d4b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandsetjail extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java index ccdacab57..1c8cb2caa 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; -import org.bukkit.Location; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Location; +import org.bukkit.Server; public class Commandsetwarp extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java index 086b1549d..a8889fc09 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; import org.bukkit.inventory.ItemStack; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index 3ea3aae40..49f2a67d1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -1,20 +1,15 @@ package com.earth2me.essentials.commands; -import org.bukkit.Location; -import org.bukkit.Server; -import com.earth2me.essentials.User; import com.earth2me.essentials.Mob; import com.earth2me.essentials.Mob.MobException; -import com.earth2me.essentials.TargetBlock; +import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.Random; import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Server; import org.bukkit.block.Block; -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; +import org.bukkit.entity.*; public class Commandspawnmob extends EssentialsCommand @@ -72,13 +67,9 @@ public class Commandspawnmob extends EssentialsCommand { throw new Exception(Util.i18n("unableToSpawnMob")); } - - int[] ignore = - { - 8, 9 - }; - Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock(); - if (block == null) + + final Block block = Util.getTarget(user).getBlock(); + if (block == null) { throw new Exception(Util.i18n("unableToSpawnMob")); } @@ -215,7 +206,7 @@ public class Commandspawnmob extends EssentialsCommand } if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed")) { - Wolf wolf = ((Wolf)spawned); + final Wolf wolf = ((Wolf)spawned); wolf.setTamed(true); wolf.setOwner(user); wolf.setSitting(true); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java index a7976e8a6..eb0934b6a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java @@ -31,10 +31,10 @@ public class Commandsudo extends EssentialsCommand //TODO: Translate this. sender.sendMessage("Running the command as " + user.getDisplayName()); - final PluginCommand pc = ess.getServer().getPluginCommand(command); - if (pc != null) + final PluginCommand execCommand = ess.getServer().getPluginCommand(command); + if (execCommand != null) { - pc.execute(user.getBase(), command, arguments); + execCommand.execute(user.getBase(), command, arguments); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java index e98a613ff..ec99dd712 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandsuicide extends EssentialsCommand @@ -13,7 +13,7 @@ public class Commandsuicide 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 { user.setHealth(0); user.sendMessage(Util.i18n("suicideMessage")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java index bc8442da4..eaabdaa68 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java @@ -2,10 +2,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; import com.earth2me.essentials.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -23,8 +23,8 @@ public class Commandtempban extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - final User player = getPlayer(server, args, 0, true); - if (player.getBase() instanceof OfflinePlayer) + final User user = getPlayer(server, args, 0, true); + if (user.getBase() instanceof OfflinePlayer) { if (sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.tempban.offline")) @@ -35,7 +35,7 @@ public class Commandtempban extends EssentialsCommand } else { - if (player.isAuthorized("essentials.tempban.exempt")) + if (user.isAuthorized("essentials.tempban.exempt")) { sender.sendMessage(Util.i18n("tempbanExempt")); return; @@ -45,18 +45,18 @@ public class Commandtempban extends EssentialsCommand final long banTimestamp = Util.parseDateDiff(time, true); final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp)); - player.setBanReason(banReason); - player.setBanTimeout(banTimestamp); - player.setBanned(true); - player.kickPlayer(banReason); - String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; + user.setBanReason(banReason); + user.setBanTimeout(banTimestamp); + user.setBanned(true); + user.kickPlayer(banReason); + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - for(Player p : server.getOnlinePlayers()) + for(Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if(u.isAuthorized("essentials.ban.notify")) + final User player = ess.getUser(onlinePlayer); + if(player.isAuthorized("essentials.ban.notify")) { - p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason)); + onlinePlayer.sendMessage(Util.format("playerBanned", senderName, user.getName(), banReason)); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java index 34f5c3fed..678eebafd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java @@ -14,15 +14,15 @@ public class Commandthunder 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) { throw new NotEnoughArgumentsException(); } - World world = user.getWorld(); - boolean setThunder = args[0].equalsIgnoreCase("true"); + final World world = user.getWorld(); + final boolean setThunder = args[0].equalsIgnoreCase("true"); if (args.length > 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index 687396f53..30ecaaf54 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -1,12 +1,12 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.DescParseTickFormat; -import org.bukkit.Server; -import org.bukkit.World; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.*; +import org.bukkit.Server; +import org.bukkit.World; +import org.bukkit.command.CommandSender; public class Commandtime extends EssentialsCommand @@ -58,11 +58,11 @@ public class Commandtime extends EssentialsCommand /** * Used to get the time and inform */ - private void getWorldsTime(CommandSender sender, Collection worlds) + private void getWorldsTime(final CommandSender sender, final Collection worlds) { if (worlds.size() == 1) { - Iterator iter = worlds.iterator(); + final Iterator iter = worlds.iterator(); sender.sendMessage(DescParseTickFormat.format(iter.next().getTime())); return; } @@ -71,13 +71,12 @@ public class Commandtime extends EssentialsCommand { sender.sendMessage(Util.format("timeCurrentWorld", world.getName(), DescParseTickFormat.format(world.getTime()))); } - return; } /** * Used to set the time and inform of the change */ - private void setWorldsTime(CommandSender sender, Collection worlds, long ticks) + private void setWorldsTime(final CommandSender sender, final Collection worlds, final long ticks) { // Update the time for (World world : worlds) @@ -87,35 +86,31 @@ public class Commandtime extends EssentialsCommand world.setTime(time + 24000 + ticks); } - // Inform the sender of the change - //sender.sendMessage(""); - - StringBuilder msg = new StringBuilder(); - boolean first = true; + final StringBuilder output = new StringBuilder(); for (World world : worlds) { - if (msg.length() > 0) + if (output.length() > 0) { - msg.append(", "); + output.append(", "); } - msg.append(world.getName()); + output.append(world.getName()); } - sender.sendMessage(Util.format("timeWorldSet", DescParseTickFormat.format(ticks), msg.toString())); + sender.sendMessage(Util.format("timeWorldSet", DescParseTickFormat.format(ticks), output.toString())); } /** * Used to parse an argument of the type "world(s) selector" */ - private Set getWorlds(Server server, CommandSender sender, String selector) throws Exception + private Set getWorlds(final Server server, final CommandSender sender, final String selector) throws Exception { - Set worlds = new TreeSet(new WorldNameComparator()); + final Set worlds = new TreeSet(new WorldNameComparator()); // If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user. if (selector == null) { - User user = ess.getUser(sender); + final User user = ess.getUser(sender); if (user == null) { worlds.addAll(server.getWorlds()); @@ -128,7 +123,7 @@ public class Commandtime extends EssentialsCommand } // Try to find the world with name = selector - World world = server.getWorld(selector); + final World world = server.getWorld(selector); if (world != null) { worlds.add(world); @@ -151,7 +146,8 @@ public class Commandtime extends EssentialsCommand class WorldNameComparator implements Comparator { - public int compare(World a, World b) + @Override + public int compare(final World a, final World b) { return a.getName().compareTo(b.getName()); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 625a375d8..61edd2054 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -16,18 +16,18 @@ public class Commandtogglejail extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - User p = getPlayer(server, args, 0, true); + final User player = getPlayer(server, args, 0, true); - if (args.length >= 2 && !p.isJailed()) + if (args.length >= 2 && !player.isJailed()) { - if (p.getBase() instanceof OfflinePlayer) + if (player.getBase() instanceof OfflinePlayer) { if (sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.togglejail.offline")) @@ -38,68 +38,68 @@ public class Commandtogglejail extends EssentialsCommand } else { - if (p.isAuthorized("essentials.jail.exempt")) + if (player.isAuthorized("essentials.jail.exempt")) { sender.sendMessage(Util.i18n("mayNotJail")); return; } } - if (!(p.getBase() instanceof OfflinePlayer)) + if (!(player.getBase() instanceof OfflinePlayer)) { - ess.getJail().sendToJail(p, args[1]); + ess.getJail().sendToJail(player, args[1]); } else { // Check if jail exists ess.getJail().getJail(args[1]); } - p.setJailed(true); - p.sendMessage(Util.i18n("userJailed")); - p.setJail(null); - p.setJail(args[1]); + player.setJailed(true); + player.sendMessage(Util.i18n("userJailed")); + player.setJail(null); + player.setJail(args[1]); long timeDiff = 0; if (args.length > 2) { - String time = getFinalArg(args, 2); + final String time = getFinalArg(args, 2); timeDiff = Util.parseDateDiff(time, true); - p.setJailTimeout(timeDiff); + player.setJailTimeout(timeDiff); } sender.sendMessage((timeDiff > 0 - ? Util.format("playerJailedFor", p.getName(), Util.formatDateDiff(timeDiff)) - : Util.format("playerJailed", p.getName()))); + ? Util.format("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff)) + : Util.format("playerJailed", player.getName()))); return; } - if (args.length >= 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail())) + if (args.length >= 2 && player.isJailed() && !args[1].equalsIgnoreCase(player.getJail())) { - sender.sendMessage(Util.format("jailAlreadyIncarcerated", p.getJail())); + sender.sendMessage(Util.format("jailAlreadyIncarcerated", player.getJail())); return; } - if (args.length >= 2 && p.isJailed() && args[1].equalsIgnoreCase(p.getJail())) + if (args.length >= 2 && player.isJailed() && args[1].equalsIgnoreCase(player.getJail())) { - String time = getFinalArg(args, 2); - long timeDiff = Util.parseDateDiff(time, true); - p.setJailTimeout(timeDiff); + final String time = getFinalArg(args, 2); + final long timeDiff = Util.parseDateDiff(time, true); + player.setJailTimeout(timeDiff); sender.sendMessage(Util.format("jailSentenceExtended", Util.formatDateDiff(timeDiff))); return; } - if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase(p.getJail()))) + if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase(player.getJail()))) { - if (!p.isJailed()) + if (!player.isJailed()) { throw new NotEnoughArgumentsException(); } - p.setJailed(false); - p.setJailTimeout(0); - p.sendMessage(Util.format("jailReleasedPlayerNotify")); - p.setJail(null); - if (!(p.getBase() instanceof OfflinePlayer)) + player.setJailed(false); + player.setJailTimeout(0); + player.sendMessage(Util.format("jailReleasedPlayerNotify")); + player.setJail(null); + if (!(player.getBase() instanceof OfflinePlayer)) { - p.getTeleport().back(); + player.getTeleport().back(); } - sender.sendMessage(Util.format("jailReleased", p.getName())); + sender.sendMessage(Util.format("jailReleased", player.getName())); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java index ee5bfbe45..99f665184 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; -import org.bukkit.Location; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Location; +import org.bukkit.Server; public class Commandtop extends EssentialsCommand @@ -15,11 +15,11 @@ public class Commandtop 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 { - int topX = user.getLocation().getBlockX(); - int topZ = user.getLocation().getBlockZ(); - int topY = user.getWorld().getHighestBlockYAt(topX, topZ); + final int topX = user.getLocation().getBlockX(); + final int topZ = user.getLocation().getBlockZ(); + final int topY = user.getWorld().getHighestBlockYAt(topX, topZ); 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 480fb6153..c93f05a29 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.Trade; import com.earth2me.essentials.Console; -import org.bukkit.Server; +import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -16,7 +16,7 @@ public class Commandtp 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 { switch (args.length) { @@ -24,25 +24,25 @@ public class Commandtp extends EssentialsCommand throw new NotEnoughArgumentsException(); case 1: - User p = getPlayer(server, args, 0); - if (!p.isTeleportEnabled()) + final User player = getPlayer(server, args, 0); + if (!player.isTeleportEnabled()) { - throw new Exception(Util.format("teleportDisabled", p.getDisplayName())); + throw new Exception(Util.format("teleportDisabled", player.getDisplayName())); } user.sendMessage(Util.i18n("teleporting")); - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); - user.getTeleport().teleport(p, charge); + user.getTeleport().teleport(player, charge); throw new NoChargeException(); - case 2: + default: if (!user.isAuthorized("essentials.tpohere")) { throw new Exception("You need access to /tpohere to teleport other players."); } user.sendMessage(Util.i18n("teleporting")); - User target = getPlayer(server, args, 0); - User toPlayer = getPlayer(server, args, 1); + final User target = getPlayer(server, args, 0); + final User toPlayer = getPlayer(server, args, 1); target.getTeleport().now(toPlayer, false); target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName())); break; @@ -50,7 +50,7 @@ public class Commandtp extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { @@ -58,10 +58,9 @@ public class Commandtp extends EssentialsCommand } sender.sendMessage(Util.i18n("teleporting")); - User target = getPlayer(server, args, 0); - User toPlayer = getPlayer(server, args, 1); + final User target = getPlayer(server, args, 0); + final User toPlayer = getPlayer(server, args, 1); target.getTeleport().now(toPlayer, false); target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName())); - return; } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java index 32cbe3bd9..c9f41f4d8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtpa extends EssentialsCommand @@ -20,18 +20,18 @@ public class Commandtpa extends EssentialsCommand throw new NotEnoughArgumentsException(); } - User p = getPlayer(server, args, 0); - if (!p.isTeleportEnabled()) + User player = getPlayer(server, args, 0); + if (!player.isTeleportEnabled()) { - throw new Exception(Util.format("teleportDisabled", p.getDisplayName())); + throw new Exception(Util.format("teleportDisabled", player.getDisplayName())); } - if (!p.isIgnoredPlayer(user.getName())) + if (!player.isIgnoredPlayer(user.getName())) { - p.requestTeleport(user, false); - p.sendMessage(Util.format("teleportRequest", user.getDisplayName())); - p.sendMessage(Util.i18n("typeTpaccept")); - p.sendMessage(Util.i18n("typeTpdeny")); + player.requestTeleport(user, false); + player.sendMessage(Util.format("teleportRequest", user.getDisplayName())); + player.sendMessage(Util.i18n("typeTpaccept")); + player.sendMessage(Util.i18n("typeTpdeny")); } - user.sendMessage(Util.format("requestSent", p.getDisplayName())); + user.sendMessage(Util.format("requestSent", player.getDisplayName())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java index 97897852f..59d66da3e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,7 +15,7 @@ public class Commandtpaall extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -27,29 +27,29 @@ public class Commandtpaall extends EssentialsCommand throw new NotEnoughArgumentsException(); } - User p = getPlayer(server, args, 0); - teleportAAllPlayers(server, sender, p); + final User player = getPlayer(server, args, 0); + teleportAAllPlayers(server, sender, player); } - private void teleportAAllPlayers(Server server, CommandSender sender, User p) + private void teleportAAllPlayers(final Server server, final CommandSender sender, final User user) { sender.sendMessage(Util.i18n("teleportAAll")); - for (Player player : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(player); - if (p == u) + final User player = ess.getUser(onlinePlayer); + if (user == player) { continue; } - if (!u.isTeleportEnabled()) + if (!player.isTeleportEnabled()) { continue; } try { - u.requestTeleport(p, true); - u.sendMessage(Util.format("teleportHereRequest", p.getDisplayName())); - u.sendMessage(Util.i18n("typeTpaccept")); + player.requestTeleport(user, true); + player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName())); + player.sendMessage(Util.i18n("typeTpaccept")); } catch (Exception ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index fd9eeaa84..350640087 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -2,9 +2,9 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.Trade; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtpaccept extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java index 935721345..3f120037b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtpahere extends EssentialsCommand @@ -13,21 +13,21 @@ public class Commandtpahere 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) { throw new NotEnoughArgumentsException(); } - User p = getPlayer(server, args, 0); - if (!p.isTeleportEnabled()) + final User player = getPlayer(server, args, 0); + if (!player.isTeleportEnabled()) { - throw new Exception(Util.format("teleportDisabled", p.getDisplayName())); + throw new Exception(Util.format("teleportDisabled", player.getDisplayName())); } - p.requestTeleport(user, true); - p.sendMessage(Util.format("teleportHereRequest", user.getDisplayName())); - p.sendMessage(Util.i18n("typeTpaccept")); - user.sendMessage(Util.format("requestSent", p.getDisplayName())); + player.requestTeleport(user, true); + player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName())); + player.sendMessage(Util.i18n("typeTpaccept")); + user.sendMessage(Util.format("requestSent", player.getDisplayName())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java index 1cb6321ea..a9ccb91e3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,7 +15,7 @@ public class Commandtpall extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -27,23 +27,23 @@ public class Commandtpall extends EssentialsCommand throw new NotEnoughArgumentsException(); } - User p = getPlayer(server, args, 0); - teleportAllPlayers(server, sender, p); + final User player = getPlayer(server, args, 0); + teleportAllPlayers(server, sender, player); } - private void teleportAllPlayers(Server server, CommandSender sender, User p) + private void teleportAllPlayers(Server server, CommandSender sender, User user) { sender.sendMessage(Util.i18n("teleportAll")); - for (Player player : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(player); - if (p == u) + final User player = ess.getUser(onlinePlayer); + if (user == player) { continue; } try { - u.getTeleport().now(p, false); + player.getTeleport().now(user, false); } catch (Exception ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java index 5d7764ae6..b8de959ee 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtpdeny extends EssentialsCommand @@ -13,16 +13,16 @@ public class Commandtpdeny 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 { - User p = user.getTeleportRequest(); - if (p == null) + final User player = user.getTeleportRequest(); + if (player == null) { throw new Exception(Util.i18n("noPendingRequest")); } user.sendMessage(Util.i18n("requestDenied")); - p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName())); + player.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName())); user.requestTeleport(null, false); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java index bba8d8743..121e06c2a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtphere extends EssentialsCommand @@ -14,16 +14,16 @@ public class Commandtphere 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 { - User p = getPlayer(server, args, 0); - if (!p.isTeleportEnabled()) + final User player = getPlayer(server, args, 0); + if (!player.isTeleportEnabled()) { - throw new Exception(Util.format("teleportDisabled", p.getDisplayName())); + throw new Exception(Util.format("teleportDisabled", player.getDisplayName())); } - p.getTeleport().teleport(user, new Trade(this.getName(), ess)); + player.getTeleport().teleport(user, new Trade(this.getName(), ess)); user.sendMessage(Util.i18n("teleporting")); - p.sendMessage(Util.i18n("teleporting")); + player.sendMessage(Util.i18n("teleporting")); throw new NoChargeException(); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java index 5a4e082e0..2411bae6e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.OfflinePlayer; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtpo extends EssentialsCommand @@ -14,7 +14,7 @@ public class Commandtpo 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) { @@ -22,17 +22,17 @@ public class Commandtpo extends EssentialsCommand } //Just basically the old tp command - User p = getPlayer(server, args, 0, true); + final User player = getPlayer(server, args, 0, true); // Check if user is offline - if (p.getBase() instanceof OfflinePlayer) + if (player.getBase() instanceof OfflinePlayer) { throw new NoSuchFieldException(Util.i18n("playerNotFound")); } // Verify permission - if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden")) + if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden")) { - user.getTeleport().now(p, false); + user.getTeleport().now(player, false); user.sendMessage(Util.i18n("teleporting")); } else diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java index 7af39854f..2e58ae3a0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.OfflinePlayer; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtpohere extends EssentialsCommand @@ -14,7 +14,7 @@ public class Commandtpohere 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) { @@ -22,18 +22,18 @@ public class Commandtpohere extends EssentialsCommand } //Just basically the old tphere command - User p = getPlayer(server, args, 0, true); + final User player = getPlayer(server, args, 0, true); // Check if user is offline - if (p.getBase() instanceof OfflinePlayer) + if (player.getBase() instanceof OfflinePlayer) { throw new NoSuchFieldException(Util.i18n("playerNotFound")); } // Verify permission - if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden")) + if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden")) { - p.getTeleport().now(user, false); + player.getTeleport().now(user, false); user.sendMessage(Util.i18n("teleporting")); } else diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java index ce7c369e4..5b2ee2890 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; -import org.bukkit.Location; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Location; +import org.bukkit.Server; public class Commandtppos extends EssentialsCommand @@ -15,27 +15,27 @@ public class Commandtppos 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 < 3) { throw new NotEnoughArgumentsException(); } - int x = Integer.parseInt(args[0]); - int y = Integer.parseInt(args[1]); - int z = Integer.parseInt(args[2]); - Location l = new Location(user.getWorld(), x, y, z); + final int x = Integer.parseInt(args[0]); + final int y = Integer.parseInt(args[1]); + final int z = Integer.parseInt(args[2]); + final Location location = new Location(user.getWorld(), x, y, z); if (args.length > 3) { - l.setYaw(Float.parseFloat(args[3])); + location.setYaw(Float.parseFloat(args[3])); } if (args.length > 4) { - l.setPitch(Float.parseFloat(args[4])); + location.setPitch(Float.parseFloat(args[4])); } - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); user.sendMessage(Util.i18n("teleporting")); - user.getTeleport().teleport(l, charge); + user.getTeleport().teleport(location, charge); throw new NoChargeException(); } } \ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java index f880c5d34..c42862514 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Server; public class Commandtptoggle extends EssentialsCommand @@ -13,7 +13,7 @@ public class Commandtptoggle 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 { user.sendMessage(user.toggleTeleportEnabled() ? Util.i18n("teleportationEnabled") diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java index 26bc9a8ee..bec23d834 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.TreeType; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; public class Commandtree extends EssentialsCommand @@ -15,7 +15,7 @@ public class Commandtree 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 { TreeType tree; if (args.length < 1) @@ -39,10 +39,6 @@ public class Commandtree extends EssentialsCommand throw new NotEnoughArgumentsException(); } - final int[] ignore = - { - 8, 9 - }; final Location loc = Util.getTarget(user); final Location safeLocation = Util.getSafeDestination(loc); final boolean success = user.getWorld().generateTree(safeLocation, tree); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java index c36fde0e7..ac6818c80 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java @@ -23,8 +23,8 @@ public class Commandunban extends EssentialsCommand try { - final User u = getPlayer(server, args, 0, true); - u.setBanned(false); + final User player = getPlayer(server, args, 0, true); + player.setBanned(false); sender.sendMessage(Util.i18n("unbannedPlayer")); } catch (NoSuchFieldException e) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index cebbcaf8c..93e6235dc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -17,7 +17,7 @@ public class Commandunlimited 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,17 +33,17 @@ public class Commandunlimited extends EssentialsCommand if (args[0].equalsIgnoreCase("list")) { - String list = getList(target); + final String list = getList(target); user.sendMessage(list); } else if (args[0].equalsIgnoreCase("clear")) { - List itemList = target.getUnlimited(); + final List itemList = target.getUnlimited(); int index = 0; while (itemList.size() > index) { - Integer item = itemList.get(index); + final Integer item = itemList.get(index); if (toggleUnlimited(user, target, item.toString()) == false) { index++; @@ -56,36 +56,36 @@ public class Commandunlimited extends EssentialsCommand } } - private String getList(User target) + private String getList(final User target) { - StringBuilder sb = new StringBuilder(); - sb.append(Util.i18n("unlimitedItems")).append(" "); + final StringBuilder output = new StringBuilder(); + output.append(Util.i18n("unlimitedItems")).append(" "); boolean first = true; - List items = target.getUnlimited(); + final List items = target.getUnlimited(); if (items.isEmpty()) { - sb.append(Util.i18n("none")); + output.append(Util.i18n("none")); } for (Integer integer : items) { if (!first) { - sb.append(", "); + output.append(", "); } first = false; - String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", ""); - sb.append(matname); + final String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", ""); + output.append(matname); } - return sb.toString(); + return output.toString(); } - private Boolean toggleUnlimited(User user, User target, String item) throws Exception + private Boolean toggleUnlimited(final User user, final User target, final String item) throws Exception { - ItemStack stack = ess.getItemDb().get(item, 1); + final ItemStack stack = ess.getItemDb().get(item, 1); stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2)); - String itemname = stack.getType().toString().toLowerCase().replace("_", ""); + final String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (ess.getSettings().permissionBasedItemSpawn() && (!user.isAuthorized("essentials.unlimited.item-all") && !user.isAuthorized("essentials.unlimited.item-" + itemname) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 9b8ab28f3..81207b740 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -1,13 +1,13 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; -import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import com.earth2me.essentials.Warps; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -21,7 +21,7 @@ public class Commandwarp 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 == 0 || args[0].matches("[0-9]+")) { @@ -50,11 +50,12 @@ public class Commandwarp extends EssentialsCommand } } - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + @Override + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2 || args[0].matches("[0-9]+")) { - warpList(null, args); + warpList(sender, args); throw new NoChargeException(); } User otherUser = ess.getUser(server.getPlayer(args[1])); @@ -67,22 +68,22 @@ public class Commandwarp extends EssentialsCommand } - private void warpList(User user, String[] args) throws Exception + private void warpList(final CommandSender sender, final String[] args) throws Exception { - Warps warps = ess.getWarps(); + final Warps warps = ess.getWarps(); if (warps.isEmpty()) { throw new Exception(Util.i18n("noWarpsDefined")); } final List warpNameList = new ArrayList(warps.getWarpNames()); - if (user != null) + if (sender instanceof User) { final Iterator iterator = warpNameList.iterator(); while (iterator.hasNext()) { final String warpName = iterator.next(); - if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName)) + if (ess.getSettings().getPerWarpPermission() && !((User)sender).isAuthorized("essentials.warp." + warpName)) { iterator.remove(); } @@ -99,17 +100,17 @@ public class Commandwarp extends EssentialsCommand if (warpNameList.size() > WARPS_PER_PAGE) { - user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); - user.sendMessage(warpList); + sender.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); + sender.sendMessage(warpList); } else { - user.sendMessage(Util.format("warps", warpList)); + sender.sendMessage(Util.format("warps", warpList)); } } - private void warpUser(User user, String name) throws Exception + private void warpUser(final User user, final String name) throws Exception { - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); if (ess.getSettings().getPerWarpPermission()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java index 9603e9f72..2af6f8abf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java @@ -13,17 +13,19 @@ public class Commandweather extends EssentialsCommand { super("weather"); } + + //TODO: Remove duplication @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) { throw new NotEnoughArgumentsException(); } - boolean isStorm = args[0].equalsIgnoreCase("storm"); - World world = user.getWorld(); + final boolean isStorm = args[0].equalsIgnoreCase("storm"); + final World world = user.getWorld(); if (args.length > 1) { @@ -32,7 +34,6 @@ public class Commandweather extends EssentialsCommand user.sendMessage(isStorm ? Util.format("weatherStormFor", world.getName(), args[1]) : Util.format("weatherSunFor", world.getName(), args[1])); - return; } else { @@ -40,20 +41,19 @@ public class Commandweather extends EssentialsCommand user.sendMessage(isStorm ? Util.format("weatherStorm", world.getName()) : Util.format("weatherSun", world.getName())); - return; } } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) //running from console means inserting a world arg before other args { throw new Exception("When running from console, usage is: /" + commandLabel + " [duration]"); } - boolean isStorm = args[1].equalsIgnoreCase("storm"); - World world = server.getWorld(args[0]); + final boolean isStorm = args[1].equalsIgnoreCase("storm"); + final World world = server.getWorld(args[0]); if (world == null) { throw new Exception("World named " + args[0] + " not found!"); @@ -66,7 +66,6 @@ public class Commandweather extends EssentialsCommand sender.sendMessage(isStorm ? Util.format("weatherStormFor", world.getName(), args[2]) : Util.format("weatherSunFor", world.getName(), args[2])); - return; } else { @@ -74,7 +73,6 @@ public class Commandweather extends EssentialsCommand sender.sendMessage(isStorm ? Util.format("weatherStorm", world.getName()) : Util.format("weatherSun", world.getName())); - return; } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 008f8ac00..b8081d04e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import org.bukkit.ChatColor; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandwhois extends EssentialsCommand @@ -16,7 +16,7 @@ public class Commandwhois extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -34,38 +34,38 @@ public class Commandwhois extends EssentialsCommand { showhidden = true; } - String whois = args[0].toLowerCase(); - int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length(); - for (Player p : server.getOnlinePlayers()) + final String whois = args[0].toLowerCase(); + final int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length(); + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if (u.isHidden() && !showhidden) + final User user = ess.getUser(onlinePlayer); + if (user.isHidden() && !showhidden) { continue; } - String dn = ChatColor.stripColor(u.getNick()); - if (!whois.equalsIgnoreCase(dn) - && !whois.equalsIgnoreCase(dn.substring(prefixLength)) - && !whois.equalsIgnoreCase(u.getName())) + final String displayName = ChatColor.stripColor(user.getNick()); + if (!whois.equalsIgnoreCase(displayName) + && !whois.equalsIgnoreCase(displayName.substring(prefixLength)) + && !whois.equalsIgnoreCase(user.getName())) { continue; } sender.sendMessage(""); - sender.sendMessage(Util.format("whoisIs", u.getDisplayName(), u.getName())); - sender.sendMessage(Util.format("whoisHealth", u.getHealth())); - sender.sendMessage(Util.format("whoisOP", (u.isOp() ? Util.i18n("true") : Util.i18n("false")))); - sender.sendMessage(Util.format("whoisGod", (u.isGodModeEnabled() ? Util.i18n("true") : Util.i18n("false")))); - sender.sendMessage(Util.format("whoisGamemode", Util.i18n(u.getGameMode().toString().toLowerCase()))); - sender.sendMessage(Util.format("whoisLocation", u.getLocation().getWorld().getName(), u.getLocation().getBlockX(), u.getLocation().getBlockY(), u.getLocation().getBlockZ())); + sender.sendMessage(Util.format("whoisIs", user.getDisplayName(), user.getName())); + sender.sendMessage(Util.format("whoisHealth", user.getHealth())); + sender.sendMessage(Util.format("whoisOP", (user.isOp() ? Util.i18n("true") : Util.i18n("false")))); + sender.sendMessage(Util.format("whoisGod", (user.isGodModeEnabled() ? Util.i18n("true") : Util.i18n("false")))); + sender.sendMessage(Util.format("whoisGamemode", Util.i18n(user.getGameMode().toString().toLowerCase()))); + sender.sendMessage(Util.format("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ())); if (!ess.getSettings().isEcoDisabled()) { - sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess))); + sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(user.getMoney(), ess))); } - sender.sendMessage(u.isAfk() + sender.sendMessage(user.isAfk() ? Util.i18n("whoisStatusAway") : Util.i18n("whoisStatusAvailable")); - sender.sendMessage(Util.format("whoisIPAddress", u.getAddress().getAddress().toString())); - final String location = u.getGeoLocation(); + sender.sendMessage(Util.format("whoisIPAddress", user.getAddress().getAddress().toString())); + final String location = user.getGeoLocation(); if (location != null && (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true)) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index 557f46dbf..ba742188e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -1,12 +1,12 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Trade; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.List; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; public class Commandworld extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index 2a7e107bc..d88fb4e68 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; + import com.earth2me.essentials.User; import com.earth2me.essentials.Util; - +import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; @@ -15,15 +15,16 @@ public class Commandworth extends EssentialsCommand super("worth"); } + //TODO: Remove duplication @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 { - ItemStack is = user.getInventory().getItemInHand(); - int amount = is.getAmount(); + ItemStack iStack = user.getInventory().getItemInHand(); + int amount = iStack.getAmount(); if (args.length > 0) { - is = ess.getItemDb().get(args[0]); + iStack = ess.getItemDb().get(args[0]); } try @@ -35,40 +36,40 @@ public class Commandworth extends EssentialsCommand } catch (NumberFormatException ex) { - amount = is.getType().getMaxStackSize(); + amount = iStack.getType().getMaxStackSize(); } - is.setAmount(amount); - double worth = ess.getWorth().getPrice(is); + iStack.setAmount(amount); + final double worth = ess.getWorth().getPrice(iStack); if (Double.isNaN(worth)) { throw new Exception(Util.i18n("itemCannotBeSold")); } - user.sendMessage(is.getDurability() != 0 + user.sendMessage(iStack.getDurability() != 0 ? Util.format("worthMeta", - is.getType().toString().toLowerCase().replace("_", ""), - is.getDurability(), + iStack.getType().toString().toLowerCase().replace("_", ""), + iStack.getDurability(), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)) : Util.format("worth", - is.getType().toString().toLowerCase().replace("_", ""), + iStack.getType().toString().toLowerCase().replace("_", ""), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess))); } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - ItemStack is = ess.getItemDb().get(args[0]); - int amount = is.getAmount(); + ItemStack iStack = ess.getItemDb().get(args[0]); + int amount = iStack.getAmount(); try { @@ -79,25 +80,25 @@ public class Commandworth extends EssentialsCommand } catch (NumberFormatException ex) { - amount = is.getType().getMaxStackSize(); + amount = iStack.getType().getMaxStackSize(); } - is.setAmount(amount); - double worth = ess.getWorth().getPrice(is); + iStack.setAmount(amount); + final double worth = ess.getWorth().getPrice(iStack); if (Double.isNaN(worth)) { throw new Exception(Util.i18n("itemCannotBeSold")); } - sender.sendMessage(is.getDurability() != 0 + sender.sendMessage(iStack.getDurability() != 0 ? Util.format("worthMeta", - is.getType().toString().toLowerCase().replace("_", ""), - is.getDurability(), + iStack.getType().toString().toLowerCase().replace("_", ""), + iStack.getDurability(), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)) : Util.format("worth", - is.getType().toString().toLowerCase().replace("_", ""), + iStack.getType().toString().toLowerCase().replace("_", ""), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess))); diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java index 58da18c21..f52a06e29 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java @@ -1,17 +1,12 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.Trade; +import com.earth2me.essentials.*; import java.util.List; +import java.util.logging.Logger; import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.OfflinePlayer; import org.bukkit.entity.Player; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.util.logging.Logger; public abstract class EssentialsCommand implements IEssentialsCommand @@ -25,11 +20,13 @@ public abstract class EssentialsCommand implements IEssentialsCommand this.name = name; } + @Override public void setEssentials(final IEssentials ess) { this.ess = ess; } + @Override public String getName() { return name; diff --git a/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java index a5192ba10..870797453 100644 --- a/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java @@ -2,9 +2,9 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; +import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.Server; public interface IEssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java index b30a7c0c7..232cb04b4 100644 --- a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.perm; import de.bananaco.permissions.Permissions; +import de.bananaco.permissions.info.InfoReader; import de.bananaco.permissions.interfaces.PermissionSet; import de.bananaco.permissions.worlds.WorldPermissionsManager; -import de.bananaco.permissions.info.InfoReader; import java.util.List; import org.bukkit.entity.Player; diff --git a/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java b/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java index 20b3806e0..d9da43ae8 100644 --- a/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java @@ -1,12 +1,12 @@ package com.earth2me.essentials.perm; + import java.util.Arrays; import java.util.List; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; public class GroupManagerHandler implements IPermissionsHandler diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java index 34acf9837..dc9a23e13 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.register.payment; + import java.util.HashSet; import java.util.Set; - import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java index bc3893d5e..4c4b2721a 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java @@ -1,7 +1,7 @@ package com.earth2me.essentials.register.payment.methods; -import com.earth2me.essentials.register.payment.Method; +import com.earth2me.essentials.register.payment.Method; import cosine.boseconomy.BOSEconomy; import org.bukkit.plugin.Plugin; @@ -18,26 +18,31 @@ public class BOSE6 implements Method { private BOSEconomy BOSEconomy; + @Override public BOSEconomy getPlugin() { return this.BOSEconomy; } + @Override public String getName() { return "BOSEconomy"; } + @Override public String getVersion() { return "0.6.2"; } + @Override public int fractionalDigits() { return 0; } + @Override public String format(double amount) { String currency = this.BOSEconomy.getMoneyNamePlural(); @@ -50,27 +55,32 @@ public class BOSE6 implements Method return amount + " " + currency; } + @Override public boolean hasBanks() { return true; } + @Override public boolean hasBank(String bank) { return this.BOSEconomy.bankExists(bank); } + @Override public boolean hasAccount(String name) { return this.BOSEconomy.playerRegistered(name, false); } + @Override public boolean hasBankAccount(String bank, String name) { return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); } + @Override public boolean createAccount(String name) { if (hasAccount(name)) @@ -82,6 +92,7 @@ public class BOSE6 implements Method return true; } + @Override public boolean createAccount(String name, Double balance) { if (hasAccount(name)) @@ -94,6 +105,7 @@ public class BOSE6 implements Method return true; } + @Override public MethodAccount getAccount(String name) { if (!hasAccount(name)) @@ -104,6 +116,7 @@ public class BOSE6 implements Method return new BOSEAccount(name, this.BOSEconomy); } + @Override public MethodBankAccount getBankAccount(String bank, String name) { if (!hasBankAccount(bank, name)) @@ -114,6 +127,7 @@ public class BOSE6 implements Method return new BOSEBankAccount(bank, BOSEconomy); } + @Override public boolean isCompatible(Plugin plugin) { return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") @@ -121,6 +135,7 @@ public class BOSE6 implements Method && plugin.getDescription().getVersion().equals("0.6.2"); } + @Override public void setPlugin(Plugin plugin) { BOSEconomy = (BOSEconomy)plugin; @@ -138,23 +153,27 @@ public class BOSE6 implements Method this.BOSEconomy = bOSEconomy; } + @Override public double balance() { return (double)this.BOSEconomy.getPlayerMoney(this.name); } + @Override public boolean set(double amount) { int IntAmount = (int)Math.ceil(amount); return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false); } + @Override public boolean add(double amount) { int IntAmount = (int)Math.ceil(amount); return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false); } + @Override public boolean subtract(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -162,6 +181,7 @@ public class BOSE6 implements Method return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false); } + @Override public boolean multiply(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -169,6 +189,7 @@ public class BOSE6 implements Method return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false); } + @Override public boolean divide(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -176,26 +197,31 @@ public class BOSE6 implements Method return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false); } + @Override public boolean hasEnough(double amount) { return (this.balance() >= amount); } + @Override public boolean hasOver(double amount) { return (this.balance() > amount); } + @Override public boolean hasUnder(double amount) { return (this.balance() < amount); } + @Override public boolean isNegative() { return (this.balance() < 0); } + @Override public boolean remove() { return false; @@ -214,27 +240,32 @@ public class BOSE6 implements Method this.BOSEconomy = bOSEconomy; } + @Override public String getBankName() { return this.bank; } + @Override public int getBankId() { return -1; } + @Override public double balance() { return (double)this.BOSEconomy.getBankMoney(bank); } + @Override public boolean set(double amount) { int IntAmount = (int)Math.ceil(amount); return this.BOSEconomy.setBankMoney(bank, IntAmount, true); } + @Override public boolean add(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -242,6 +273,7 @@ public class BOSE6 implements Method return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false); } + @Override public boolean subtract(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -249,6 +281,7 @@ public class BOSE6 implements Method return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false); } + @Override public boolean multiply(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -256,6 +289,7 @@ public class BOSE6 implements Method return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false); } + @Override public boolean divide(double amount) { int IntAmount = (int)Math.ceil(amount); @@ -263,26 +297,31 @@ public class BOSE6 implements Method return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false); } + @Override public boolean hasEnough(double amount) { return (this.balance() >= amount); } + @Override public boolean hasOver(double amount) { return (this.balance() > amount); } + @Override public boolean hasUnder(double amount) { return (this.balance() < amount); } + @Override public boolean isNegative() { return (this.balance() < 0); } + @Override public boolean remove() { return this.BOSEconomy.removeBank(bank); diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java index 72d1f763e..f96c286fa 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java @@ -1,7 +1,7 @@ package com.earth2me.essentials.register.payment.methods; -import com.earth2me.essentials.register.payment.Method; +import com.earth2me.essentials.register.payment.Method; import cosine.boseconomy.BOSEconomy; import org.bukkit.plugin.Plugin; @@ -18,26 +18,31 @@ public class BOSE7 implements Method { private BOSEconomy BOSEconomy; + @Override public BOSEconomy getPlugin() { return this.BOSEconomy; } + @Override public String getName() { return "BOSEconomy"; } + @Override public String getVersion() { return "0.7.0"; } + @Override public int fractionalDigits() { return this.BOSEconomy.getFractionalDigits(); } + @Override public String format(double amount) { String currency = this.BOSEconomy.getMoneyNamePlural(); @@ -50,26 +55,31 @@ public class BOSE7 implements Method return amount + " " + currency; } + @Override public boolean hasBanks() { return true; } + @Override public boolean hasBank(String bank) { return this.BOSEconomy.bankExists(bank); } + @Override public boolean hasAccount(String name) { return this.BOSEconomy.playerRegistered(name, false); } + @Override public boolean hasBankAccount(String bank, String name) { return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); } + @Override public boolean createAccount(String name) { if (hasAccount(name)) @@ -81,6 +91,7 @@ public class BOSE7 implements Method return true; } + @Override public boolean createAccount(String name, Double balance) { if (hasAccount(name)) @@ -93,6 +104,7 @@ public class BOSE7 implements Method return true; } + @Override public MethodAccount getAccount(String name) { if (!hasAccount(name)) @@ -103,6 +115,7 @@ public class BOSE7 implements Method return new BOSEAccount(name, this.BOSEconomy); } + @Override public MethodBankAccount getBankAccount(String bank, String name) { if (!hasBankAccount(bank, name)) @@ -113,6 +126,7 @@ public class BOSE7 implements Method return new BOSEBankAccount(bank, BOSEconomy); } + @Override public boolean isCompatible(Plugin plugin) { return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") @@ -120,6 +134,7 @@ public class BOSE7 implements Method && !plugin.getDescription().getVersion().equals("0.6.2"); } + @Override public void setPlugin(Plugin plugin) { BOSEconomy = (BOSEconomy)plugin; @@ -137,59 +152,70 @@ public class BOSE7 implements Method this.BOSEconomy = bOSEconomy; } + @Override public double balance() { return this.BOSEconomy.getPlayerMoneyDouble(this.name); } + @Override public boolean set(double amount) { return this.BOSEconomy.setPlayerMoney(this.name, amount, false); } + @Override public boolean add(double amount) { return this.BOSEconomy.addPlayerMoney(this.name, amount, false); } + @Override public boolean subtract(double amount) { double balance = this.balance(); return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false); } + @Override public boolean multiply(double amount) { double balance = this.balance(); return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false); } + @Override public boolean divide(double amount) { double balance = this.balance(); return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false); } + @Override public boolean hasEnough(double amount) { return (this.balance() >= amount); } + @Override public boolean hasOver(double amount) { return (this.balance() > amount); } + @Override public boolean hasUnder(double amount) { return (this.balance() < amount); } + @Override public boolean isNegative() { return (this.balance() < 0); } + @Override public boolean remove() { return false; @@ -208,70 +234,83 @@ public class BOSE7 implements Method this.BOSEconomy = bOSEconomy; } + @Override public String getBankName() { return this.bank; } + @Override public int getBankId() { return -1; } + @Override public double balance() { return this.BOSEconomy.getBankMoneyDouble(bank); } + @Override public boolean set(double amount) { return this.BOSEconomy.setBankMoney(bank, amount, true); } + @Override public boolean add(double amount) { double balance = this.balance(); return this.BOSEconomy.setBankMoney(bank, (balance + amount), false); } + @Override public boolean subtract(double amount) { double balance = this.balance(); return this.BOSEconomy.setBankMoney(bank, (balance - amount), false); } + @Override public boolean multiply(double amount) { double balance = this.balance(); return this.BOSEconomy.setBankMoney(bank, (balance * amount), false); } + @Override public boolean divide(double amount) { double balance = this.balance(); return this.BOSEconomy.setBankMoney(bank, (balance / amount), false); } + @Override public boolean hasEnough(double amount) { return (this.balance() >= amount); } + @Override public boolean hasOver(double amount) { return (this.balance() > amount); } + @Override public boolean hasUnder(double amount) { return (this.balance() < amount); } + @Override public boolean isNegative() { return (this.balance() < 0); } + @Override public boolean remove() { return this.BOSEconomy.removeBank(bank); diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java index 53d8ed120..ddef3c6fd 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.register.payment.methods; -import com.earth2me.essentials.register.payment.Method; + +import com.earth2me.essentials.register.payment.Method; import me.ashtheking.currency.Currency; import me.ashtheking.currency.CurrencyList; - import org.bukkit.plugin.Plugin; @@ -19,73 +19,87 @@ public class MCUR implements Method { private Currency currencyList; + @Override public Object getPlugin() { return this.currencyList; } + @Override public String getName() { return "MultiCurrency"; } + @Override public String getVersion() { return "0.09"; } + @Override public int fractionalDigits() { return -1; } + @Override public String format(double amount) { return amount + " Currency"; } + @Override public boolean hasBanks() { return false; } + @Override public boolean hasBank(String bank) { return false; } + @Override public boolean hasAccount(String name) { return true; } + @Override public boolean hasBankAccount(String bank, String name) { return false; } + @Override public boolean createAccount(String name) { CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, 0); return true; } + @Override public boolean createAccount(String name, Double balance) { CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, balance); return true; } + @Override public MethodAccount getAccount(String name) { return new MCurrencyAccount(name); } + @Override public MethodBankAccount getBankAccount(String bank, String name) { return null; } + @Override public boolean isCompatible(Plugin plugin) { return (plugin.getDescription().getName().equalsIgnoreCase("Currency") @@ -93,6 +107,7 @@ public class MCUR implements Method && plugin instanceof Currency; } + @Override public void setPlugin(Plugin plugin) { currencyList = (Currency)plugin; @@ -108,57 +123,68 @@ public class MCUR implements Method this.name = name; } + @Override public double balance() { return CurrencyList.getValue((String)CurrencyList.maxCurrency(name)[0], name); } + @Override public boolean set(double amount) { CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, amount); return true; } + @Override public boolean add(double amount) { return CurrencyList.add(name, amount); } + @Override public boolean subtract(double amount) { return CurrencyList.subtract(name, amount); } + @Override public boolean multiply(double amount) { return CurrencyList.multiply(name, amount); } + @Override public boolean divide(double amount) { return CurrencyList.divide(name, amount); } + @Override public boolean hasEnough(double amount) { return CurrencyList.hasEnough(name, amount); } + @Override public boolean hasOver(double amount) { return CurrencyList.hasOver(name, amount); } + @Override public boolean hasUnder(double amount) { return CurrencyList.hasUnder(name, amount); } + @Override public boolean isNegative() { return CurrencyList.isNegative(name); } + @Override public boolean remove() { return CurrencyList.remove(name); diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java index 1f33df12c..aaa3153c0 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.register.payment.methods; + + import com.earth2me.essentials.register.payment.Method; import com.nijiko.coelho.iConomy.iConomy; import com.nijiko.coelho.iConomy.system.Account; - - import org.bukkit.plugin.Plugin; @@ -19,51 +19,61 @@ public class iCo4 implements Method { private iConomy iConomy; + @Override public iConomy getPlugin() { return this.iConomy; } + @Override public String getName() { return "iConomy"; } + @Override public String getVersion() { return "4"; } + @Override public int fractionalDigits() { return 2; } + @Override public String format(double amount) { return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount); } + @Override public boolean hasBanks() { return false; } + @Override public boolean hasBank(String bank) { return false; } + @Override public boolean hasAccount(String name) { return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name); } + @Override public boolean hasBankAccount(String bank, String name) { return false; } + @Override public boolean createAccount(String name) { if (hasAccount(name)) @@ -83,6 +93,7 @@ public class iCo4 implements Method return true; } + @Override public boolean createAccount(String name, Double balance) { if (hasAccount(name)) @@ -102,16 +113,19 @@ public class iCo4 implements Method return true; } + @Override public MethodAccount getAccount(String name) { return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name)); } + @Override public MethodBankAccount getBankAccount(String bank, String name) { return null; } + @Override public boolean isCompatible(Plugin plugin) { return plugin.getDescription().getName().equalsIgnoreCase("iconomy") @@ -119,6 +133,7 @@ public class iCo4 implements Method && plugin instanceof iConomy; } + @Override public void setPlugin(Plugin plugin) { iConomy = (iConomy)plugin; @@ -139,11 +154,13 @@ public class iCo4 implements Method return account; } + @Override public double balance() { return this.account.getBalance(); } + @Override public boolean set(double amount) { if (this.account == null) @@ -154,6 +171,7 @@ public class iCo4 implements Method return true; } + @Override public boolean add(double amount) { if (this.account == null) @@ -164,6 +182,7 @@ public class iCo4 implements Method return true; } + @Override public boolean subtract(double amount) { if (this.account == null) @@ -174,6 +193,7 @@ public class iCo4 implements Method return true; } + @Override public boolean multiply(double amount) { if (this.account == null) @@ -184,6 +204,7 @@ public class iCo4 implements Method return true; } + @Override public boolean divide(double amount) { if (this.account == null) @@ -194,26 +215,31 @@ public class iCo4 implements Method return true; } + @Override public boolean hasEnough(double amount) { return this.account.hasEnough(amount); } + @Override public boolean hasOver(double amount) { return this.account.hasOver(amount); } + @Override public boolean hasUnder(double amount) { return (this.balance() < amount); } + @Override public boolean isNegative() { return this.account.isNegative(); } + @Override public boolean remove() { if (this.account == null) diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java index d56873c3f..c0ddeed83 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java @@ -1,13 +1,13 @@ package com.earth2me.essentials.register.payment.methods; + + import com.earth2me.essentials.register.payment.Method; import com.iConomy.iConomy; import com.iConomy.system.Account; import com.iConomy.system.BankAccount; import com.iConomy.system.Holdings; import com.iConomy.util.Constants; - - import org.bukkit.plugin.Plugin; @@ -22,51 +22,61 @@ public class iCo5 implements Method { private iConomy iConomy; + @Override public iConomy getPlugin() { return this.iConomy; } + @Override public String getName() { return "iConomy"; } + @Override public String getVersion() { return "5"; } + @Override public int fractionalDigits() { return 2; } + @Override public String format(double amount) { return com.iConomy.iConomy.format(amount); } + @Override public boolean hasBanks() { return Constants.Banking; } + @Override public boolean hasBank(String bank) { return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank); } + @Override public boolean hasAccount(String name) { return com.iConomy.iConomy.hasAccount(name); } + @Override public boolean hasBankAccount(String bank, String name) { return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name); } + @Override public boolean createAccount(String name) { if (hasAccount(name)) @@ -77,6 +87,7 @@ public class iCo5 implements Method return com.iConomy.iConomy.Accounts.create(name); } + @Override public boolean createAccount(String name, Double balance) { if (hasAccount(name)) @@ -94,16 +105,19 @@ public class iCo5 implements Method return true; } + @Override public MethodAccount getAccount(String name) { return new iCoAccount(com.iConomy.iConomy.getAccount(name)); } + @Override public MethodBankAccount getBankAccount(String bank, String name) { return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name)); } + @Override public boolean isCompatible(Plugin plugin) { return plugin.getDescription().getName().equalsIgnoreCase("iconomy") @@ -111,6 +125,7 @@ public class iCo5 implements Method && plugin instanceof iConomy; } + @Override public void setPlugin(Plugin plugin) { iConomy = (iConomy)plugin; @@ -133,11 +148,13 @@ public class iCo5 implements Method return account; } + @Override public double balance() { return this.holdings.balance(); } + @Override public boolean set(double amount) { if (this.holdings == null) @@ -148,6 +165,7 @@ public class iCo5 implements Method return true; } + @Override public boolean add(double amount) { if (this.holdings == null) @@ -158,6 +176,7 @@ public class iCo5 implements Method return true; } + @Override public boolean subtract(double amount) { if (this.holdings == null) @@ -168,6 +187,7 @@ public class iCo5 implements Method return true; } + @Override public boolean multiply(double amount) { if (this.holdings == null) @@ -178,6 +198,7 @@ public class iCo5 implements Method return true; } + @Override public boolean divide(double amount) { if (this.holdings == null) @@ -188,26 +209,31 @@ public class iCo5 implements Method return true; } + @Override public boolean hasEnough(double amount) { return this.holdings.hasEnough(amount); } + @Override public boolean hasOver(double amount) { return this.holdings.hasOver(amount); } + @Override public boolean hasUnder(double amount) { return this.holdings.hasUnder(amount); } + @Override public boolean isNegative() { return this.holdings.isNegative(); } + @Override public boolean remove() { if (this.account == null) @@ -236,21 +262,25 @@ public class iCo5 implements Method return account; } + @Override public String getBankName() { return this.account.getBankName(); } + @Override public int getBankId() { return this.account.getBankId(); } + @Override public double balance() { return this.holdings.balance(); } + @Override public boolean set(double amount) { if (this.holdings == null) @@ -261,6 +291,7 @@ public class iCo5 implements Method return true; } + @Override public boolean add(double amount) { if (this.holdings == null) @@ -271,6 +302,7 @@ public class iCo5 implements Method return true; } + @Override public boolean subtract(double amount) { if (this.holdings == null) @@ -281,6 +313,7 @@ public class iCo5 implements Method return true; } + @Override public boolean multiply(double amount) { if (this.holdings == null) @@ -291,6 +324,7 @@ public class iCo5 implements Method return true; } + @Override public boolean divide(double amount) { if (this.holdings == null) @@ -301,26 +335,31 @@ public class iCo5 implements Method return true; } + @Override public boolean hasEnough(double amount) { return this.holdings.hasEnough(amount); } + @Override public boolean hasOver(double amount) { return this.holdings.hasOver(amount); } + @Override public boolean hasUnder(double amount) { return this.holdings.hasUnder(amount); } + @Override public boolean isNegative() { return this.holdings.isNegative(); } + @Override public boolean remove() { if (this.account == null) diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java index 1feee30af..9ebe08d39 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java @@ -1,12 +1,12 @@ package com.earth2me.essentials.register.payment.methods; + + import com.earth2me.essentials.register.payment.Method; import com.iCo6.iConomy; import com.iCo6.system.Account; import com.iCo6.system.Accounts; import com.iCo6.system.Holdings; - - import org.bukkit.plugin.Plugin; @@ -21,51 +21,61 @@ public class iCo6 implements Method { private iConomy iConomy; + @Override public iConomy getPlugin() { return this.iConomy; } + @Override public String getName() { return "iConomy"; } + @Override public String getVersion() { return "6"; } + @Override public int fractionalDigits() { return 2; } + @Override public String format(double amount) { return com.iCo6.iConomy.format(amount); } + @Override public boolean hasBanks() { return false; } + @Override public boolean hasBank(String bank) { return false; } + @Override public boolean hasAccount(String name) { return (new Accounts()).exists(name); } + @Override public boolean hasBankAccount(String bank, String name) { return false; } + @Override public boolean createAccount(String name) { if (hasAccount(name)) @@ -76,6 +86,7 @@ public class iCo6 implements Method return (new Accounts()).create(name); } + @Override public boolean createAccount(String name, Double balance) { if (hasAccount(name)) @@ -86,16 +97,19 @@ public class iCo6 implements Method return (new Accounts()).create(name, balance); } + @Override public MethodAccount getAccount(String name) { return new iCoAccount((new Accounts()).get(name)); } + @Override public MethodBankAccount getBankAccount(String bank, String name) { return null; } + @Override public boolean isCompatible(Plugin plugin) { return plugin.getDescription().getName().equalsIgnoreCase("iconomy") @@ -103,6 +117,7 @@ public class iCo6 implements Method && plugin instanceof iConomy; } + @Override public void setPlugin(Plugin plugin) { iConomy = (iConomy)plugin; @@ -125,11 +140,13 @@ public class iCo6 implements Method return account; } + @Override public double balance() { return this.holdings.getBalance(); } + @Override public boolean set(double amount) { if (this.holdings == null) @@ -140,6 +157,7 @@ public class iCo6 implements Method return true; } + @Override public boolean add(double amount) { if (this.holdings == null) @@ -150,6 +168,7 @@ public class iCo6 implements Method return true; } + @Override public boolean subtract(double amount) { if (this.holdings == null) @@ -160,6 +179,7 @@ public class iCo6 implements Method return true; } + @Override public boolean multiply(double amount) { if (this.holdings == null) @@ -170,6 +190,7 @@ public class iCo6 implements Method return true; } + @Override public boolean divide(double amount) { if (this.holdings == null) @@ -180,26 +201,31 @@ public class iCo6 implements Method return true; } + @Override public boolean hasEnough(double amount) { return this.holdings.hasEnough(amount); } + @Override public boolean hasOver(double amount) { return this.holdings.hasOver(amount); } + @Override public boolean hasUnder(double amount) { return this.holdings.hasUnder(amount); } + @Override public boolean isNegative() { return this.holdings.isNegative(); } + @Override public boolean remove() { if (this.account == null) diff --git a/Essentials/src/com/earth2me/essentials/settings/Commands.java b/Essentials/src/com/earth2me/essentials/settings/Commands.java index 771cef12b..64a218476 100644 --- a/Essentials/src/com/earth2me/essentials/settings/Commands.java +++ b/Essentials/src/com/earth2me/essentials/settings/Commands.java @@ -1,12 +1,6 @@ package com.earth2me.essentials.settings; -import com.earth2me.essentials.settings.commands.Afk; -import com.earth2me.essentials.settings.commands.God; -import com.earth2me.essentials.settings.commands.Help; -import com.earth2me.essentials.settings.commands.Home; -import com.earth2me.essentials.settings.commands.Kit; -import com.earth2me.essentials.settings.commands.Lightning; -import com.earth2me.essentials.settings.commands.Spawnmob; +import com.earth2me.essentials.settings.commands.*; import com.earth2me.essentials.storage.Comment; import com.earth2me.essentials.storage.ListType; import com.earth2me.essentials.storage.StorageObject; diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index b9d224cec..e8bdd2b76 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; import java.util.HashSet; import java.util.Set; import org.bukkit.Material; @@ -426,24 +422,27 @@ public class EssentialsSign this.block = event.getBlock(); } + @Override public final String getLine(final int index) { return event.getLine(index); } + @Override public final void setLine(final int index, final String text) { event.setLine(index, text); } + @Override public Block getBlock() { return block; } + @Override public void updateSign() { - return; } } @@ -459,21 +458,25 @@ public class EssentialsSign this.sign = (Sign)block.getState(); } + @Override public final String getLine(final int index) { return sign.getLine(index); } + @Override public final void setLine(final int index, final String text) { sign.setLine(index, text); } + @Override public final Block getBlock() { return block; } + @Override public final void updateSign() { sign.update(); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 7320f27a4..2840df298 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -8,14 +8,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.block.BlockListener; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.block.*; public class SignBlockListener extends BlockListener diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBuy.java b/Essentials/src/com/earth2me/essentials/signs/SignBuy.java index 39704ff0d..b99f92b65 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBuy.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBuy.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index 4f6736989..eee813c7b 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -4,7 +4,6 @@ import com.earth2me.essentials.IEssentials; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.entity.EndermanPickupEvent; -import org.bukkit.event.entity.EndermanPlaceEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityListener; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignFree.java b/Essentials/src/com/earth2me/essentials/signs/SignFree.java index 8a7c27fe7..56efffb65 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignFree.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignFree.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.InventoryWorkaround; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; import net.minecraft.server.InventoryPlayer; import org.bukkit.Material; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java index a3b8cd275..f8fdeb20d 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; import org.bukkit.GameMode; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignHeal.java b/Essentials/src/com/earth2me/essentials/signs/SignHeal.java index cc932c5e2..a1c80e268 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignHeal.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignHeal.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; public class SignHeal extends EssentialsSign diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index ced8443a6..856831b58 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignSell.java b/Essentials/src/com/earth2me/essentials/signs/SignSell.java index 2a5a8cfcc..442a503c2 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignSell.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignSell.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTime.java b/Essentials/src/com/earth2me/essentials/signs/SignTime.java index 120347467..054ffde0c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTime.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTime.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; public class SignTime extends EssentialsSign diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index 6c956165a..ed7ef4db0 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; import org.bukkit.inventory.ItemStack; @@ -288,6 +284,7 @@ public class SignTrade extends EssentialsSign if (split.length == 3) { final int stackamount = getIntegerPositive(split[0]); + //TODO: Unused local variable final ItemStack item = getItemStack(split[1], stackamount, ess); final int amount = getInteger(split[2]); final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value)); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignWarp.java b/Essentials/src/com/earth2me/essentials/signs/SignWarp.java index 4aa4af11f..bd56be46e 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignWarp.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignWarp.java @@ -1,8 +1,8 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Trade; import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignWeather.java b/Essentials/src/com/earth2me/essentials/signs/SignWeather.java index 05496ac14..8af788961 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignWeather.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignWeather.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.ChargeException; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.*; public class SignWeather extends EssentialsSign diff --git a/Essentials/src/com/earth2me/essentials/storage/Comment.java b/Essentials/src/com/earth2me/essentials/storage/Comment.java index b43cec980..8cb9d4d31 100644 --- a/Essentials/src/com/earth2me/essentials/storage/Comment.java +++ b/Essentials/src/com/earth2me/essentials/storage/Comment.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.storage; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; @Target(ElementType.FIELD) diff --git a/Essentials/src/com/earth2me/essentials/storage/StorageObject.java b/Essentials/src/com/earth2me/essentials/storage/StorageObject.java index a35338516..cd144f424 100644 --- a/Essentials/src/com/earth2me/essentials/storage/StorageObject.java +++ b/Essentials/src/com/earth2me/essentials/storage/StorageObject.java @@ -4,21 +4,14 @@ import java.io.PrintWriter; import java.io.Reader; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; import java.util.Map.Entry; -import java.util.Set; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.TypeDescription; import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.composer.Composer; import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.introspector.PropertyUtils; public class StorageObject diff --git a/Essentials/src/com/earth2me/essentials/textreader/IText.java b/Essentials/src/com/earth2me/essentials/textreader/IText.java new file mode 100644 index 000000000..851119701 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/textreader/IText.java @@ -0,0 +1,14 @@ +package com.earth2me.essentials.textreader; + +import java.util.List; +import java.util.Map; + + +public interface IText +{ + List getLines(); + + List getChapters(); + + Map getBookmarks(); +} diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java new file mode 100644 index 000000000..29e44a682 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -0,0 +1,112 @@ +package com.earth2me.essentials.textreader; + +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.User; +import java.util.List; +import java.util.Map; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +public class KeywordReplacer implements IText +{ + private final transient IText input; + private final transient IEssentials ess; + + public KeywordReplacer(final IText input, final CommandSender sender, final IEssentials ess) + { + this.input = input; + this.ess = ess; + replaceKeywords(sender); + } + + private void replaceKeywords(final CommandSender sender) + { + String displayName, ipAddress, balance, mails, world; + String worlds, online, unique, playerlist; + if (sender instanceof Player) + { + final User user = ess.getUser(sender); + displayName = user.getDisplayName(); + ipAddress = user.getAddress().getAddress().toString(); + balance = Double.toString(user.getMoney()); + mails = Integer.toString(user.getMails().size()); + world = user.getLocation().getWorld().getName(); + } + else + { + displayName = ipAddress = balance = mails = world = ""; + } + + int playerHidden = 0; + for (Player p : ess.getServer().getOnlinePlayers()) + { + if (ess.getUser(p).isHidden()) + { + playerHidden++; + } + } + online = Integer.toString(ess.getServer().getOnlinePlayers().length - playerHidden); + unique = Integer.toString(ess.getUserMap().getUniqueUsers()); + + final StringBuilder worldsBuilder = new StringBuilder(); + for (World w : ess.getServer().getWorlds()) + { + if (worldsBuilder.length() > 0) + { + worldsBuilder.append(", "); + } + worldsBuilder.append(w.getName()); + } + worlds = worldsBuilder.toString(); + + final StringBuilder playerlistBuilder = new StringBuilder(); + for (Player p : ess.getServer().getOnlinePlayers()) + { + if (ess.getUser(p).isHidden()) + { + continue; + } + if (playerlistBuilder.length() > 0) + { + playerlistBuilder.append(", "); + } + playerlistBuilder.append(p.getDisplayName()); + } + playerlist = playerlistBuilder.toString(); + + for (int i = 0; i < input.getLines().size(); i++) + { + String line = input.getLines().get(i); + line = line.replace("{PLAYER}", displayName); + line = line.replace("{IP}", ipAddress); + line = line.replace("{BALANCE}", balance); + line = line.replace("{MAILS}", mails); + line = line.replace("{WORLD}", world); + line = line.replace("{ONLINE}", online); + line = line.replace("{UNIQUE}", unique); + line = line.replace("{WORLDS}", worlds); + line = line.replace("{PLAYERLIST}", playerlist); + input.getLines().set(i, line); + } + } + + @Override + public List getLines() + { + return input.getLines(); + } + + @Override + public List getChapters() + { + return input.getChapters(); + } + + @Override + public Map getBookmarks() + { + return input.getBookmarks(); + } +} diff --git a/Essentials/src/com/earth2me/essentials/textreader/TextInput.java b/Essentials/src/com/earth2me/essentials/textreader/TextInput.java new file mode 100644 index 000000000..ce99a8093 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/textreader/TextInput.java @@ -0,0 +1,109 @@ +package com.earth2me.essentials.textreader; + +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import java.io.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +public class TextInput implements IText +{ + private final transient List lines = new ArrayList(); + private final transient List chapters = new ArrayList(); + private final transient Map bookmarks = new HashMap(); + + public TextInput(final CommandSender sender, final String filename, final boolean createFile, final IEssentials ess) throws IOException + { + + File file = null; + if (sender instanceof Player) + { + final User user = ess.getUser(sender); + file = new File(ess.getDataFolder(), filename + "_" + Util.sanitizeFileName(user.getName()) + ".txt"); + if (!file.exists()) + { + file = new File(ess.getDataFolder(), filename + "_" + Util.sanitizeFileName(user.getGroup()) + ".txt"); + } + } + if (file == null || !file.exists()) + { + file = new File(ess.getDataFolder(), filename + ".txt"); + } + if (file.exists()) + { + final BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); + try + { + int lineNumber = 0; + while (bufferedReader.ready()) + { + final String line = bufferedReader.readLine(); + if (line == null) + { + break; + } + if (line.length() > 0 && line.charAt(0) == '#') + { + bookmarks.put(line.substring(1).toLowerCase().replaceAll("&[0-9a-f]", ""), lineNumber); + chapters.add(line.substring(1).replace('&', '§').replace("§§", "&")); + } + lines.add(line.replace('&', '§').replace("§§", "&")); + lineNumber++; + } + } + finally + { + bufferedReader.close(); + } + } + else + { + if (createFile) + { + final InputStream input = ess.getResource(filename + ".txt"); + final OutputStream output = new FileOutputStream(file); + try + { + final byte[] buffer = new byte[1024]; + int length = 0; + length = input.read(buffer); + while (length > 0) + { + output.write(buffer, 0, length); + length = input.read(buffer); + } + } + finally + { + output.close(); + input.close(); + } + throw new FileNotFoundException("File " + filename + ".txt does not exist. Creating one for you."); + } + } + } + + @Override + public List getLines() + { + return lines; + } + + @Override + public List getChapters() + { + return chapters; + } + + @Override + public Map getBookmarks() + { + return bookmarks; + } +} diff --git a/Essentials/src/com/earth2me/essentials/textreader/TextPager.java b/Essentials/src/com/earth2me/essentials/textreader/TextPager.java new file mode 100644 index 000000000..786ca96bd --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/textreader/TextPager.java @@ -0,0 +1,156 @@ +package com.earth2me.essentials.textreader; + +import com.earth2me.essentials.Util; +import java.util.List; +import java.util.Map; +import org.bukkit.command.CommandSender; + + +public class TextPager +{ + private final transient IText text; + private final transient boolean showHeader; + + public TextPager(final IText text) + { + this(text, true); + } + + public TextPager(final IText text, final boolean showHeader) + { + this.text = text; + this.showHeader = showHeader; + } + + public void showPage(final String pageStr, final String chapterPageStr, final CommandSender sender) + { + List lines = text.getLines(); + List chapters = text.getChapters(); + Map bookmarks = text.getBookmarks(); + + if (bookmarks.isEmpty()) + { + int page = 1; + try + { + page = Integer.parseInt(pageStr); + } + catch (Exception ex) + { + page = 1; + } + + int start = (page - 1) * 9; + if (showHeader) + { + int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); + sender.sendMessage(Util.format("infoPages", page, pages)); + } + for (int i = start; i < lines.size() && i < start + 9; i++) + { + sender.sendMessage(lines.get(i)); + } + return; + } + + if (pageStr == null || pageStr.isEmpty() || pageStr.matches("[0-9]+")) + { + if (lines.get(0).startsWith("#")) + { + if (!showHeader) + { + return; + } + sender.sendMessage(Util.i18n("infoChapter")); + final StringBuilder sb = new StringBuilder(); + boolean first = true; + for (String string : chapters) + { + if (!first) + { + sb.append(", "); + } + first = false; + sb.append(string); + } + sender.sendMessage(sb.toString()); + return; + } + else + { + int page = 1; + try + { + page = Integer.parseInt(pageStr); + } + catch (Exception ex) + { + page = 1; + } + + int start = (page - 1) * 9; + int end; + for (end = 0; end < lines.size(); end++) + { + String line = lines.get(end); + if (line.startsWith("#")) + { + break; + } + } + + if (showHeader) + { + int pages = end / 9 + (end % 9 > 0 ? 1 : 0); + sender.sendMessage(Util.format("infoPages", page, pages)); + } + for (int i = start; i < end && i < start + 9; i++) + { + sender.sendMessage(lines.get(i)); + } + return; + } + } + + int chapterpage = 0; + if (chapterPageStr != null) + { + try + { + chapterpage = Integer.parseInt(chapterPageStr) - 1; + } + catch (Exception ex) + { + chapterpage = 0; + } + } + + if (!bookmarks.containsKey(pageStr.toLowerCase())) + { + sender.sendMessage(Util.i18n("infoUnknownChapter")); + return; + } + final int chapterstart = bookmarks.get(pageStr.toLowerCase()) + 1; + int chapterend; + for (chapterend = chapterstart; chapterend < lines.size(); chapterend++) + { + final String line = lines.get(chapterend); + if (line.length() > 0 && line.charAt(0) == '#') + { + break; + } + } + final int start = chapterstart + chapterpage * 9; + + if (showHeader) + { + final int page = chapterpage + 1; + final int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0); + sender.sendMessage(Util.format("infoChapterPages", pageStr, page, pages)); + } + for (int i = start; i < chapterend && i < start + 9; i++) + { + sender.sendMessage(lines.get(i)); + } + } +} diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 472887d5d..0e3361308 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -85,19 +85,8 @@ spawnmob-limit: 10 # Shall we notify users when using /lightning warn-on-smite: true -# The message of the day, displayed on connect and by typing /motd. -# Valid tags are: {PLAYER}, {IP}, {BALANCE}, {MAILS}, {WORLD}, {ONLINE}, {UNIQUE}, {PLAYERLIST} -motd: - - '&cWelcome, {PLAYER}&c!' - - '&fType &c/help&f for a list of commands.' - - 'Currently online: {PLAYERLIST}' +# motd and rules are now configured in the files motd.txt and rules.txt -# The server rules, available by typing /rules -rules: - - '[1] Be respectful' - - '[2] Be ethical' - - '[3] Use common sense' - # When a command conflicts with another plugin, by default, Essentials will try to force the OTHER plugin to take # priority. If a command is in this list, Essentials will try to give ITSELF priority. This does not always work: # usually whichever plugin was updated most recently wins out. However, the full name of the command will always work. diff --git a/Essentials/src/info.txt b/Essentials/src/info.txt new file mode 100644 index 000000000..4435364fe --- /dev/null +++ b/Essentials/src/info.txt @@ -0,0 +1,35 @@ +This is the info file. + +This file format works for the info.txt, motd.txt and rules.txt + +You can create a specific file for a user or a group: +Name it info_username.txt or info_groupname.txt + +This also works with motd and rules. + +It can contain chapters like the Chapter1 below: + +#Chapter1 +Lines starting with # begin a new chapter +The user has to type /info Chapter1 to read this chapter + +If the file starts with a # then the user is shown a chapter selection, +when he does not select a chapter. + +#Colors +Minecraft colors: +&0 &&0 &1 &&1 &2 &&2 &3 &&3 +&4 &&4 &5 &&5 &6 &&6 &7 &&7 +&8 &&8 &9 &&9 &a &&a &b &&b +&c &&c &d &&d &e &&e &f &&f + +#Tags +PLAYER: {PLAYER} +IP: {IP} +BALANCE: {BALANCE} +MAILS: {MAILS} +WORLD: {WORLD} +WORLDS: {WORLDS} +ONLINE: {ONLINE} +UNIQUE: {UNIQUE} +PLAYERLIST: {PLAYERLIST} \ No newline at end of file diff --git a/Essentials/src/motd.txt b/Essentials/src/motd.txt new file mode 100644 index 000000000..224e452ef --- /dev/null +++ b/Essentials/src/motd.txt @@ -0,0 +1,3 @@ +&cWelcome, {PLAYER}&c! +&fType &c/help&f for a list of commands. +Currently online: {PLAYERLIST} \ No newline at end of file diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index dd7bb2ec3..dcbbfe767 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -275,7 +275,7 @@ commands: usage: / [:data][,[:data]] [amount] aliases: [espawnmob] sudo: - description: Make another user do something. + description: Make another user perform a command. usage: / aliases: [esudo] suicide: @@ -309,7 +309,7 @@ commands: tpa: description: Request to teleport to the specified player. usage: / - aliases: [call,etpa,ecal] + aliases: [call,etpa,ecall] tpaall: description: Requests all players online to teleport to you. usage: / diff --git a/Essentials/src/rules.txt b/Essentials/src/rules.txt new file mode 100644 index 000000000..486bfdf29 --- /dev/null +++ b/Essentials/src/rules.txt @@ -0,0 +1,3 @@ +[1] Be respectful +[2] Be ethical +[3] Use common sense \ No newline at end of file diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java index a7ade803b..ba4e63d98 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java @@ -1,9 +1,7 @@ package com.earth2me.essentials.chat; -import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; import java.util.Map; import org.bukkit.Server; import org.bukkit.event.player.PlayerChatEvent; diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java index aa919f44b..5a4049a62 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.geoip; -import com.earth2me.essentials.Essentials; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.Util; import java.util.logging.Level; diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index cbe89f9d6..a5daa263d 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -5,27 +5,14 @@ import com.earth2me.essentials.EssentialsConf; import com.earth2me.essentials.IConf; import com.earth2me.essentials.IUser; import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import org.jivesoftware.smack.Chat; -import org.jivesoftware.smack.ChatManager; -import org.jivesoftware.smack.ChatManagerListener; -import org.jivesoftware.smack.ConnectionConfiguration; -import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smack.Roster.SubscriptionMode; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; +import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.util.StringUtils; diff --git a/WebPush/index.php b/WebPush/index.php index fc3405fe2..56193ebf7 100644 --- a/WebPush/index.php +++ b/WebPush/index.php @@ -38,16 +38,22 @@ sleep(60); $changes = getChanges($build, $branch); -uploadit($build, $branch, 'Essentials.jar', $version, $changes); +//uploadit($build, $branch, 'Essentials.jar', $version, $changes); +//sleep(1); +//uploadit($build, $branch, 'EssentialsChat.jar', $version, $changes); +//sleep(1); +//uploadit($build, $branch, 'EssentialsSpawn.jar', $version, $changes); +//sleep(1); +//uploadit($build, $branch, 'EssentialsProtect.jar', $version, $changes); +//sleep(1); +//uploadit($build, $branch, 'EssentialsXMPP.jar', $version, $changes); +//sleep(1); +//uploadit($build, $branch, 'EssentialsGeoIP.jar', $version, $changes); + +uploadit($build, $branch, 'Essentials.zip', $version, $changes); sleep(1); -uploadit($build, $branch, 'EssentialsChat.jar', $version, $changes); -sleep(1); -uploadit($build, $branch, 'EssentialsSpawn.jar', $version, $changes); -sleep(1); -uploadit($build, $branch, 'EssentialsProtect.jar', $version, $changes); -sleep(1); -uploadit($build, $branch, 'EssentialsXMPP.jar', $version, $changes); -sleep(1); -uploadit($build, $branch, 'EssentialsGeoIP.jar', $version, $changes); +uploadit($build, $branch, 'Essentials-extra.zip', $version, $changes); + + ?>