mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 23:57:43 +01:00
Made /stack respect max stack sizes unless the user has worldguard.stack.illegitimate which will stack normally unstackable items.
This commit is contained in:
parent
321b3acf0a
commit
3f77a9b721
@ -252,6 +252,7 @@ public static void stack(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
CommandSender sender) throws CommandException {
|
CommandSender sender) throws CommandException {
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
|
boolean ignoreMax = plugin.hasPermission(player, "worldguard.stack.illegitimate");
|
||||||
|
|
||||||
ItemStack[] items = player.getInventory().getContents();
|
ItemStack[] items = player.getInventory().getContents();
|
||||||
int len = items.length;
|
int len = items.length;
|
||||||
@ -263,17 +264,14 @@ public static void stack(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
|
|
||||||
// Avoid infinite stacks and stacks with durability
|
// Avoid infinite stacks and stacks with durability
|
||||||
if (item == null || item.getAmount() <= 0
|
if (item == null || item.getAmount() <= 0
|
||||||
|| ItemType.shouldNotStack(item.getTypeId())) {
|
|| (!ignoreMax && item.getMaxStackSize() == 1)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore buckets
|
int max = ignoreMax ? 64 : item.getMaxStackSize();
|
||||||
if (item.getTypeId() >= 325 && item.getTypeId() <= 327) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.getAmount() < 64) {
|
if (item.getAmount() < max) {
|
||||||
int needed = 64 - item.getAmount(); // Number of needed items until 64
|
int needed = max - item.getAmount(); // Number of needed items until max
|
||||||
|
|
||||||
// Find another stack of the same type
|
// Find another stack of the same type
|
||||||
for (int j = i + 1; j < len; j++) {
|
for (int j = i + 1; j < len; j++) {
|
||||||
@ -281,7 +279,7 @@ public static void stack(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
|
|
||||||
// Avoid infinite stacks and stacks with durability
|
// Avoid infinite stacks and stacks with durability
|
||||||
if (item2 == null || item2.getAmount() <= 0
|
if (item2 == null || item2.getAmount() <= 0
|
||||||
|| ItemType.shouldNotStack(item.getTypeId())) {
|
|| (!ignoreMax && item.getMaxStackSize() == 1)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user