mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 18:14:38 +02:00
Properly handle negative /clear amounts.
This commit is contained in:
@@ -121,7 +121,8 @@ public class Commandclearinventory extends EssentialsCommand
|
|||||||
if (data == -1) // data -1 means that all subtypes will be cleared
|
if (data == -1) // data -1 means that all subtypes will be cleared
|
||||||
{
|
{
|
||||||
ItemStack stack = new ItemStack(type);
|
ItemStack stack = new ItemStack(type);
|
||||||
if (showExtended) {
|
if (showExtended)
|
||||||
|
{
|
||||||
sender.sendMessage(_("inventoryClearingAllStack", stack.getType().toString().toLowerCase(Locale.ENGLISH), player.getDisplayName()));
|
sender.sendMessage(_("inventoryClearingAllStack", stack.getType().toString().toLowerCase(Locale.ENGLISH), player.getDisplayName()));
|
||||||
}
|
}
|
||||||
player.getInventory().clear(type, data);
|
player.getInventory().clear(type, data);
|
||||||
@@ -138,6 +139,10 @@ public class Commandclearinventory extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (amount < 0)
|
||||||
|
{
|
||||||
|
amount = 1;
|
||||||
|
}
|
||||||
ItemStack stack = new ItemStack(type, amount, data);
|
ItemStack stack = new ItemStack(type, amount, data);
|
||||||
if (player.getInventory().containsAtLeast(stack, amount))
|
if (player.getInventory().containsAtLeast(stack, amount))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user