summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-10-15 23:28:53 +0200
committersnowleo <schneeleo@gmail.com>2012-10-15 23:28:53 +0200
commitd82899ebd669c9f8cf29cb6cca215e0c0a41180a (patch)
treeae0685dc0b2d785986afda96b395349690c687b3
parentc74545d614cdb43611923ca153343976633adbe7 (diff)
downloadEssentials-d82899ebd669c9f8cf29cb6cca215e0c0a41180a.tar
Essentials-d82899ebd669c9f8cf29cb6cca215e0c0a41180a.tar.gz
Essentials-d82899ebd669c9f8cf29cb6cca215e0c0a41180a.tar.lz
Essentials-d82899ebd669c9f8cf29cb6cca215e0c0a41180a.tar.xz
Essentials-d82899ebd669c9f8cf29cb6cca215e0c0a41180a.zip
Correctly implement charges in /more all
-rw-r--r--Essentials/src/net/ess3/commands/Commandmore.java62
1 files changed, 48 insertions, 14 deletions
diff --git a/Essentials/src/net/ess3/commands/Commandmore.java b/Essentials/src/net/ess3/commands/Commandmore.java
index 26c7d7de3..587852c29 100644
--- a/Essentials/src/net/ess3/commands/Commandmore.java
+++ b/Essentials/src/net/ess3/commands/Commandmore.java
@@ -2,8 +2,10 @@ package net.ess3.commands;
import java.util.Locale;
import static net.ess3.I18n._;
+import net.ess3.api.ChargeException;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
+import net.ess3.economy.Trade;
import net.ess3.permissions.Permissions;
import org.bukkit.inventory.ItemStack;
@@ -29,37 +31,69 @@ public class Commandmore extends EssentialsCommand
{
if (stack == null)
{
- throw new Exception(_("cantSpawnItem", "Air"));
+ if (stacks.length == 1)
+ {
+ throw new Exception(_("cantSpawnItem", "Air"));
+ }
+ else
+ {
+ continue;
+ }
}
ISettings settings = ess.getSettings();
-
+
int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
-
- if (stack.getAmount() >= (Permissions.OVERSIZEDSTACKS.isAuthorized(user)
- ? oversizedStackSize
- : defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize()))
+
+ int newAmount = Permissions.OVERSIZEDSTACKS.isAuthorized(user)
+ ? oversizedStackSize
+ : defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize();
+ if (stack.getAmount() >= newAmount)
{
- throw new NoChargeException();
+ if (stacks.length == 1)
+ {
+ throw new NoChargeException();
+ }
+ else
+ {
+ continue;
+ }
}
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (!Permissions.ITEMSPAWN.isAuthorized(user, stack))
{
- throw new Exception(_("cantSpawnItem", itemname));
- }
- if (Permissions.OVERSIZEDSTACKS.isAuthorized(user))
- {
- stack.setAmount(oversizedStackSize);
+ if (stacks.length == 1)
+ {
+ throw new Exception(_("cantSpawnItem", itemname));
+ }
+ else
+ {
+ continue;
+ }
}
- else
+ if (stack.getAmount() < newAmount && stacks.length > 1)
{
- stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize());
+ Trade trade = new Trade("more", ess);
+ try
+ {
+ trade.charge(user);
+ }
+ catch (ChargeException ex)
+ {
+ user.sendMessage(ex.getMessage());
+ break;
+ }
}
+ stack.setAmount(newAmount);
}
if (stacks.length > 1)
{
user.getPlayer().getInventory().setContents(stacks);
}
user.getPlayer().updateInventory();
+ if (stacks.length > 1)
+ {
+ throw new NoChargeException();
+ }
}
}