Prevent stacks of runes being consumed on one item

This commit is contained in:
AlexTheCoder 2016-08-05 14:33:21 -04:00
parent a56f72b6af
commit 599c47a8c2

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.items.CustomItem;
@ -248,8 +249,18 @@ public class RuneManager implements Listener
}
event.setCancelled(true);
ItemStack cursorAfter = null;
if (event.getCursor().getAmount() > 1)
{
cursorAfter = event.getCursor().clone();
cursorAfter.setAmount(cursorAfter.getAmount() - 1);
}
event.setCursor(new ItemStack(Material.AIR));
event.getClickedInventory().setItem(event.getSlot(), after);
if (cursorAfter != null)
{
UtilInv.insert(player, cursorAfter);
}
player.playSound(player.getLocation(), Sound.ANVIL_USE, 1.5f, 5f);
player.updateInventory();