mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Also changed output when clicking the shop
Former-commit-id: 76192a6e577decc2ca592044c354f171507fab17 [formerly bc9ddf3c976c6d692c946c6498ca84c519388040] Former-commit-id: 8654537fc61cef7b8aa382bf32908f87c62aedd5
This commit is contained in:
1 parent
8a55a44131
commit
d54e69aa77
1 file changed
+17
-2
@@ -18,6 +18,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.maxgamer.quickshop.Economy.Economy;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Info;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
@@ -85,16 +86,30 @@ public class PlayerListener implements Listener {
|
||||
// Text menu
|
||||
MsgUtil.sendShopInfo(p, shop);
|
||||
shop.setSignText();
|
||||
Economy eco = plugin.getEconomy();
|
||||
double price = shop.getPrice();
|
||||
double money = plugin.getEconomy().getBalance(p.getUniqueId());
|
||||
if (shop.isSelling()) {
|
||||
double price = shop.getPrice();
|
||||
double money = plugin.getEconomy().getBalance(p.getUniqueId());
|
||||
int itemAmount = Math.min(Util.countSpace(p.getInventory(), shop.getItem()), (int) Math.floor(money / price));
|
||||
if (!shop.isUnlimited()) {
|
||||
itemAmount = Math.min(itemAmount, shop.getRemainingStock());
|
||||
}
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-buy", p, "" + itemAmount));
|
||||
} else {
|
||||
double ownerBalance = eco.getBalance(shop.getOwner());
|
||||
int items = Util.countItems(p.getInventory(), shop.getItem());
|
||||
int ownerCanAfford = (int) (ownerBalance / shop.getPrice());
|
||||
if (!shop.isUnlimited()) {
|
||||
// Amount check player amount and shop empty slot
|
||||
items = Math.min(items, shop.getRemainingSpace());
|
||||
// Amount check player selling item total cost and the shop owner's balance
|
||||
items = Math.min(items, (int) ownerCanAfford);
|
||||
}
|
||||
else if (plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
|
||||
// even if the shop is unlimited, the config option pay-unlimited-shop-owners is set to true,
|
||||
// the unlimited shop owner should have enough money.
|
||||
items = Math.min(items, (int) ownerCanAfford);
|
||||
}
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-sell", p, "" + items));
|
||||
}
|
||||
// Add the new action
|
||||
|
||||
Reference in new issue
Block a user