diff options
113 files changed, 579 insertions, 999 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java b/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java index 473f986bc..5c0fdbafa 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java @@ -1,21 +1,12 @@ package com.earth2me.essentials; -import com.earth2me.essentials.api.ICommandHandler; -import com.earth2me.essentials.api.ISettings; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IEssentials; -import com.earth2me.essentials.api.IEssentialsModule; -import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.api.*; import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.commands.NotEnoughArgumentsException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; @@ -36,6 +27,7 @@ public class EssentialsCommandHandler implements ICommandHandler private static final transient Logger LOGGER = Bukkit.getLogger(); private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>(); private final transient Map<String, String> disabledList = new HashMap<String, String>(); + private final transient Map<String, IEssentialsCommand> commands = new HashMap<String, IEssentialsCommand>(); private final transient IEssentials ess; public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentials ess) @@ -66,10 +58,13 @@ public class EssentialsCommandHandler implements ICommandHandler boolean overridden = false; ISettings settings = ess.getSettings(); settings.acquireReadLock(); - try { + try + { disabled = settings.getData().getCommands().isDisabled(command.getName()); overridden = !disabled || settings.getData().getCommands().isOverridden(command.getName()); - } finally { + } + finally + { settings.unlock(); } // Allow plugins to override the command via onCommand @@ -98,22 +93,27 @@ public class EssentialsCommandHandler implements ICommandHandler return true; } - IEssentialsCommand cmd; - try - { - cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + command.getName()).newInstance(); - cmd.setEssentials(ess); - cmd.setEssentialsModule(module); - } - catch (Exception ex) + final String commandName = command.getName().toLowerCase(Locale.ENGLISH); + IEssentialsCommand cmd = commands.get(commandName); + if (cmd == null) { - sender.sendMessage(_("commandNotLoaded", commandLabel)); - LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex); - return true; + try + { + cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + commandName).newInstance(); + cmd.init(ess, commandName); + cmd.setEssentialsModule(module); + commands.put(commandName, cmd); + } + catch (Exception ex) + { + sender.sendMessage(_("commandNotLoaded", commandName)); + LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandName), ex); + return true; + } } // Check authorization - if (user != null && !user.isAuthorized(cmd, permissionPrefix)) + if (user != null && !user.isAuthorized(cmd)) { LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName())); user.sendMessage(_("noAccessCommand")); @@ -125,14 +125,14 @@ public class EssentialsCommandHandler implements ICommandHandler { if (user == null) { - cmd.run(ess.getServer(), sender, commandLabel, command, args); + cmd.run(sender, command, args); } else { user.acquireReadLock(); try { - cmd.run(ess.getServer(), user, commandLabel, command, args); + cmd.run(user, command, args); } finally { @@ -177,11 +177,10 @@ public class EssentialsCommandHandler implements ICommandHandler LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception); } } - + @Override public void onReload() { - } public final void addPlugin(final Plugin plugin) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 2df4322b9..0a10ba33f 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -14,6 +14,7 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import lombok.Cleanup; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -39,17 +40,17 @@ public final class Util try { String r = name.toLowerCase(Locale.ENGLISH); - r = r.replace('.', (char)('\ue200'+'.')); - r = r.replace('\\', (char)('\ue200'+'\\')); - r = r.replace('/', (char)('\ue200'+'/')); - r = r.replace('"', (char)('\ue200'+'"')); - r = r.replace('<', (char)('\ue200'+'<')); - r = r.replace('>', (char)('\ue200'+'>')); - r = r.replace('|', (char)('\ue200'+'|')); - r = r.replace('?', (char)('\ue200'+'?')); - r = r.replace('*', (char)('\ue200'+'*')); - r = r.replace(':', (char)('\ue200'+':')); - r = r.replace('-', (char)('\ue200'+'-')); + r = r.replace('.', (char)('\ue200' + '.')); + r = r.replace('\\', (char)('\ue200' + '\\')); + r = r.replace('/', (char)('\ue200' + '/')); + r = r.replace('"', (char)('\ue200' + '"')); + r = r.replace('<', (char)('\ue200' + '<')); + r = r.replace('>', (char)('\ue200' + '>')); + r = r.replace('|', (char)('\ue200' + '|')); + r = r.replace('?', (char)('\ue200' + '?')); + r = r.replace('*', (char)('\ue200' + '*')); + r = r.replace(':', (char)('\ue200' + ':')); + r = r.replace('-', (char)('\ue200' + '-')); r = unsafeFileChars.matcher(r).replaceAll(""); return Punycode.encode(r); } @@ -58,23 +59,23 @@ public final class Util throw new InvalidNameException(ex); } } - + public static String decodeFileName(String name) throws InvalidNameException { try { String r = Punycode.decode(name); - r = r.replace((char)('\ue200'+'.'), '.'); - r = r.replace((char)('\ue200'+'\\'), '\\'); - r = r.replace((char)('\ue200'+'/'), '/'); - r = r.replace((char)('\ue200'+'"'), '"'); - r = r.replace((char)('\ue200'+'<'), '<'); - r = r.replace((char)('\ue200'+'>'), '>'); - r = r.replace((char)('\ue200'+'|'), '|'); - r = r.replace((char)('\ue200'+'?'), '?'); - r = r.replace((char)('\ue200'+'*'), '*'); - r = r.replace((char)('\ue200'+':'), ':'); - r = r.replace((char)('\ue200'+'-'), '-'); + r = r.replace((char)('\ue200' + '.'), '.'); + r = r.replace((char)('\ue200' + '\\'), '\\'); + r = r.replace((char)('\ue200' + '/'), '/'); + r = r.replace((char)('\ue200' + '"'), '"'); + r = r.replace((char)('\ue200' + '<'), '<'); + r = r.replace((char)('\ue200' + '>'), '>'); + r = r.replace((char)('\ue200' + '|'), '|'); + r = r.replace((char)('\ue200' + '?'), '?'); + r = r.replace((char)('\ue200' + '*'), '*'); + r = r.replace((char)('\ue200' + ':'), ':'); + r = r.replace((char)('\ue200' + '-'), '-'); return r; } catch (PunycodeException ex) @@ -581,6 +582,44 @@ public final class Util } basePerm.recalculatePermissibles(); } + private static transient final Pattern DOT_PATTERN = Pattern.compile("\\."); + + public static Permission registerPermission(String permission, PermissionDefault defaultPerm) + { + final PluginManager pluginManager = Bukkit.getServer().getPluginManager(); + final String[] parts = DOT_PATTERN.split(permission); + final StringBuilder builder = new StringBuilder(permission.length()); + Permission parent = null; + for (int i = 0; i < parts.length - 1; i++) + { + builder.append(parts[i]).append(".*"); + String permString = builder.toString(); + Permission perm = pluginManager.getPermission(permString); + if (perm == null) + { + perm = new Permission(permString, PermissionDefault.FALSE); + pluginManager.addPermission(perm); + if (parent != null) + { + parent.getChildren().put(perm.getName(), Boolean.TRUE); + } + parent = perm; + } + builder.deleteCharAt(builder.length() - 1); + } + Permission perm = pluginManager.getPermission(permission); + if (perm == null) + { + perm = new Permission(permission, defaultPerm); + pluginManager.addPermission(perm); + if (parent != null) + { + parent.getChildren().put(perm.getName(), Boolean.TRUE); + } + parent = perm; + } + return perm; + } private static transient final Pattern COLOR_PATTERN = Pattern.compile("(?i)\u00A7[0-9A-F]"); public static String stripColor(final String input) diff --git a/Essentials/src/com/earth2me/essentials/api/IPermission.java b/Essentials/src/com/earth2me/essentials/api/IPermission.java index 5ce7a654b..bebf8380e 100644 --- a/Essentials/src/com/earth2me/essentials/api/IPermission.java +++ b/Essentials/src/com/earth2me/essentials/api/IPermission.java @@ -1,5 +1,14 @@ package com.earth2me.essentials.api; -public interface IPermission { +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + + +public interface IPermission +{ String getPermission(); + + Permission getBukkitPermission(); + + PermissionDefault getPermissionDefault(); } diff --git a/Essentials/src/com/earth2me/essentials/api/IUser.java b/Essentials/src/com/earth2me/essentials/api/IUser.java index 86d710e9f..6528a17af 100644 --- a/Essentials/src/com/earth2me/essentials/api/IUser.java +++ b/Essentials/src/com/earth2me/essentials/api/IUser.java @@ -16,9 +16,9 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, boolean isAuthorized(IPermission node); - boolean isAuthorized(IEssentialsCommand cmd); + //boolean isAuthorized(IEssentialsCommand cmd); - boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); + //boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); Player getBase(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java index dd1ccfb8e..a3e1fd141 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java @@ -2,21 +2,17 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; +import com.earth2me.essentials.perm.Permissions; import org.bukkit.entity.Player; +import org.bukkit.permissions.PermissionDefault; public class Commandafk extends EssentialsCommand { - public Commandafk() - { - super("afk"); - } - @Override - public void run(Server server, IUser user, String commandLabel, String[] args) throws Exception + public void run(IUser user, String[] args) throws Exception { - if (args.length > 0 && user.isAuthorized("essentials.afk.others")) + if (args.length > 0 && user.isAuthorized(Permissions.AFK_OTHERS)) { IUser afkUser = ess.getUser((Player)ess.getServer().matchPlayer(args[0])); if (afkUser != null) @@ -50,4 +46,10 @@ public class Commandafk extends EssentialsCommand } } } + + @Override + public PermissionDefault getPermissionDefault() + { + return PermissionDefault.TRUE; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java index 03eaa88ec..f1ced883e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java @@ -3,19 +3,13 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Util; import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.entity.TNTPrimed; public class Commandantioch extends EssentialsCommand { - public Commandantioch() - { - super("antioch"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { 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."); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java index ae36087c2..3b997240e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java @@ -3,20 +3,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandback extends EssentialsCommand { - public Commandback() - { - super("back"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); user.sendMessage(_("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 d1869e5b9..0f22ba51a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java @@ -1,20 +1,14 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.api.IBackup; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; +import com.earth2me.essentials.api.IBackup; import org.bukkit.command.CommandSender; public class Commandbackup extends EssentialsCommand { - public Commandbackup() - { - super("backup"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { final IBackup backup = ess.getBackup(); backup.run(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java index f04b0b136..3594f858c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java @@ -3,35 +3,30 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Util; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; +import com.earth2me.essentials.perm.Permissions; import org.bukkit.command.CommandSender; +import org.bukkit.permissions.PermissionDefault; public class Commandbalance extends EssentialsCommand { - public Commandbalance() - { - super("balance"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess))); + sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(args, 0, true).getMoney(), ess))); } @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { final double bal = (args.length < 1 - || !(user.isAuthorized("essentials.balance.others") - || user.isAuthorized("essentials.balance.other")) + || !user.isAuthorized(Permissions.BALANCE_OTHERS) ? user - : getPlayer(server, args, 0, true)).getMoney(); + : getPlayer(args, 0, true)).getMoney(); user.sendMessage(_("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 4b598d70d..757cb6c1d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java @@ -1,24 +1,19 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.api.IUser; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Util; +import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.textreader.ArrayListInput; import com.earth2me.essentials.textreader.TextPager; import java.text.DateFormat; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandbalancetop extends EssentialsCommand { - public Commandbalancetop() - { - super("balancetop"); - } private static final int CACHETIME = 2 * 60 * 1000; public static final int MINUSERS = 50; private static ArrayListInput cache = new ArrayListInput(); @@ -26,7 +21,7 @@ public class Commandbalancetop extends EssentialsCommand private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { int page = 0; boolean force = false; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index c360eeaba..75d55d5c6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -2,31 +2,24 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.user.Ban; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandban extends EssentialsCommand { - public Commandban() - { - super("ban"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } @Cleanup - final IUser user = getPlayer(server, args, 0, true); + final IUser user = getPlayer(args, 0, true); if (user.getBase() instanceof OfflinePlayer) { if (sender instanceof Player diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index f067888f6..64f315a9b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -3,19 +3,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandbanip extends EssentialsCommand { - public Commandbanip() - { - super("banip"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index e1e486344..39ef14d57 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -1,22 +1,16 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; +import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.TreeType; public class Commandbigtree extends EssentialsCommand { - public Commandbigtree() - { - super("bigtree"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { TreeType tree; if (args.length > 0 && args[0].equalsIgnoreCase("redwood")) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java index 41b830488..bb38c3583 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java @@ -2,21 +2,15 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.api.IUser; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.event.block.BlockBreakEvent; public class Commandbreak extends EssentialsCommand { - public Commandbreak() - { - super("break"); - } - //TODO: Switch to use util class @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { final Block block = user.getTargetBlock(null, 20); if (block == null) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java index 95bb967c6..ea70f1c10 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java @@ -1,19 +1,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandbroadcast extends EssentialsCommand { - public Commandbroadcast() - { - super("broadcast"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java index 5d8d38ce7..11b332ad2 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java @@ -1,20 +1,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandburn extends EssentialsCommand { - public Commandburn() - { - super("burn"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, 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 94d83f250..55195f9bc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java @@ -3,21 +3,15 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.List; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandclearinventory extends EssentialsCommand { - public Commandclearinventory() - { - super("clearinventory"); - } - //TODO: Cleanup @Override - public void run(Server server, IUser user, String commandLabel, String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others")) { @@ -59,7 +53,7 @@ public class Commandclearinventory extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java index 3bb08967b..7b9b590cb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandcompass extends EssentialsCommand { - public Commandcompass() - { - super("compass"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360; String dir; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java index 98b4a79ff..14bda2212 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java @@ -4,20 +4,14 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.Locale; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commanddelhome extends EssentialsCommand { - public Commanddelhome() - { - super("delhome"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -31,7 +25,7 @@ public class Commanddelhome extends EssentialsCommand if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) { - user = getPlayer(server, expandedArg, 0, true); + user = getPlayer(expandedArg, 0, true); name = expandedArg[1]; } else if (user == null) @@ -44,9 +38,7 @@ public class Commanddelhome extends EssentialsCommand } //TODO: Think up a nice error message /* - * if (name.equalsIgnoreCase("bed")) { - * throw new Exception("You cannot remove the vanilla home point"); - * } + * if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); } */ user.acquireWriteLock(); user.getData().removeHome(name.toLowerCase(Locale.ENGLISH)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java index 5c2c957e4..dc097a803 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java @@ -1,19 +1,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commanddeljail extends EssentialsCommand { - public Commanddeljail() - { - super("deljail"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java index 3b7c42b4c..b122f76bc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java @@ -1,19 +1,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commanddelwarp extends EssentialsCommand { - public Commanddelwarp() - { - super("delwarp"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, 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 0124e0bc7..031bb29d5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commanddepth extends EssentialsCommand { - public Commanddepth() - { - super("depth"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { final int depth = user.getLocation().getBlockY() - 63; if (depth > 0) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java index 46f8f6eba..299d23d2f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java @@ -4,20 +4,14 @@ import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; import java.util.Locale; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandeco extends EssentialsCommand { - public Commandeco() - { - super("eco"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { @@ -60,7 +54,7 @@ public class Commandeco extends EssentialsCommand } else { - final IUser player = getPlayer(server, args, 1, true); + final IUser player = getPlayer(args, 1, true); switch (cmd) { case GIVE: diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java index ae816141b..6eff93a48 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java @@ -5,21 +5,15 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import java.util.*; -import org.bukkit.Server; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; public class Commandenchant extends EssentialsCommand { - public Commandenchant() - { - super("enchant"); - } - //TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess); @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { final ItemStack stack = user.getItemInHand(); if (stack == null) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index 685f40353..7cff555fc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -1,13 +1,10 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.api.ISettings; import static com.earth2me.essentials.I18n._; import java.util.HashMap; import java.util.Map; -import lombok.Cleanup; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,33 +12,31 @@ import org.bukkit.entity.Player; public class Commandessentials extends EssentialsCommand { - public Commandessentials() - { - super("essentials"); - } private transient int taskid; private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>(); @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { - if (args.length == 0) { - run_disabled(server, sender, commandLabel, args); + if (args.length == 0) + { + run_disabled(sender, args); } else if (args[0].equalsIgnoreCase("debug")) { - run_debug(server, sender, commandLabel, args); + run_debug(sender, args); } else if (args[0].equalsIgnoreCase("nya")) { - run_nya(server, sender, commandLabel, args); + run_nya(sender, args); } - else { - run_reload(server, sender, commandLabel, args); + else + { + run_reload(sender, args); } } - - private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + + private void run_disabled(final CommandSender sender, final String[] args) throws Exception { sender.sendMessage("Essentials " + ess.getDescription().getVersion()); sender.sendMessage("/<command> <reload/debug>"); @@ -49,27 +44,28 @@ public class Commandessentials extends EssentialsCommand final StringBuilder disabledCommands = new StringBuilder(); for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet()) { - if (disabledCommands.length() > 0) { + if (disabledCommands.length() > 0) + { disabledCommands.append(", "); } disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue()); } sender.sendMessage(disabledCommands.toString()); } - - private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + + private void run_debug(final CommandSender sender, final String[] args) throws Exception { ess.getSettings().setDebug(!ess.getSettings().isDebug()); sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled")); } - - private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + + private void run_reload(final CommandSender sender, final String[] args) throws Exception { ess.reload(); sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion())); } - - private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + + private void run_nya(final CommandSender sender, final String[] args) throws Exception { final Map<String, Byte> noteMap = new HashMap<String, Byte>(); noteMap.put("1F#", (byte)0x0); @@ -96,56 +92,56 @@ public class Commandessentials extends EssentialsCommand noteMap.put("2D#", (byte)(0x9 + 0xC)); noteMap.put("2E", (byte)(0xA + 0xC)); noteMap.put("2F", (byte)(0xB + 0xC)); - if (!noteBlocks.isEmpty()) + if (!noteBlocks.isEmpty()) + { + return; + } + final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,"; + final String[] tune = tuneStr.split(","); + for (Player player : server.getOnlinePlayers()) + { + final Location loc = player.getLocation(); + loc.add(0, 3, 0); + while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0) { - return; + loc.add(0, 1, 0); } - final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,"; - final String[] tune = tuneStr.split(","); - for (Player player : server.getOnlinePlayers()) + if (loc.getBlock().getTypeId() == 0) { - final Location loc = player.getLocation(); - loc.add(0, 3, 0); - while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0) + noteBlocks.put(player, loc.getBlock()); + loc.getBlock().setType(Material.NOTE_BLOCK); + } + } + taskid = ess.scheduleSyncRepeatingTask(new Runnable() + { + int i = 0; + + @Override + public void run() + { + final String note = tune[i]; + i++; + if (i >= tune.length) { - loc.add(0, 1, 0); + Commandessentials.this.stopTune(); } - if (loc.getBlock().getTypeId() == 0) + if (note.isEmpty()) { - noteBlocks.put(player, loc.getBlock()); - loc.getBlock().setType(Material.NOTE_BLOCK); + return; } - } - taskid = ess.scheduleSyncRepeatingTask(new Runnable() - { - int i = 0; - - @Override - public void run() + Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks; + for (Player onlinePlayer : server.getOnlinePlayers()) { - final String note = tune[i]; - i++; - if (i >= tune.length) + final Block block = noteBlocks.get(onlinePlayer); + if (block == null || block.getType() != Material.NOTE_BLOCK) { - Commandessentials.this.stopTune(); - } - if (note.isEmpty()) - { - return; - } - Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks; - for (Player onlinePlayer : server.getOnlinePlayers()) - { - final Block block = noteBlocks.get(onlinePlayer); - if (block == null || block.getType() != Material.NOTE_BLOCK) - { - continue; - } - onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note)); + continue; } + onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note)); } - }, 20, 2); - return; + } + }, 20, 2); + return; } private void stopTune() diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandext.java b/Essentials/src/com/earth2me/essentials/commands/Commandext.java index dac1a3e9c..8520915df 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandext.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandext.java @@ -2,31 +2,27 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandext extends EssentialsCommand { - public Commandext() - { - super("ext"); - } + @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - extinguishPlayers(server, sender, args[0]); + extinguishPlayers(sender, args[0]); } @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -35,10 +31,10 @@ public class Commandext extends EssentialsCommand return; } - extinguishPlayers(server, user, commandLabel); + extinguishPlayers(user, args[0]); } - private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception + private void extinguishPlayers(final CommandSender sender, final String name) throws Exception { for (Player matchPlayer : server.matchPlayer(name)) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java index 7ab6b7ca9..9b2f858d6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java @@ -3,24 +3,18 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.List; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandfeed extends EssentialsCommand { - public Commandfeed() - { - super("feed"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length > 0 && user.isAuthorized("essentials.feed.others")) { - feedOtherPlayers(server, user, args[0]); + feedOtherPlayers(user, args[0]); } else { @@ -30,7 +24,7 @@ public class Commandfeed extends EssentialsCommand } } - private void feedOtherPlayers(final Server server, final CommandSender sender, final String name) + private void feedOtherPlayers(final CommandSender sender, final String name) { final List<Player> players = server.matchPlayer(name); if (players.isEmpty()) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java index 868924a27..87d564c90 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java @@ -1,7 +1,6 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.entity.Fireball; import org.bukkit.entity.SmallFireball; import org.bukkit.util.Vector; @@ -9,13 +8,8 @@ import org.bukkit.util.Vector; public class Commandfireball extends EssentialsCommand { - public Commandfireball() - { - super("fireball"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { boolean small = false; if (args.length > 0 && args[0].equalsIgnoreCase("small")) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index 396e3bef2..f951eb19b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -4,35 +4,29 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.Locale; import org.bukkit.GameMode; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandgamemode extends EssentialsCommand { - public Commandgamemode() - { - super("gamemode"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - gamemodeOtherPlayers(server, sender, args[0]); + gamemodeOtherPlayers(sender, args[0]); } @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.gamemode.others")) { - gamemodeOtherPlayers(server, user, args[0]); + gamemodeOtherPlayers(user, args[0]); return; } @@ -40,7 +34,7 @@ public class Commandgamemode extends EssentialsCommand user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName())); } - private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name) + private void gamemodeOtherPlayers(final CommandSender sender, final String name) { for (Player matchPlayer : server.matchPlayer(name)) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java index 9429bc5a8..560541de6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java @@ -1,20 +1,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; public class Commandgc extends EssentialsCommand { - public Commandgc() - { - super("gc"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024))); sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024))); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java index c7f54c593..b4d3c2e00 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java @@ -2,23 +2,17 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandgetpos extends EssentialsCommand { - public Commandgetpos() - { - super("getpos"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length > 0 && user.isAuthorized("essentials.getpos.others")) { - final IUser otherUser = getPlayer(server, args, 0); + final IUser otherUser = getPlayer(args, 0); outputPosition(user, otherUser.getLocation(), user.getLocation()); } else @@ -26,18 +20,18 @@ public class Commandgetpos extends EssentialsCommand outputPosition(user, user.getLocation(), null); } } - + @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - final IUser user = getPlayer(server, args, 0); + final IUser user = getPlayer(args, 0); outputPosition(sender, user.getLocation(), null); } - + //TODO: Translate private void outputPosition(final CommandSender sender, final Location coords, final Location distance) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 08239b32b..717ff0bff 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -6,7 +6,6 @@ import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import java.util.Locale; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -15,14 +14,9 @@ import org.bukkit.inventory.ItemStack; public class Commandgive extends EssentialsCommand { - public Commandgive() - { - super("give"); - } - //TODO: move these messages to message file @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { @@ -39,7 +33,7 @@ public class Commandgive extends EssentialsCommand throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname); } - final IUser giveTo = getPlayer(server, args, 0); + final IUser giveTo = getPlayer(args, 0); int defaultStackSize = 0; int oversizedStackSize = 0; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java index 0a1ca4dd0..6be1a2e9c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java @@ -2,42 +2,36 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandgod extends EssentialsCommand { - public Commandgod() - { - super("god"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - godOtherPlayers(server, sender, args[0]); + godOtherPlayers(sender, args[0]); } @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.god.others")) { - godOtherPlayers(server, user, args[0]); + godOtherPlayers(user, args[0]); return; } user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled")))); } - private void godOtherPlayers(final Server server, final CommandSender sender, final String name) + private void godOtherPlayers(final CommandSender sender, final String name) { for (Player matchPlayer : server.matchPlayer(name)) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java index 578457bbb..b27daabc8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java @@ -4,27 +4,21 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.user.UserData.TimestampType; import java.util.List; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandheal extends EssentialsCommand { - public Commandheal() - { - super("heal"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { - + if (args.length > 0 && user.isAuthorized("essentials.heal.others")) { user.checkCooldown(TimestampType.LASTHEAL, ess.getGroups().getHealCooldown(user), true, "essentials.heal.cooldown.bypass"); - healOtherPlayers(server, user, args[0]); + healOtherPlayers(user, args[0]); return; } @@ -36,17 +30,17 @@ public class Commandheal extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - healOtherPlayers(server, sender, args[0]); + healOtherPlayers(sender, args[0]); } - private void healOtherPlayers(final Server server, final CommandSender sender, final String name) + private void healOtherPlayers(final CommandSender sender, final String name) { final List<Player> players = server.matchPlayer(name); if (players.isEmpty()) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 03acac872..b85ea0bd4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -4,19 +4,13 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import com.earth2me.essentials.textreader.*; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandhelp extends EssentialsCommand { - public Commandhelp() - { - super("help"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { IText output; String pageStr = args.length > 0 ? args[0] : null; @@ -45,7 +39,7 @@ public class Commandhelp extends EssentialsCommand } @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { sender.sendMessage(_("helpConsole")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java index bd383d1ce..d811004cc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java @@ -3,19 +3,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.logging.Level; -import org.bukkit.Server; import org.bukkit.entity.Player; public class Commandhelpop extends EssentialsCommand { - public Commandhelpop() - { - super("helpop"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index e1197a946..365afe30c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -2,27 +2,20 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; -import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; +import com.earth2me.essentials.api.IUser; import java.util.List; import java.util.Locale; -import lombok.Cleanup; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandhome extends EssentialsCommand { - public Commandhome() - { - super("home"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); IUser player = user; String homeName = ""; @@ -36,7 +29,7 @@ public class Commandhome extends EssentialsCommand } else { - player = getPlayer(server, nameParts, 0, true); + player = getPlayer(nameParts, 0, true); if (nameParts.length > 1) { homeName = nameParts[1]; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java index c1afd50cd..1e734d9b4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandignore extends EssentialsCommand { - public Commandignore() - { - super("ignore"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -22,7 +16,7 @@ public class Commandignore extends EssentialsCommand IUser player; try { - player = getPlayer(server, args, 0); + player = getPlayer(args, 0); } catch (NoSuchFieldException ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java index e75eeed9a..2d14b60f7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java @@ -4,19 +4,13 @@ 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; public class Commandinfo extends EssentialsCommand { - public Commandinfo() - { - super("info"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { final IText input = new TextInput(sender, "info", true, ess); final IText output = new KeywordReplacer(input, sender, ess); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index c2f5b7464..b90d7bf89 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -4,19 +4,13 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.user.Inventory; import java.util.Arrays; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandinvsee extends EssentialsCommand { - public Commandinvsee() - { - super("invsee"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length < 1 && user.getData().getInventory() == null) @@ -26,7 +20,7 @@ public class Commandinvsee extends EssentialsCommand IUser invUser = user; if (args.length == 1) { - invUser = getPlayer(server, args, 0); + invUser = getPlayer(args, 0); } user.acquireWriteLock(); if (invUser == user && user.getData().getInventory() != null) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 84165a2ea..66756fe1f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -6,20 +6,14 @@ import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import java.util.Locale; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; public class Commanditem extends EssentialsCommand { - public Commanditem() - { - super("item"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -29,7 +23,7 @@ public class Commanditem extends EssentialsCommand final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); if (!user.isAuthorized("essentials.itemspawn.item-" + itemname) - && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) + && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) { throw new Exception(_("cantSpawnItem", itemname)); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java index 2fff20e8c..07d88eac6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -8,13 +7,8 @@ import org.bukkit.inventory.ItemStack; public class Commanditemdb extends EssentialsCommand { - public Commanditemdb() - { - super("find"); - } - @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { ItemStack itemStack = null; if (args.length < 1) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java index 051bcf710..6cdbe4b0b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java @@ -1,19 +1,13 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Util; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandjails extends EssentialsCommand { - public Commandjails() - { - super("jails"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java index cee2134de..966ea419b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java @@ -5,19 +5,13 @@ import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandjump extends EssentialsCommand { - public Commandjump() - { - super("jump"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { Location loc; final Location cloc = user.getLocation(); @@ -34,7 +28,7 @@ public class Commandjump extends EssentialsCommand throw new Exception(_("jumpError"), ex); } - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index 5a1a83cf6..981d52db4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -3,27 +3,21 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandkick extends EssentialsCommand { - public Commandkick() - { - super("kick"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - final IUser user = getPlayer(server, args, 0); + final IUser user = getPlayer(args, 0); if (user.isAuthorized("essentials.kick.exempt")) { throw new Exception(_("kickExempt")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java index 6d97b6af9..8f8f10bf7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java @@ -1,20 +1,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandkickall extends EssentialsCommand { - public Commandkickall() - { - super("kickall"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { for (Player onlinePlayer : server.getOnlinePlayers()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java index e56f9d67b..f0d291c1a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java @@ -1,7 +1,6 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; @@ -9,13 +8,8 @@ import org.bukkit.event.entity.EntityDamageEvent; public class Commandkill extends EssentialsCommand { - public Commandkill() - { - super("kill"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java index b9679e8b9..b70243ad4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java @@ -5,7 +5,6 @@ import static com.earth2me.essentials.I18n._; import java.util.Collections; import java.util.Locale; import org.bukkit.Chunk; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Animals; @@ -26,14 +25,9 @@ import org.bukkit.event.entity.EntityDeathEvent; public class Commandkillall extends EssentialsCommand { - public Commandkillall() - { - super("killall"); - } - //TODO: Tidy - missed this during command cleanup @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { String type = "all"; int radius = -1; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java index 4d764394b..c8abd6a81 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java @@ -1,21 +1,18 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.*; -import com.earth2me.essentials.api.IUser; import static com.earth2me.essentials.I18n._; -import java.util.*; -import org.bukkit.Server; +import com.earth2me.essentials.Kit; +import com.earth2me.essentials.Trade; +import com.earth2me.essentials.api.IUser; +import java.util.List; +import java.util.Locale; +import java.util.Map; public class Commandkit extends EssentialsCommand { - public Commandkit() - { - super("kit"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -48,7 +45,7 @@ public class Commandkit extends EssentialsCommand charge.isAffordableFor(user); Kit.expandItems(ess, user, items); - + charge.charge(user); user.sendMessage(_("kitGive", kitName)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java index 73ab6db4e..a5dd94556 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java @@ -4,7 +4,6 @@ import com.earth2me.essentials.api.ISettings; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Player; @@ -12,13 +11,8 @@ import org.bukkit.entity.Player; public class Commandlightning extends EssentialsCommand { - public Commandlightning() - { - super("lightning"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { IUser user = null; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index c7b7546cb..305ba29bf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -4,20 +4,14 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; import java.util.*; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandlist extends EssentialsCommand { - public Commandlist() - { - super("list"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { boolean showhidden = false; if (sender instanceof Player) @@ -50,13 +44,16 @@ public class Commandlist extends EssentialsCommand online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers()); } sender.sendMessage(online); - + boolean sortListByGroups = false; ISettings settings = ess.getSettings(); settings.acquireReadLock(); - try { + try + { sortListByGroups = settings.getData().getCommands().getList().isSortByGroups(); - } finally { + } + finally + { settings.unlock(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index ad6928b69..46979b31e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -3,21 +3,15 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.List; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandmail extends EssentialsCommand { - public Commandmail() - { - super("mail"); - } - //TODO: Tidy this up @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) { @@ -38,7 +32,7 @@ public class Commandmail extends EssentialsCommand { if (!user.isAuthorized("essentials.mail.send")) { - throw new Exception(_("noPerm","essentials.mail.send")); + throw new Exception(_("noPerm", "essentials.mail.send")); } Player player = server.getPlayer(args[1]); @@ -66,7 +60,7 @@ public class Commandmail extends EssentialsCommand { if (!user.isAuthorized("essentials.mail.sendall")) { - throw new Exception(_("noPerm","essentials.mail.sendall")); + throw new Exception(_("noPerm", "essentials.mail.sendall")); } ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + getFinalArg(args, 1))); user.sendMessage(_("mailSent")); @@ -83,15 +77,15 @@ public class Commandmail extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) { - throw new Exception(_("onlyPlayers", commandLabel + " read")); + throw new Exception(_("onlyPlayers", commandName + " read")); } else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) { - throw new Exception(_("onlyPlayers", commandLabel + " clear")); + throw new Exception(_("onlyPlayers", commandName + " clear")); } else if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java index 2226bedef..0504d0f65 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandme extends EssentialsCommand { - public Commandme() - { - super("me"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (user.getData().isMuted()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java index 9bb5c715d..c36de8d6b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java @@ -4,19 +4,13 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; import java.util.Locale; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandmore extends EssentialsCommand { - public Commandmore() - { - super("more"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { final ItemStack stack = user.getItemInHand(); if (stack == null) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java index 78ca5c306..4958d774e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java @@ -4,19 +4,13 @@ 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; public class Commandmotd extends EssentialsCommand { - public Commandmotd() - { - super("motd"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { final IText input = new TextInput(sender, "motd", true, ess); final IText output = new KeywordReplacer(input, sender, ess); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java index b95fc609b..2b513d9c0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java @@ -6,20 +6,14 @@ import com.earth2me.essentials.api.IReplyTo; import com.earth2me.essentials.api.IUser; import java.util.List; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandmsg extends EssentialsCommand { - public Commandmsg() - { - super("msg"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception + public void run(final CommandSender sender, String[] args) throws Exception { if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index a3dcf3ce1..1019cf136 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -5,19 +5,13 @@ import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import com.earth2me.essentials.user.UserData.TimestampType; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandmute extends EssentialsCommand { - public Commandmute() - { - super("mute"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -25,7 +19,7 @@ public class Commandmute extends EssentialsCommand } @Cleanup - final IUser player = getPlayer(server, args, 0, true); + final IUser player = getPlayer(args, 0, true); player.acquireReadLock(); if (!player.getData().isMuted() && player.isAuthorized("essentials.mute.exempt")) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java index e667bb376..0fb2900c6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java @@ -3,7 +3,6 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,22 +10,17 @@ import org.bukkit.entity.Player; public class Commandnear extends EssentialsCommand { - public Commandnear() - { - super("near"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { long radius = 200; IUser otherUser = null; - + if (args.length > 0) { try { - otherUser = getPlayer(server, args, 0); + otherUser = getPlayer(args, 0); } catch (Exception ex) { @@ -51,22 +45,22 @@ public class Commandnear extends EssentialsCommand } if (otherUser == null || user.isAuthorized("essentials.near.others")) { - user.sendMessage(_("nearbyPlayers", getLocal(server, otherUser == null ? user : otherUser, radius))); + user.sendMessage(_("nearbyPlayers", getLocal(otherUser == null ? user : otherUser, radius))); } else { user.sendMessage(_("noAccessCommand")); } } - + @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { - + IUser otherUser = null; if (args.length > 0) { - otherUser = getPlayer(server, args, 0); + otherUser = getPlayer(args, 0); } else { @@ -83,16 +77,16 @@ public class Commandnear extends EssentialsCommand { } } - sender.sendMessage(_("nearbyPlayers", getLocal(server, otherUser, radius))); + sender.sendMessage(_("nearbyPlayers", getLocal(otherUser, radius))); } - - private String getLocal(final Server server, final IUser user, final long radius) + + private String getLocal(final IUser user, final long radius) { final Location loc = user.getLocation(); final World world = loc.getWorld(); final StringBuilder output = new StringBuilder(); final long radiusSquared = radius * radius; - + for (Player onlinePlayer : server.getOnlinePlayers()) { final IUser player = ess.getUser(onlinePlayer); @@ -103,7 +97,7 @@ public class Commandnear extends EssentialsCommand { continue; } - + final long delta = (long)playerLoc.distanceSquared(loc); if (delta < radiusSquared) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java index 79fe7b329..58daba11e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java @@ -12,13 +12,8 @@ import org.bukkit.entity.Player; public class Commandnick extends EssentialsCommand { - public Commandnick() - { - super("nick"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -37,15 +32,15 @@ public class Commandnick extends EssentialsCommand { throw new Exception(_("nickOthersPermission")); } - setNickname(server, getPlayer(server, args, 0), formatNickname(user, args[1])); + setNickname(getPlayer(args, 0), formatNickname(user, args[1])); user.sendMessage(_("nickChanged")); return; } - setNickname(server, user, formatNickname(user, args[0])); + setNickname(user, formatNickname(user, args[0])); } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { @@ -64,7 +59,7 @@ public class Commandnick extends EssentialsCommand } else { - setNickname(server, getPlayer(server, args, 0), formatNickname(null, args[1])); + setNickname(getPlayer(args, 0), formatNickname(null, args[1])); } sender.sendMessage(_("nickChanged")); } @@ -84,7 +79,7 @@ public class Commandnick extends EssentialsCommand { try { - setNickname(server, ess.getUser(player), "off"); + setNickname(ess.getUser(player), "off"); } catch (Exception ex) { @@ -92,7 +87,7 @@ public class Commandnick extends EssentialsCommand } } - private void setNickname(final Server server, final IUser target, final String nick) throws Exception + private void setNickname(final IUser target, final String nick) throws Exception { if (nick.matches("[^a-zA-Z_0-9]")) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java index df497a352..b508e19fa 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -13,13 +12,8 @@ import org.bukkit.entity.TNTPrimed; public class Commandnuke extends EssentialsCommand { - public Commandnuke() - { - super("nuke"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException + protected void run(final CommandSender sender, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException { List<Player> targets; if (args.length > 0) @@ -28,7 +22,7 @@ public class Commandnuke extends EssentialsCommand int pos = 0; for (String arg : args) { - targets.add(getPlayer(server, args, pos)); + targets.add(getPlayer(args, pos)); pos++; } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java index daddce587..b7261aab5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java @@ -3,25 +3,19 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.entity.Player; public class Commandpay extends EssentialsCommand { - public Commandpay() - { - super("pay"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 2) { throw new NotEnoughArgumentsException(); } - + if (args[0] == "") { throw new NotEnoughArgumentsException("You need to specify a player to pay."); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandping.java b/Essentials/src/com/earth2me/essentials/commands/Commandping.java index 758852ed6..b5ab2bd18 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandping.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandping.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandping extends EssentialsCommand { - public Commandping() - { - super("ping"); - } - @Override - public void run(final Server server, final IUser player, final String commandLabel, final String[] args) throws Exception + public void run(final IUser player, final String[] args) throws Exception { player.sendMessage(_("pong")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java index a1c91536a..7a2029ac4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java @@ -7,19 +7,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandpowertool extends EssentialsCommand { - public Commandpowertool() - { - super("powertool"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { String command = getFinalArg(args, 0); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java index d1a44fd7e..74205cda5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandpowertooltoggle extends EssentialsCommand { - public Commandpowertooltoggle() - { - super("powertooltoggle"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (!user.getData().hasPowerTools()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java index 2de416acb..9d84ded94 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java @@ -4,7 +4,6 @@ import com.earth2me.essentials.DescParseTickFormat; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.*; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -22,13 +21,8 @@ public class Commandptime extends EssentialsCommand getAliases.add("display"); } - public Commandptime() - { - super("ptime"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { // Which Players(s) / Users(s) are we interested in? String userSelector = null; @@ -36,7 +30,7 @@ public class Commandptime extends EssentialsCommand { userSelector = args[1]; } - Set<IUser> users = getUsers(server, sender, userSelector); + Set<IUser> users = getUsers(sender, userSelector); // If no arguments we are reading the time if (args.length == 0) @@ -181,7 +175,7 @@ public class Commandptime extends EssentialsCommand /** * Used to parse an argument of the type "users(s) selector" */ - private Set<IUser> getUsers(final Server server, final CommandSender sender, final String selector) throws Exception + private Set<IUser> getUsers(final CommandSender sender, final String selector) throws Exception { final Set<IUser> users = new TreeSet<IUser>(); // If there is no selector we want the sender itself. Or all users if sender isn't a user. diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java index fb8cc7040..ee3acc1b8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -4,20 +4,14 @@ import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IReplyTo; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandr extends EssentialsCommand { - public Commandr() - { - super("r"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -58,4 +52,10 @@ public class Commandr extends EssentialsCommand } } } + + @Override + public String getPermission() + { + return "essentials.msg"; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java index 61566c215..3ea171c95 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java @@ -4,20 +4,14 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import java.util.Locale; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandrealname extends EssentialsCommand { - public Commandrealname() - { - super("realname"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java index 28c8da441..78314401b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.Locale; import org.bukkit.Chunk; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.*; @@ -12,12 +11,6 @@ import org.bukkit.entity.*; public class Commandremove extends EssentialsCommand { - public Commandremove() - { - super("remove"); - } - - private enum ToRemove { DROPS, @@ -29,7 +22,7 @@ public class Commandremove extends EssentialsCommand } @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -64,7 +57,7 @@ public class Commandremove extends EssentialsCommand } @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { @@ -92,8 +85,9 @@ public class Commandremove extends EssentialsCommand protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception { int removed = 0; - if (radius > 0) { - radius*=radius; + if (radius > 0) + { + radius *= radius; } for (Chunk chunk : world.getLoadedChunks()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index 0847302b2..8cae67a6a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -7,19 +7,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandrepair extends EssentialsCommand { - public Commandrepair() - { - super("repair"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java index d87c4f41b..a696469ad 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java @@ -4,19 +4,13 @@ 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; public class Commandrules extends EssentialsCommand { - public Commandrules() - { - super("rules"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { final IText input = new TextInput(sender, "rules", true, ess); final IText output = new KeywordReplacer(input, sender, ess); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index 1510c1531..12180f274 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -4,19 +4,13 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import com.earth2me.essentials.user.UserData.TimestampType; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandseen extends EssentialsCommand { - public Commandseen() - { - super("seen"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -24,7 +18,7 @@ public class Commandseen extends EssentialsCommand } try { - IUser u = getPlayer(server, args, 0); + IUser u = getPlayer(args, 0); sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getTimestamp(TimestampType.LOGIN)))); } catch (NoSuchFieldException e) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 8697e8762..6b6390a18 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -8,19 +8,13 @@ import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import java.util.Locale; import java.util.logging.Level; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandsell extends EssentialsCommand { - public Commandsell() - { - super("sell"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index 134b122af..62296fc40 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -6,18 +6,12 @@ import java.util.HashMap; import java.util.Locale; import lombok.Cleanup; import org.bukkit.Location; -import org.bukkit.Server; public class Commandsethome extends EssentialsCommand { - public Commandsethome() - { - super("sethome"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, String[] args) throws Exception + public void run(final IUser user, String[] args) throws Exception { if (args.length > 0) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java index efef540b9..ab7fe2c3f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandsetjail extends EssentialsCommand { - public Commandsetjail() - { - super("setjail"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java index b4524b041..38f18db2b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java @@ -3,25 +3,20 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; public class Commandsetwarp extends EssentialsCommand { - public Commandsetwarp() - { - super("setwarp"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - - if (args[0].matches("[0-9]+")) { + + if (args[0].matches("[0-9]+")) + { throw new NotEnoughArgumentsException(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java index 0a689755a..9e9a0e71e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java @@ -2,19 +2,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandsetworth extends EssentialsCommand { - public Commandsetworth() - { - super("setworth"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 2) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java index 495393290..a4e8127b3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandsocialspy extends EssentialsCommand { - public Commandsocialspy() - { - super("socialspy"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? _("enabled") : _("disabled"))); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java index 5c264c084..58703f13e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java @@ -7,19 +7,13 @@ import com.earth2me.essentials.Util; import java.util.Locale; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.block.CreatureSpawner; public class Commandspawner extends EssentialsCommand { - public Commandspawner() - { - super("spawner"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { if (args.length < 1 || args[0].length() < 2) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index ba6255765..5f581580e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -9,20 +9,14 @@ import java.util.Locale; 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.*; public class Commandspawnmob extends EssentialsCommand { - public Commandspawnmob() - { - super("spawnmob"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -79,7 +73,7 @@ public class Commandspawnmob extends EssentialsCommand IUser otherUser = null; if (args.length >= 3) { - otherUser = getPlayer(ess.getServer(), args, 2); + otherUser = getPlayer(ess.getServer(), args, 2); } final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation(); final Location sloc = Util.getSafeDestination(loc); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java index d73fdf13e..771c7bbc1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java @@ -1,27 +1,21 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; public class Commandsudo extends EssentialsCommand { - public Commandsudo() - { - super("sudo"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { throw new NotEnoughArgumentsException(); } - final IUser user = getPlayer(server, args, 0, false); + final IUser user = getPlayer(args, 0, false); final String command = args[1]; final String[] arguments = new String[args.length - 2]; if (arguments.length > 0) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java index 25c77856e..3560d5340 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandsuicide extends EssentialsCommand { - public Commandsuicide() - { - super("suicide"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { user.setHealth(0); user.sendMessage(_("suicideMessage")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java index 7fc31130c..c43e64908 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java @@ -6,26 +6,21 @@ import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import com.earth2me.essentials.user.Ban; -import org.bukkit.Server; +import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandtempban extends EssentialsCommand { - public Commandtempban() - { - super("tempban"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { throw new NotEnoughArgumentsException(); } - final IUser user = getPlayer(server, args, 0, true); + final IUser user = getPlayer(args, 0, true); if (user.getBase() instanceof OfflinePlayer) { if (sender instanceof Player diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java index a682ce0f5..cdb132c4a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java @@ -2,19 +2,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.World; public class Commandthunder extends EssentialsCommand { - public Commandthunder() - { - super("thunder"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { 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 51fbd9e87..579458cb5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -4,7 +4,6 @@ import com.earth2me.essentials.DescParseTickFormat; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import java.util.*; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -12,13 +11,8 @@ import org.bukkit.entity.Player; public class Commandtime extends EssentialsCommand { - public Commandtime() - { - super("time"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { // Which World(s) are we interested in? String worldSelector = null; @@ -26,7 +20,7 @@ public class Commandtime extends EssentialsCommand { worldSelector = args[1]; } - final Set<World> worlds = getWorlds(server, sender, worldSelector); + final Set<World> worlds = getWorlds(sender, worldSelector); // If no arguments we are reading the time if (args.length == 0) @@ -104,7 +98,7 @@ public class Commandtime extends EssentialsCommand /** * Used to parse an argument of the type "world(s) selector" */ - private Set<World> getWorlds(final Server server, final CommandSender sender, final String selector) throws Exception + private Set<World> getWorlds(final CommandSender sender, final String selector) throws Exception { final Set<World> worlds = new TreeSet<World>(new WorldNameComparator()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 04b605468..93acbdc91 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -6,20 +6,15 @@ import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import com.earth2me.essentials.user.UserData.TimestampType; import lombok.Cleanup; -import org.bukkit.Server; +import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandtogglejail extends EssentialsCommand { - public Commandtogglejail() - { - super("togglejail"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -27,7 +22,7 @@ public class Commandtogglejail extends EssentialsCommand } @Cleanup - final IUser player = getPlayer(server, args, 0, true); + final IUser player = getPlayer(args, 0, true); player.acquireReadLock(); if (args.length >= 2 && !player.getData().isJailed()) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java index 30518ea0b..480fed1ec 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java @@ -4,24 +4,18 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtop extends EssentialsCommand { - public Commandtop() - { - super("top"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { 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), TeleportCause.COMMAND); + user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(commandName, ess), TeleportCause.COMMAND); user.sendMessage(_("teleportTop")); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java index b051aa313..fa5969718 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -5,20 +5,14 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtp extends EssentialsCommand { - public Commandtp() - { - super("tp"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { switch (args.length) { @@ -27,14 +21,14 @@ public class Commandtp extends EssentialsCommand case 1: @Cleanup - final IUser player = getPlayer(server, args, 0); + final IUser player = getPlayer(args, 0); player.acquireReadLock(); if (!player.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", player.getDisplayName())); } user.sendMessage(_("teleporting")); - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); user.getTeleport().teleport(player, charge, TeleportCause.COMMAND); throw new NoChargeException(); @@ -46,8 +40,8 @@ public class Commandtp extends EssentialsCommand throw new Exception("You need access to /tpohere to teleport other players."); } user.sendMessage(_("teleporting")); - final IUser target = getPlayer(server, args, 0); - final IUser toPlayer = getPlayer(server, args, 1); + final IUser target = getPlayer(args, 0); + final IUser toPlayer = getPlayer(args, 1); target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND); target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName())); break; @@ -55,7 +49,7 @@ public class Commandtp extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2) { @@ -63,8 +57,8 @@ public class Commandtp extends EssentialsCommand } sender.sendMessage(_("teleporting")); - final IUser target = getPlayer(server, args, 0); - final IUser toPlayer = getPlayer(server, args, 1); + final IUser target = getPlayer(args, 0); + final IUser toPlayer = getPlayer(args, 1); target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND); target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java index 599ae334b..cd0232c53 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java @@ -3,18 +3,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; public class Commandtpa extends EssentialsCommand { - public Commandtpa() - { - super("tpa"); - } - @Override - public void run(Server server, IUser user, String commandLabel, String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -22,7 +16,7 @@ public class Commandtpa extends EssentialsCommand } @Cleanup - IUser player = getPlayer(server, args, 0); + IUser player = getPlayer(args, 0); player.acquireReadLock(); if (!player.getData().isTeleportEnabled()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java index e9494db2e..5044ce140 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java @@ -3,36 +3,30 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandtpaall extends EssentialsCommand { - public Commandtpaall() - { - super("tpaall"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { if (sender instanceof Player) { - teleportAAllPlayers(server, sender, ess.getUser(sender)); + teleportAAllPlayers( sender, ess.getUser(sender)); return; } throw new NotEnoughArgumentsException(); } - final IUser player = getPlayer(server, args, 0); - teleportAAllPlayers(server, sender, player); + final IUser player = getPlayer(args, 0); + teleportAAllPlayers( sender, player); } - private void teleportAAllPlayers(final Server server, final CommandSender sender, final IUser user) + private void teleportAAllPlayers(final CommandSender sender, final IUser user) { sender.sendMessage(_("teleportAAll")); for (Player onlinePlayer : server.getOnlinePlayers()) @@ -60,7 +54,7 @@ public class Commandtpaall extends EssentialsCommand } catch (Exception ex) { - ess.showCommandError(sender, getName(), ex); + ess.showCommandError(sender, commandName, ex); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 12a471605..7c2702dc9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -4,26 +4,20 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; -import lombok.Cleanup; -import org.bukkit.Server; +import org.bukkit.OfflinePlayer; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtpaccept extends EssentialsCommand { - public Commandtpaccept() - { - super("tpaccept"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (user.getTeleportRequester() == null) { throw new Exception(_("noPendingRequest")); } - + final IUser target = user.getTeleportRequester(); if (target.getBase() instanceof OfflinePlayer || (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere"))) @@ -38,7 +32,7 @@ public class Commandtpaccept extends EssentialsCommand throw new Exception(_("requestTimedOut")); } - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); if (user.isTeleportRequestHere()) { charge.isAffordableFor(user); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java index 76a4422dd..6ae28c0da 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java @@ -3,18 +3,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; public class Commandtpahere extends EssentialsCommand { - public Commandtpahere() - { - super("tpahere"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -22,7 +16,7 @@ public class Commandtpahere extends EssentialsCommand } @Cleanup - final IUser player = getPlayer(server, args, 0); + final IUser player = getPlayer(args, 0); player.acquireReadLock(); if (!player.getData().isTeleportEnabled()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java index 9643a0ff3..0e886b0b2 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java @@ -10,25 +10,20 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtpall extends EssentialsCommand { - public Commandtpall() - { - super("tpall"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { if (sender instanceof Player) { - teleportAllPlayers(server, sender, ess.getUser(sender)); + teleportAllPlayers(sender, ess.getUser(sender)); return; } throw new NotEnoughArgumentsException(); } - final IUser player = getPlayer(server, args, 0); + final IUser player = getPlayer(args, 0); teleportAllPlayers(server, sender, player); } @@ -48,7 +43,7 @@ public class Commandtpall extends EssentialsCommand } catch (Exception ex) { - ess.showCommandError(sender, getName(), ex); + ess.showCommandError(sender, commandName, ex); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java index 6a2c787bc..9477ad059 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandtpdeny extends EssentialsCommand { - public Commandtpdeny() - { - super("tpdeny"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { final IUser player = user.getTeleportRequester(); if (player == null) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java index 065c5d2a4..76d42c6ec 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java @@ -4,28 +4,22 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtphere extends EssentialsCommand { - public Commandtphere() - { - super("tphere"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { @Cleanup - final IUser player = getPlayer(server, args, 0); + final IUser player = getPlayer(args, 0); player.acquireReadLock(); if (!player.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - player.getTeleport().teleport(user, new Trade(this.getName(), ess), TeleportCause.COMMAND); + player.getTeleport().teleport(user, new Trade(commandName, ess), TeleportCause.COMMAND); user.sendMessage(_("teleporting")); player.sendMessage(_("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 5da17488f..0c6976f89 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java @@ -3,19 +3,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; +import org.bukkit.OfflinePlayer; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtpo extends EssentialsCommand { - public Commandtpo() - { - super("tpo"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -23,7 +18,7 @@ public class Commandtpo extends EssentialsCommand } //Just basically the old tp command - final IUser player = getPlayer(server, args, 0, true); + final IUser player = getPlayer(args, 0, true); // Check if user is offline if (player.getBase() instanceof OfflinePlayer) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java index 51bc900c2..e55d7f6b5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java @@ -3,19 +3,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; +import org.bukkit.OfflinePlayer; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtpohere extends EssentialsCommand { - public Commandtpohere() - { - super("tpohere"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -23,7 +18,7 @@ public class Commandtpohere extends EssentialsCommand } //Just basically the old tphere command - final IUser player = getPlayer(server, args, 0, true); + final IUser player = getPlayer(args, 0, true); // Check if user is offline if (player.getBase() instanceof OfflinePlayer) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java index 0a85f4499..2d0149a10 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java @@ -4,19 +4,13 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandtppos extends EssentialsCommand { - public Commandtppos() - { - super("tppos"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 3) { @@ -35,7 +29,7 @@ public class Commandtppos extends EssentialsCommand { location.setPitch(Float.parseFloat(args[4])); } - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); user.sendMessage(_("teleporting")); user.getTeleport().teleport(location, charge, TeleportCause.COMMAND); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java index d2256ac72..fea85e51b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java @@ -2,18 +2,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; public class Commandtptoggle extends EssentialsCommand { - public Commandtptoggle() - { - super("tptoggle"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { user.sendMessage(user.toggleTeleportEnabled() ? _("teleportationEnabled") diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java index 314aa6420..d539f7d4b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java @@ -4,19 +4,13 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.TreeType; public class Commandtree extends EssentialsCommand { - public Commandtree() - { - super("tree"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { TreeType tree; if (args.length < 1) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java index 186420fa1..6f1b9a833 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java @@ -3,19 +3,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandunban extends EssentialsCommand { - public Commandunban() - { - super("unban"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -25,7 +19,7 @@ public class Commandunban extends EssentialsCommand try { @Cleanup - final IUser player = getPlayer(server, args, 0, true); + final IUser player = getPlayer(args, 0, true); player.acquireWriteLock(); player.getData().setBan(null); player.setBanned(false); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java index 5a48f9843..6de7cbbd9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java @@ -3,19 +3,13 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import lombok.Cleanup; -import org.bukkit.Server; import org.bukkit.command.CommandSender; public class Commandunbanip extends EssentialsCommand { - public Commandunbanip() - { - super("unbanip"); - } - @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { @@ -24,7 +18,7 @@ public class Commandunbanip extends EssentialsCommand try { @Cleanup - final IUser user = getPlayer(server, args, 0, true); + final IUser user = getPlayer(args, 0, true); user.acquireReadLock(); ess.getServer().unbanIP(user.getData().getIpAddress()); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index 27ba32faf..e79167f15 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -7,19 +7,13 @@ import java.util.List; import java.util.Locale; import lombok.Cleanup; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; public class Commandunlimited extends EssentialsCommand { - public Commandunlimited() - { - super("unlimited"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -31,9 +25,9 @@ public class Commandunlimited extends EssentialsCommand if (args.length > 1 && user.isAuthorized("essentials.unlimited.others")) { - target = getPlayer(server, args, 1); + target = getPlayer(args, 1); target.acquireReadLock(); - } + } if (args[0].equalsIgnoreCase("list")) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index fab643f7e..2d6f32ca9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -8,7 +8,6 @@ import com.earth2me.essentials.api.IWarps; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -17,13 +16,8 @@ public class Commandwarp extends EssentialsCommand { private final static int WARPS_PER_PAGE = 20; - public Commandwarp() - { - super("warp"); - } - @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length == 0 || args[0].matches("[0-9]+")) { @@ -53,7 +47,7 @@ public class Commandwarp extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 2 || args[0].matches("[0-9]+")) { @@ -86,7 +80,7 @@ public class Commandwarp extends EssentialsCommand while (iterator.hasNext()) { final String warpName = iterator.next(); - if (ess.getSettings().getPerWarpPermission() && !((User)sender).isAuthorized("essentials.warp." + warpName)) + if (ess.getSettings().getPerWarpPermission() && !((IUser)sender).isAuthorized("essentials.warp." + warpName)) { iterator.remove(); } @@ -114,7 +108,7 @@ public class Commandwarp extends EssentialsCommand private void warpUser(final IUser user, final String name) throws Exception { - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, 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 ee2156251..051bc24d1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java @@ -2,21 +2,15 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; public class Commandweather extends EssentialsCommand { - public Commandweather() - { - super("weather"); - } - //TODO: Remove duplication @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { if (args.length < 1) { @@ -45,11 +39,11 @@ public class Commandweather extends EssentialsCommand //TODO: Translate these @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, 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 + " <world> <storm/sun> [duration]"); + throw new Exception("When running from console, usage is: /" + commandName + " <world> <storm/sun> [duration]"); } final boolean isStorm = args[1].equalsIgnoreCase("storm"); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 8dcd3ffa5..637739714 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -19,7 +19,7 @@ public class Commandwhois extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index bfb56543c..26413fc4e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -5,20 +5,14 @@ import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IUser; import java.util.List; import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.World; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Commandworld extends EssentialsCommand { - public Commandworld() - { - super("world"); - } - @Override - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { World world; @@ -78,7 +72,7 @@ public class Commandworld extends EssentialsCommand final Location loc = user.getLocation(); final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5); - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); user.getTeleport().teleport(target, charge, TeleportCause.COMMAND); throw new NoChargeException(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index cdc8788c0..b36d71695 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -1,24 +1,18 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.Util; +import com.earth2me.essentials.api.IUser; import java.util.Locale; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; public class Commandworth extends EssentialsCommand { - public Commandworth() - { - super("worth"); - } - //TODO: Remove duplication @Override - public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + public void run(final IUser user, final String[] args) throws Exception { ItemStack iStack = user.getInventory().getItemInHand(); int amount = iStack.getAmount(); @@ -62,7 +56,7 @@ public class Commandworth extends EssentialsCommand } @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java index 6e679de9b..2f1cdd22b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java @@ -5,50 +5,47 @@ import com.earth2me.essentials.Trade; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IEssentialsModule; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.perm.AbstractSuperpermsPermission; import java.util.List; import java.util.logging.Logger; import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; -public abstract class EssentialsCommand implements IEssentialsCommand +public abstract class EssentialsCommand extends AbstractSuperpermsPermission implements IEssentialsCommand { - private final transient String name; + protected transient String commandName; protected transient IEssentials ess; protected transient IEssentialsModule module; + protected transient Server server; protected final static Logger logger = Logger.getLogger("Minecraft"); + private transient String permission; + private transient Permission bukkitPerm; - protected EssentialsCommand(final String name) - { - this.name = name; - } - - @Override - public void setEssentials(final IEssentials ess) + public void init(final IEssentials ess, final String commandName) { this.ess = ess; + this.server = ess.getServer(); + this.commandName = commandName; + this.permission = "essentials." + commandName; } - + @Override public void setEssentialsModule(final IEssentialsModule module) { this.module = module; } - @Override - public String getName() + protected IUser getPlayer(final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException { - return name; + return getPlayer(args, pos, false); } - protected IUser getPlayer(final Server server, final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException - { - return getPlayer(server, args, pos, false); - } - - protected IUser getPlayer(final Server server, final String[] args, final int pos, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException + protected IUser getPlayer(final String[] args, final int pos, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException { if (args.length <= pos) { @@ -89,28 +86,28 @@ public abstract class EssentialsCommand implements IEssentialsCommand } @Override - public final void run(final Server server, final IUser user, final String commandLabel, final Command cmd, final String[] args) throws Exception + public final void run(final IUser user, final Command cmd, final String[] args) throws Exception { - final Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); - run(server, user, commandLabel, args); + run(user, args); charge.charge(user); } - protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String[] args) throws Exception { - run(server, (CommandSender)user.getBase(), commandLabel, args); + run((CommandSender)user.getBase(), args); } @Override - public final void run(final Server server, final CommandSender sender, final String commandLabel, final Command cmd, final String[] args) throws Exception + public final void run(final CommandSender sender, final Command cmd, final String[] args) throws Exception { - run(server, sender, commandLabel, args); + run(sender, args); } - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + protected void run(final CommandSender sender, final String[] args) throws Exception { - throw new Exception(_("onlyPlayers", commandLabel)); + throw new Exception(_("onlyPlayers", commandName)); } public static String getFinalArg(final String[] args, final int start) @@ -126,4 +123,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand } return bldr.toString(); } + + @Override + public String getPermission() + { + return permission; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java index 66dc05ff5..ae54c75c3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java @@ -1,24 +1,22 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.api.IEssentialsModule; import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IEssentialsModule; +import com.earth2me.essentials.api.IPermission; import com.earth2me.essentials.api.IUser; -import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -public interface IEssentialsCommand +public interface IEssentialsCommand extends IPermission { - String getName(); - - void run(Server server, IUser user, String commandLabel, Command cmd, String[] args) + void run(IUser user, Command cmd, String[] args) throws Exception; - void run(Server server, CommandSender sender, String commandLabel, Command cmd, String[] args) + void run(CommandSender sender, Command cmd, String[] args) throws Exception; - void setEssentials(IEssentials ess); + void init(IEssentials ess, String commandLabel); void setEssentialsModule(IEssentialsModule module); } diff --git a/Essentials/src/com/earth2me/essentials/perm/AbstractSuperpermsPermission.java b/Essentials/src/com/earth2me/essentials/perm/AbstractSuperpermsPermission.java new file mode 100644 index 000000000..a4cef71a3 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/AbstractSuperpermsPermission.java @@ -0,0 +1,31 @@ +package com.earth2me.essentials.perm; + +import com.earth2me.essentials.Util; +import com.earth2me.essentials.api.IPermission; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + + +public abstract class AbstractSuperpermsPermission implements IPermission +{ + protected Permission bukkitPerm; + + @Override + public Permission getBukkitPermission() + { + if (bukkitPerm != null) + { + return bukkitPerm; + } + else + { + return Util.registerPermission(getPermission(), getPermissionDefault()); + } + } + + @Override + public PermissionDefault getPermissionDefault() + { + return PermissionDefault.OP; + } +} diff --git a/Essentials/src/com/earth2me/essentials/perm/Permissions.java b/Essentials/src/com/earth2me/essentials/perm/Permissions.java new file mode 100644 index 000000000..80b6abf56 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions.java @@ -0,0 +1,54 @@ +package com.earth2me.essentials.perm; + +import com.earth2me.essentials.Util; +import com.earth2me.essentials.api.IPermission; +import java.util.Locale; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + + +public enum Permissions implements IPermission +{ + AFK_OTHERS, + BALANCE_OTHERS; + private static final String base = "essentials."; + private final String permission; + private final PermissionDefault defaultPerm; + private transient Permission bukkitPerm = null; + + private Permissions() + { + this(PermissionDefault.OP); + } + + private Permissions(final PermissionDefault defaultPerm) + { + permission = base + toString().toLowerCase(Locale.ENGLISH).replace('_', '.'); + this.defaultPerm = defaultPerm; + } + + @Override + public String getPermission() + { + return permission; + } + + @Override + public Permission getBukkitPermission() + { + if (bukkitPerm != null) + { + return bukkitPerm; + } + else + { + return Util.registerPermission(getPermission(), getPermissionDefault()); + } + } + + @Override + public PermissionDefault getPermissionDefault() + { + return this.defaultPerm; + } +} diff --git a/Essentials/src/com/earth2me/essentials/user/User.java b/Essentials/src/com/earth2me/essentials/user/User.java index 780109409..2194ba3c0 100644 --- a/Essentials/src/com/earth2me/essentials/user/User.java +++ b/Essentials/src/com/earth2me/essentials/user/User.java @@ -83,7 +83,7 @@ public class User extends UserBase implements IUser { return false; } - + //TODO: switch to Superperms only return ess.getPermissionsHandler().hasPermission(base, node); } @@ -92,7 +92,7 @@ public class User extends UserBase implements IUser return isAuthorized(permission.getPermission()); } - @Override + /*@Override public boolean isAuthorized(IEssentialsCommand cmd) { return isAuthorized(cmd, "essentials."); @@ -102,7 +102,7 @@ public class User extends UserBase implements IUser public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix) { return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName())); - } + }*/ public void checkCooldown(final UserData.TimestampType cooldownType, final double cooldown, final boolean set, final String bypassPermission) throws CooldownException { diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java b/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java index 04b9d47df..0fedc33cf 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java @@ -1,7 +1,10 @@ package com.earth2me.essentials.protect; +import com.earth2me.essentials.Util; import com.earth2me.essentials.api.IPermission; import java.util.Locale; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; public enum Permissions implements IPermission @@ -12,10 +15,18 @@ public enum Permissions implements IPermission ; private static final String base = "essentials.protect."; private final String permission; + private final PermissionDefault defaultPerm; + private transient Permission bukkitPerm = null; private Permissions() { + this(PermissionDefault.OP); + } + + private Permissions(final PermissionDefault defaultPerm) + { permission = base + toString().toLowerCase(Locale.ENGLISH).replace('_', '.'); + this.defaultPerm = defaultPerm; } @Override @@ -23,4 +34,23 @@ public enum Permissions implements IPermission { return permission; } + + @Override + public Permission getBukkitPermission() + { + if (bukkitPerm != null) + { + return bukkitPerm; + } + else + { + return Util.registerPermission(getPermission(), getPermissionDefault()); + } + } + + @Override + public PermissionDefault getPermissionDefault() + { + return this.defaultPerm; + } } |