summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/InventoryWorkaround.java15
-rw-r--r--Essentials/src/com/earth2me/essentials/ItemDb.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgive.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditem.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsell.java8
-rw-r--r--Essentials/src/config.yml8
8 files changed, 33 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index e7ce92a55..ed76ef325 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -31,7 +31,7 @@ public interface ISettings extends IConf
String getCurrencySymbol();
- int getDefaultStackSize();
+ int getOversizedStackSize();
double getHealCooldown();
diff --git a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java
index 53bb5c7f7..19edce8d0 100644
--- a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java
+++ b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java
@@ -81,10 +81,10 @@ public final class InventoryWorkaround
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
- return addItem(cinventory, forceDurability, false, items);
+ return addItem(cinventory, forceDurability, 0, items);
}
- public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final boolean dontBreakStacks, final ItemStack... items)
+ public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final int oversizedStacks, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@@ -146,11 +146,12 @@ public final class InventoryWorkaround
}
else
{
+ final int maxAmount = oversizedStacks > 0 ? oversizedStacks : item.getType().getMaxStackSize();
// More than a single stack!
- if (item.getAmount() > (dontBreakStacks ? 64 : item.getType().getMaxStackSize()))
+ if (item.getAmount() > maxAmount)
{
- ItemStack stack = item.clone();
- stack.setAmount(dontBreakStacks ? 64 : item.getType().getMaxStackSize());
+ final ItemStack stack = item.clone();
+ stack.setAmount(maxAmount);
if (cinventory instanceof FakeInventory)
{
cinventory.setItem(firstFree, stack);
@@ -159,7 +160,7 @@ public final class InventoryWorkaround
{
EnchantmentFix.setItem(cinventory, firstFree, stack);
}
- item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
+ item.setAmount(item.getAmount() - maxAmount);
}
else
{
@@ -183,7 +184,7 @@ public final class InventoryWorkaround
final int amount = item.getAmount();
final int partialAmount = partialItem.getAmount();
- final int maxAmount = dontBreakStacks ? 64 : partialItem.getType().getMaxStackSize();
+ final int maxAmount = oversizedStacks > 0 ? oversizedStacks : partialItem.getType().getMaxStackSize();
// Check if it fully fits
if (amount + partialAmount <= maxAmount)
diff --git a/Essentials/src/com/earth2me/essentials/ItemDb.java b/Essentials/src/com/earth2me/essentials/ItemDb.java
index cbdca198d..021e316a8 100644
--- a/Essentials/src/com/earth2me/essentials/ItemDb.java
+++ b/Essentials/src/com/earth2me/essentials/ItemDb.java
@@ -114,7 +114,7 @@ public class ItemDb implements IConf
throw new Exception(_("unknownItemId", itemid));
}
final ItemStack retval = new ItemStack(mat);
- retval.setAmount(ess.getSettings().getDefaultStackSize());
+ retval.setAmount(mat.getMaxStackSize());
retval.setDurability(metaData);
return retval;
}
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 1e9f66c6e..aa6bb6cef 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -82,9 +82,9 @@ public class Settings implements ISettings
}
@Override
- public int getDefaultStackSize()
+ public int getOversizedStackSize()
{
- return config.getInt("default-stack-size", 64);
+ return config.getInt("oversized-stacksize", 64);
}
@Override
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
index 2147392a6..52e3375cd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
@@ -77,7 +77,11 @@ public class Commandgive extends EssentialsCommand
final User giveTo = getPlayer(server, args, 0);
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
- InventoryWorkaround.addItem(giveTo.getInventory(), true, true, stack);
+ if (giveTo.isAuthorized("essentials.oversizedstacks")) {
+ InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
+ } else {
+ InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
+ }
giveTo.updateInventory();
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
index 5f9e80ed9..a749bb0a8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
@@ -72,7 +72,11 @@ public class Commanditem extends EssentialsCommand
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
- InventoryWorkaround.addItem(user.getInventory(), true, true, stack);
+ if (user.isAuthorized("essentials.oversizedstacks")) {
+ InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
+ } else {
+ InventoryWorkaround.addItem(user.getInventory(), true, stack);
+ }
user.updateInventory();
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
index 1639f5360..512eeabe3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
@@ -119,12 +119,16 @@ public class Commandsell extends EssentialsCommand
{
continue;
}
+ if (!s.getEnchantments().equals(is.getEnchantments()))
+ {
+ continue;
+ }
max += s.getAmount();
}
if (stack)
{
- amount *= 64;
+ amount *= is.getType().getMaxStackSize();
}
if (amount < 1)
{
@@ -133,7 +137,7 @@ public class Commandsell extends EssentialsCommand
if (requireStack)
{
- amount -= amount % 64;
+ amount -= amount % is.getType().getMaxStackSize();
}
if (amount > max || amount < 1)
{
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index 77b3fc3a4..b06fdd1d4 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -53,9 +53,6 @@ teleport-delay: 0
# The delay, in seconds, required between /heal attempts
heal-cooldown: 60
-# The number of items given if the quantity parameter is left out in /item or /give.
-default-stack-size: 64
-
# What to prevent from /i /give
# e.g item-spawn-blacklist: 46,11,10
item-spawn-blacklist:
@@ -230,6 +227,11 @@ death-messages: true
no-god-in-worlds:
# - world_nether
+# Oversized stacks are stacks that ignore the normal max stacksize.
+# They can be obtained using /give and /item, if the player has essentials.oversizedstacks permission.
+# How many items should be in a oversized stack?
+oversized-stacksize: 64
+
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #