diff options
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands')
21 files changed, 69 insertions, 97 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java index e2c1b266a..2b112ffa9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java @@ -1,8 +1,9 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.permissions.WorldPermissions; public class Commandback extends EssentialsCommand @@ -10,12 +11,14 @@ public class Commandback extends EssentialsCommand @Override protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception { - if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getLastLocation().getWorld().getName())) + final String worldName = user.getData().getLastLocation().getWorldName(); + if (user.getWorld() != user.getData().getLastLocation().getBukkitLocation().getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() + && WorldPermissions.getPermission(worldName)) { - throw new Exception(_("noPerm", "essentials.world." + user.getLastLocation().getWorld().getName())); + throw new Exception(_("noPerm", "essentials.world." + worldName)); } - final Trade charge = new Trade(this.getName(), ess); + //tod - verify + final Trade charge = new Trade(this.toString(), 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 c00a0d435..e620fa52d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java @@ -10,12 +10,12 @@ public class Commandbackup extends EssentialsCommand @Override protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - final Backup backup = ess.getBackup(); + final IBackup backup = ess.getBackup(); if (backup == null) { throw new Exception(_("backupDisabled")); } - final String command = ess.getSettings().getBackupCommand(); + final String command = ess.getSettings().getData().getCommands().getBackupCommand(); if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command)) { throw new Exception(_("backupDisabled")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index 88c605f4e..d9d080441 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -50,7 +50,7 @@ public class Commandban extends EssentialsCommand else { banReason = _("defaultBanReason"); - user.setBanReason(""); + user.getData().getBan().setReason(""); } user.setBanned(true); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index e2668e562..72aa66e99 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -197,5 +197,4 @@ public class Commandessentials extends EssentialsCommand { sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage()); } - } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java index 22976ff92..d0306d76f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java @@ -1,26 +1,22 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.user.User;
+import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix;
-import org.bukkit.Server;
+import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandexp extends EssentialsCommand
{
- public Commandexp()
- {
- super("exp");
- }
-
+ //todo - fix this
@Override
- public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
- if (args.length == 0)
+ if (args.length == 0 && sender instanceof Player)
{
- showExp(user, user);
+ showExp((User)sender, (User)sender);
}
else if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java index 22e3c4eea..46ae31a16 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java @@ -1,9 +1,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.User; -import java.util.Locale; -import org.bukkit.GameMode; +import com.earth2me.essentials.api.IUser; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,13 +9,8 @@ import org.bukkit.entity.Player; public class Commandfly extends EssentialsCommand { - public Commandfly() - { - super("fly"); - } - @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 commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -28,8 +21,9 @@ public class Commandfly extends EssentialsCommand } @Override - protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception + protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception { + //todo permissions if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others")) { flyOtherPlayers(server, user, args[0]); @@ -47,7 +41,7 @@ public class Commandfly extends EssentialsCommand { for (Player matchPlayer : server.matchPlayer(name)) { - final User player = ess.getUser(matchPlayer); + final IUser player = ess.getUser(matchPlayer); if (player.isHidden()) { continue; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index 72153265e..83a2577d6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -19,7 +19,7 @@ public class Commandgamemode extends EssentialsCommand throw new NotEnoughArgumentsException(); } - gamemodeOtherPlayers(sender, args[0]); + gamemodeOtherPlayers(sender, args); } @Override @@ -27,7 +27,7 @@ public class Commandgamemode extends EssentialsCommand { if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.GAMEMODE_OTHERS.isAuthorized(user)) { - gamemodeOtherPlayers(user, args[0]); + gamemodeOtherPlayers(user, args); return; } @@ -35,7 +35,7 @@ public class Commandgamemode extends EssentialsCommand user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName())); } - private void gamemodeOtherPlayers(final CommandSender sender, final String name) + private void gamemodeOtherPlayers(final CommandSender sender, final String args[]) { for (Player matchPlayer : server.matchPlayer(args[0])) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java index dfccdd31c..3ffce7595 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java @@ -13,6 +13,7 @@ public class Commandgetpos extends EssentialsCommand { if (args.length > 0 && Permissions.GETPOS_OTHERS.isAuthorized(user)) { + //todo permissions final IUser otherUser = getPlayer(args, 0); if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden")) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index aea29cbf3..f0f0380ac 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.commands; +import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.GivePermissions; -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.utils.Util; import java.util.Locale; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java index ed82fd16d..7be212373 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java @@ -1,22 +1,16 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.User; +import com.earth2me.essentials.api.IUser; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; public class Commandhat extends EssentialsCommand { - public Commandhat() - { - super("hat"); - } - @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(IUser user, String commandLabel, String[] args) throws Exception { if (user.getItemInHand().getType() != Material.AIR) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index e6fb2e2eb..b9989ddd5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -1,16 +1,14 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.utils.textreader.TextInput; -import com.earth2me.essentials.utils.textreader.IText; -import com.earth2me.essentials.utils.textreader.TextPager; -import com.earth2me.essentials.utils.textreader.HelpInput; -import com.earth2me.essentials.utils.textreader.KeywordReplacer; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.utils.Util; import com.earth2me.essentials.api.IUser; -import com.earth2me.essentials.textreader.*; +import com.earth2me.essentials.utils.Util; +import com.earth2me.essentials.utils.textreader.HelpInput; +import com.earth2me.essentials.utils.textreader.IText; +import com.earth2me.essentials.utils.textreader.KeywordReplacer; +import com.earth2me.essentials.utils.textreader.TextInput; +import com.earth2me.essentials.utils.textreader.TextPager; import java.util.Locale; -import org.bukkit.Server; import org.bukkit.command.CommandSender; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 27e93d39e..645e8fd8b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; -import com.earth2me.essentials.utils.Util; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.permissions.Permissions; +import com.earth2me.essentials.utils.Util; import java.util.List; import java.util.Locale; import org.bukkit.Location; @@ -89,14 +89,14 @@ public class Commandhome extends EssentialsCommand throw new NoChargeException(); } - private void goHome(final User user, final User player, final String home, final Trade charge) throws Exception + private void goHome(final IUser user, final IUser player, final String home, final Trade charge) throws Exception { final Location loc = player.getHome(home); if (loc == null) { throw new NotEnoughArgumentsException(); } - if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions() + if (user.getWorld() != loc.getWorld() && ess.getSettings().getData().getGeneral().isWorldHomePermissions() && !user.isAuthorized("essentials.world." + loc.getWorld().getName())) { throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName())); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index fd6a6a167..349caaf63 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.commands; -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.inventory.ItemStack; public class Commandinvsee extends EssentialsCommand @@ -16,7 +12,7 @@ public class Commandinvsee extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - final User invUser = getPlayer(server, args, 0); + final IUser invUser = getPlayer(args, 0); user.setInvSee(true); user.openInventory(invUser.getInventory()); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 1ea96ff60..bf955fbb5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -25,25 +25,21 @@ public class Commanditem extends EssentialsCommand { throw new Exception(_("cantSpawnItem", itemname)); } + try { - stack.setAmount(Integer.parseInt(args[1])); - } - - if (args.length > 2) - { - for (int i = 2; i < args.length; i++) + if (args.length > 1 && Integer.parseInt(args[1]) > 0) { stack.setAmount(Integer.parseInt(args[1])); } - else if (ess.getSettings().getDefaultStackSize() > 0) + else if (ess.getSettings().getData().getGeneral().getDefaultStacksize() > 0) { - stack.setAmount(ess.getSettings().getDefaultStackSize()); + stack.setAmount(ess.getSettings().getData().getGeneral().getDefaultStacksize()); } - else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks")) + else if (ess.getSettings().getData().getGeneral().getOversizedStacksize()> 0 && user.isAuthorized("essentials.oversizedstacks")) { - stack.setAmount(ess.getSettings().getOversizedStackSize()); - } + stack.setAmount(ess.getSettings().getData().getGeneral().getOversizedStacksize()); + } if (args.length > 2) { for (int i = 2; i < args.length; i++) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java index bab73b196..2d71302b7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java @@ -7,7 +7,9 @@ import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.KitPermissions; import com.earth2me.essentials.settings.Kit; import java.util.Collection; +import java.util.List; import java.util.Locale; +import java.util.Map; import org.bukkit.command.CommandSender; @@ -38,7 +40,7 @@ public class Commandkit extends EssentialsCommand } else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) { - final User userTo = getPlayer(server, args, 1, true); + final IUser userTo = getPlayer(args, 1, true); final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)); giveKit(userTo, user, kitName); } @@ -50,7 +52,7 @@ public class Commandkit 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 commandLabel, final String[] args) throws Exception { if (args.length < 2) { @@ -59,14 +61,13 @@ public class Commandkit extends EssentialsCommand } else { - final User userTo = getPlayer(server, args, 1, true); + final IUser userTo = getPlayer(args, 1, true); final String kitName = args[0].toLowerCase(Locale.ENGLISH); final Kit kit = ess.getKits().getKit(kitName); + final List<String> items = Kit.getItems(userTo, kit); + Kit.expandItems(ess,userTo,items); - if (!KitPermissions.getPermission(kitName).isAuthorized(user)) - { - throw new Exception(_("noKitPermission", "essentials.kit." + kitName)); - } + //TODO: Check kit delay sender.sendMessage(_("kitGive", kitName)); @@ -86,7 +87,7 @@ public class Commandkit extends EssentialsCommand } } - private void giveKit(User userTo, User userFrom, String kitName) throws Exception + private void giveKit(IUser userTo, IUser userFrom, String kitName) throws Exception { final Map<String, Object> kit = ess.getSettings().getKit(kitName); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java index c68290c65..96670fa94 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java @@ -39,7 +39,7 @@ public class Commandspawner extends EssentialsCommand { throw new Exception(_("invalidMob")); } - if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) + if (ess.getSettings().getData().getGeneral().getPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) { throw new Exception(_("disabledToSpawnMob")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index 9b28f5d6c..35ba8dedc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.utils.DescParseTickFormat; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.Permissions; -import com.earth2me.essentials.Util; +import com.earth2me.essentials.utils.DescParseTickFormat; +import com.earth2me.essentials.utils.Util; import java.util.*; import org.bukkit.World; import org.bukkit.command.CommandSender; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java index 56041fc3e..931f50202 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java @@ -17,7 +17,7 @@ public class Commandtpo extends EssentialsCommand throw new NotEnoughArgumentsException(); case 1: - final User player = getPlayer(server, args, 0, true); + final IUser player = getPlayer(args, 0, true); if (!player.isOnline() || (player.isHidden() && !user.isAuthorized("essentials.teleport.hidden"))) { throw new NoSuchFieldException(_("playerNotFound")); @@ -37,8 +37,8 @@ public class Commandtpo extends EssentialsCommand throw new Exception(_("noPerm", "essentials.tp.others")); } user.sendMessage(_("teleporting")); - final User target = getPlayer(server, args, 0, true); - final User toPlayer = getPlayer(server, args, 1, true); + final IUser target = getPlayer(args, 0, true); + final IUser toPlayer = getPlayer(args, 1, true); if (!target.isOnline() || !toPlayer.isOnline() || ((target.isHidden() || toPlayer.isHidden()) && !user.isAuthorized("essentials.teleport.hidden"))) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java index ca50a068d..80daf2b16 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java @@ -38,14 +38,14 @@ public class Commandtppos 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 commandLabel, final String[] args) throws Exception { if (args.length < 4) { throw new NotEnoughArgumentsException(); } - User user = ess.getUser(server.getPlayer(args[0])); + IUser user = ess.getUser(server.getPlayer(args[0])); final int x = Integer.parseInt(args[1]); final int y = Integer.parseInt(args[2]); final int z = Integer.parseInt(args[3]); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java index b55bd76a4..032631056 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java @@ -1,21 +1,14 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.User; -import org.bukkit.ChatColor; -import org.bukkit.Server; +import com.earth2me.essentials.api.IUser; import org.bukkit.entity.Player; public class Commandvanish extends EssentialsCommand { - public Commandvanish() - { - super("vanish"); - } - @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(IUser user, String commandLabel, String[] args) throws Exception { if (user.isVanished()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/WarpNotFoundException.java b/Essentials/src/com/earth2me/essentials/commands/WarpNotFoundException.java index c5b592c2a..c2e9c5c44 100644 --- a/Essentials/src/com/earth2me/essentials/commands/WarpNotFoundException.java +++ b/Essentials/src/com/earth2me/essentials/commands/WarpNotFoundException.java @@ -1,4 +1,5 @@ package com.earth2me.essentials.commands; +import static com.earth2me.essentials.I18n._; public class WarpNotFoundException extends Exception |