Add option to collect all balance from a single shop.
This commit is contained in:
parent
74e0f8c5b5
commit
7cfd147f1e
|
|
@ -6,6 +6,7 @@ import com.alttd.playershops.config.ShopTypeConfig;
|
||||||
import com.alttd.playershops.conversation.ConversationManager;
|
import com.alttd.playershops.conversation.ConversationManager;
|
||||||
import com.alttd.playershops.conversation.ConversationType;
|
import com.alttd.playershops.conversation.ConversationType;
|
||||||
import com.alttd.playershops.shop.PlayerShop;
|
import com.alttd.playershops.shop.PlayerShop;
|
||||||
|
import com.alttd.playershops.shop.ShopType;
|
||||||
import com.alttd.playershops.utils.EconomyUtils;
|
import com.alttd.playershops.utils.EconomyUtils;
|
||||||
import com.alttd.playershops.utils.ShopUtil;
|
import com.alttd.playershops.utils.ShopUtil;
|
||||||
import com.alttd.playershops.utils.Util;
|
import com.alttd.playershops.utils.Util;
|
||||||
|
|
@ -59,6 +60,7 @@ public class ShopManagementGui extends AbstractGui {
|
||||||
inventory.setItem(GuiIcon.MANAGE_SHOP.getSlot(), shopIcon);
|
inventory.setItem(GuiIcon.MANAGE_SHOP.getSlot(), shopIcon);
|
||||||
inventory.setItem(GuiIcon.MANAGE_SHOP_BALANCE_ADD.getSlot(), GuiIcon.MANAGE_SHOP_BALANCE_ADD.getItemStack());
|
inventory.setItem(GuiIcon.MANAGE_SHOP_BALANCE_ADD.getSlot(), GuiIcon.MANAGE_SHOP_BALANCE_ADD.getItemStack());
|
||||||
inventory.setItem(GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getSlot(), GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getItemStack());
|
inventory.setItem(GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getSlot(), GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getItemStack());
|
||||||
|
inventory.setItem(GuiIcon.MANAGE_SHOP_COLLECT_SALES.getSlot(), GuiIcon.MANAGE_SHOP_COLLECT_SALES.getItemStack());
|
||||||
inventory.setItem(GuiIcon.MANAGE_SHOP_SALES.getSlot(), GuiIcon.MANAGE_SHOP_SALES.getItemStack());
|
inventory.setItem(GuiIcon.MANAGE_SHOP_SALES.getSlot(), GuiIcon.MANAGE_SHOP_SALES.getItemStack());
|
||||||
inventory.setItem(GuiIcon.MANAGE_SHOP_ITEM.getSlot(), GuiIcon.MANAGE_SHOP_ITEM.getItemStack());
|
inventory.setItem(GuiIcon.MANAGE_SHOP_ITEM.getSlot(), GuiIcon.MANAGE_SHOP_ITEM.getItemStack());
|
||||||
inventory.setItem(GuiIcon.MANAGE_SHOP_TYPE.getSlot(), GuiIcon.MANAGE_SHOP_TYPE.getItemStack());
|
inventory.setItem(GuiIcon.MANAGE_SHOP_TYPE.getSlot(), GuiIcon.MANAGE_SHOP_TYPE.getItemStack());
|
||||||
|
|
@ -75,6 +77,31 @@ public class ShopManagementGui extends AbstractGui {
|
||||||
public void onClick(int slot, ItemStack item) {
|
public void onClick(int slot, ItemStack item) {
|
||||||
super.onClick(slot, item);
|
super.onClick(slot, item);
|
||||||
|
|
||||||
|
if (slot == GuiIcon.MANAGE_SHOP_COLLECT_SALES.getSlot() && GuiIcon.MANAGE_SHOP_COLLECT_SALES.getItemStack().equals(item)) {
|
||||||
|
Player player = getPlayer();
|
||||||
|
double d = 0;
|
||||||
|
int count = 0;
|
||||||
|
if (!ShopUtil.canManageShop(player, this.shop))
|
||||||
|
return;
|
||||||
|
if (!this.shop.getType().equals(ShopType.SELL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
double balance = this.shop.getBalance();
|
||||||
|
if (balance == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.shop.removeBalance(balance);
|
||||||
|
EconomyUtils.addFunds(player, balance);
|
||||||
|
d += balance;
|
||||||
|
count++;
|
||||||
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
|
Placeholder.parsed("balance", String.valueOf(d)),
|
||||||
|
Placeholder.parsed("count", String.valueOf(count))
|
||||||
|
);
|
||||||
|
player.sendMiniMessage("<green>You have collected <balance> from <count> shops.", placeholders);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (slot >= 45)
|
if (slot >= 45)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ public class ShopHandler {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerShop> getShopsInRadius(int x, int z, int radius) {
|
public List<PlayerShop> getShopsInRadius(int x, int z, int radius) {
|
||||||
ArrayList<PlayerShop> shops = new ArrayList<>();
|
ArrayList<PlayerShop> shops = new ArrayList<>();
|
||||||
int bottomX = x - radius;
|
int bottomX = x - radius;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user