mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-18 04:21:31 +02:00
Revert to the old behavior of oversized stacks. We might remove or change this in the future.
This commit is contained in:
@@ -80,6 +80,11 @@ public final class InventoryWorkaround
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||||
|
{
|
||||||
|
return addItem(cinventory, forceDurability, false, null, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final boolean dontBreakStacks, final IEssentials ess, final ItemStack... items)
|
||||||
{
|
{
|
||||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
@@ -142,10 +147,10 @@ public final class InventoryWorkaround
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// More than a single stack!
|
// More than a single stack!
|
||||||
if (item.getAmount() > item.getType().getMaxStackSize())
|
if (item.getAmount() > (dontBreakStacks ? ess.getSettings().getDefaultStackSize() : item.getType().getMaxStackSize()))
|
||||||
{
|
{
|
||||||
ItemStack stack = item.clone();
|
ItemStack stack = item.clone();
|
||||||
stack.setAmount(item.getType().getMaxStackSize());
|
stack.setAmount(dontBreakStacks ? ess.getSettings().getDefaultStackSize() : item.getType().getMaxStackSize());
|
||||||
EnchantmentFix.setItem(cinventory, firstFree, stack);
|
EnchantmentFix.setItem(cinventory, firstFree, stack);
|
||||||
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
|
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
|
||||||
}
|
}
|
||||||
@@ -164,7 +169,7 @@ public final class InventoryWorkaround
|
|||||||
|
|
||||||
final int amount = item.getAmount();
|
final int amount = item.getAmount();
|
||||||
final int partialAmount = partialItem.getAmount();
|
final int partialAmount = partialItem.getAmount();
|
||||||
final int maxAmount = partialItem.getType().getMaxStackSize();
|
final int maxAmount = dontBreakStacks ? ess.getSettings().getDefaultStackSize() : partialItem.getType().getMaxStackSize();
|
||||||
|
|
||||||
// Check if it fully fits
|
// Check if it fully fits
|
||||||
if (amount + partialAmount <= maxAmount)
|
if (amount + partialAmount <= maxAmount)
|
||||||
|
@@ -77,7 +77,7 @@ public class Commandgive extends EssentialsCommand
|
|||||||
final User giveTo = getPlayer(server, args, 0);
|
final User giveTo = getPlayer(server, args, 0);
|
||||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
InventoryWorkaround.addItem(giveTo.getInventory(), true, true, ess, stack);
|
||||||
giveTo.updateInventory();
|
giveTo.updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@ public class Commanditem extends EssentialsCommand
|
|||||||
|
|
||||||
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||||
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
|
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
|
||||||
InventoryWorkaround.addItem(user.getInventory(), true, stack);
|
InventoryWorkaround.addItem(user.getInventory(), true, true, ess, stack);
|
||||||
user.updateInventory();
|
user.updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user