Don't allow purchase if inv if full
This commit is contained in:
parent
4cb4f944e7
commit
074c786c35
@ -1,5 +1,6 @@
|
|||||||
package mineplex.gemhunters.shop;
|
package mineplex.gemhunters.shop;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -16,6 +17,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.gemhunters.economy.EconomyModule;
|
import mineplex.gemhunters.economy.EconomyModule;
|
||||||
@ -102,9 +104,25 @@ public class TraderNPC extends SimpleNPC
|
|||||||
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F);
|
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!UtilInv.HasSpace(player, itemStack.getType(), itemStack.getAmount()))
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main(_entity.getCustomName(), "I'm sorry you don't have enough space to hold that."));
|
||||||
|
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_economy.removeFromStore(player, cost);
|
_economy.removeFromStore(player, cost);
|
||||||
|
|
||||||
|
// Remove cost lore
|
||||||
|
ItemBuilder builder = new ItemBuilder(itemStack);
|
||||||
|
|
||||||
|
List<String> lore = builder.getLore();
|
||||||
|
lore.remove(lore.size() - 1);
|
||||||
|
builder.setLore(lore.toArray(new String[0]));
|
||||||
|
|
||||||
|
itemStack = builder.build();
|
||||||
|
|
||||||
String itemName = ItemStackFactory.Instance.GetName(itemStack, true);
|
String itemName = ItemStackFactory.Instance.GetName(itemStack, true);
|
||||||
|
|
||||||
player.sendMessage(F.main(_entity.getCustomName(), "Purchased " + F.elem(itemName) + "!"));
|
player.sendMessage(F.main(_entity.getCustomName(), "Purchased " + F.elem(itemName) + "!"));
|
||||||
|
Loading…
Reference in New Issue
Block a user