summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpay.java7
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpo.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java24
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java103
4 files changed, 111 insertions, 46 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
index 4f52eee58..9be844996 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
+import com.earth2me.essentials.Util;
public class Commandpay extends EssentialsCommand
@@ -22,6 +23,7 @@ public class Commandpay extends EssentialsCommand
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
+ Boolean foundUser = false;
for (Player p : server.matchPlayer(args[0]))
{
User u = ess.getUser(p);
@@ -30,6 +32,11 @@ public class Commandpay extends EssentialsCommand
continue;
}
user.payUser(u, amount);
+ foundUser = true;
+ }
+
+ if(foundUser == false) {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 2a9e34da8..18d818ea1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -21,9 +22,23 @@ public class Commandtpo extends EssentialsCommand
}
//Just basically the old tp command
- User p = getPlayer(server, args, 0);
- charge(user);
- user.getTeleport().now(p, false);
- user.sendMessage(Util.i18n("teleporting"));
+ User p = getPlayer(server, args, 0, true);
+ // Check if user is offline
+ if (p.getBase() instanceof OfflinePlayer)
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
+
+ // Verify permission
+ if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ {
+ charge(user);
+ user.getTeleport().now(p, false);
+ user.sendMessage(Util.i18n("teleporting"));
+ }
+ else
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
index 593d17b59..186476a50 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -21,9 +22,24 @@ public class Commandtpohere extends EssentialsCommand
}
//Just basically the old tphere command
- User p = getPlayer(server, args, 0);
- charge(user);
- p.getTeleport().now(user, false);
- user.sendMessage(Util.i18n("teleporting"));
+ User p = getPlayer(server, args, 0, true);
+
+ // Check if user is offline
+ if (p.getBase() instanceof OfflinePlayer)
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
+
+ // Verify permission
+ if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ {
+ charge(user);
+ p.getTeleport().now(user, false);
+ user.sendMessage(Util.i18n("teleporting"));
+ }
+ else
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
index 3c79df4cb..122891e02 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
@@ -33,63 +33,90 @@ public class Commandunlimited extends EssentialsCommand
if (args[0].equalsIgnoreCase("list"))
{
- StringBuilder sb = new StringBuilder();
- sb.append(Util.i18n("unlimitedItems")).append(" ");
- boolean first = true;
- List<Integer> items = target.getUnlimited();
- if (items.isEmpty())
- {
- sb.append(Util.i18n("none"));
- }
- for (Integer integer : items)
+ String list = getList(target);
+ user.sendMessage(list);
+ }
+ else if (args[0].equalsIgnoreCase("clear"))
+ {
+ List<Integer> itemList = target.getUnlimited();
+
+ int index = 0;
+ while (itemList.size() > index)
{
- if (!first)
+ Integer item = itemList.get(index);
+ if (toggleUnlimited(user, target, item.toString()) == false)
{
- sb.append(", ");
+ index++;
}
- first = false;
- String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
- sb.append(matname);
}
- user.sendMessage(sb.toString());
- return;
}
+ else
+ {
+ toggleUnlimited(user, target, args[0]);
+ }
+ }
+
+ private String getList(User target)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(Util.i18n("unlimitedItems")).append(" ");
+ boolean first = true;
+ List<Integer> items = target.getUnlimited();
+ if (items.isEmpty())
+ {
+ sb.append(Util.i18n("none"));
+ }
+ for (Integer integer : items)
+ {
+ if (!first)
+ {
+ sb.append(", ");
+ }
+ first = false;
+ String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
+ sb.append(matname);
+ }
+
+ return sb.toString();
+ }
- final ItemStack stack = ess.getItemDb().get(args[0], 1);
+ private Boolean toggleUnlimited(User user, User target, String item) throws Exception
+ {
+ ItemStack stack = ess.getItemDb().get(item, 1);
stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2));
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
- if (!user.isAuthorized("essentials.unlimited.item-all")
- && !user.isAuthorized("essentials.unlimited.item-" + itemname)
- && !user.isAuthorized("essentials.unlimited.item-" + stack.getTypeId())
- && !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
- && user.isAuthorized("essentials.unlimited.item-bucket")))
+ if (ess.getSettings().permissionBasedItemSpawn()
+ && (!user.isAuthorized("essentials.unlimited.item-all")
+ && !user.isAuthorized("essentials.unlimited.item-" + itemname)
+ && !user.isAuthorized("essentials.unlimited.item-" + stack.getTypeId())
+ && !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
+ && user.isAuthorized("essentials.unlimited.item-bucket"))))
{
user.sendMessage(Util.format("unlimitedItemPermission", itemname));
- return;
+ return false;
}
-
- if (target.hasUnlimited(stack))
+ String message = "disableUnlimited";
+ Boolean enableUnlimited = false;
+ if (!target.hasUnlimited(stack))
{
- if (user != target)
+ message = "enableUnlimited";
+ enableUnlimited = true;
+ charge(user);
+ if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack))
{
- user.sendMessage(Util.format("disableUnlimited", itemname, target.getDisplayName()));
+ target.getInventory().addItem(stack);
}
- target.sendMessage(Util.format("disableUnlimited", itemname, target.getDisplayName()));
- target.setUnlimited(stack, false);
- return;
}
- charge(user);
+
if (user != target)
{
- user.sendMessage(Util.format("enableUnlimited", itemname, target.getDisplayName()));
+ user.sendMessage(Util.format(message, itemname, target.getDisplayName()));
}
- target.sendMessage(Util.format("enableUnlimited", itemname, target.getDisplayName()));
- if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack))
- {
- target.getInventory().addItem(stack);
- }
- target.setUnlimited(stack, true);
+ target.sendMessage(Util.format(message, itemname, target.getDisplayName()));
+ target.setUnlimited(stack, enableUnlimited);
+
+ return true;
}
}