Last active
June 21, 2019 08:35
-
-
Save theresajayne/adb1412ac4ef97be1eda6a002bcebc2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Amount is now the total number of items in the chest - we will need this later | |
if (amount >= shop.getQuantity()) { | |
//We have enough items so sell to the shopper | |
player.sendMessage("You paid $" + shop.getBuyPrice() + " for " + shop.getQuantity() + " " + shop.getDescription()); | |
PayDay.getInstance().getEconomyService().subtract(player, shop.getBuyPrice()); | |
PayDay.getInstance().getEconomyService().add(shop.getPlayerName(), shop.getBuyPrice()); | |
player.getInventory().addItem(item); | |
amount = amount - shop.getQuantity(); | |
int remaining = amount; | |
chest.getInventory().clear(); | |
while (remaining > 0) { | |
if (remaining > item.getMaxStackSize()) { | |
ItemStack itemStack = new ItemStack(item.getType(), item.getMaxStackSize(),item.getDurability()); | |
chest.getInventory().addItem(itemStack); | |
remaining = remaining - item.getMaxStackSize(); | |
} else { | |
//Last bit of a stack | |
ItemStack itemStack = new ItemStack(item.getType(), remaining,item.getDurability()); | |
chest.getInventory().addItem(itemStack); | |
remaining = 0; | |
} | |
} | |
chest.update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment