示例#1
0
文件: Shop.java 项目: amarsut/Konklex
 /**
  * Buys a item from the store.
  *
  * @param player The player.
  * @param item The item to buy.
  */
 public void buyItem(Player player, SlottedItem item) {
   if (player.getInventory().freeSlots() >= item.getItem().getAmount()) {
     if (payment.buyItem(player, item)) {
       player.getInventory().add(item.getItem());
       player.send(new UpdateItemsEvent(3823, player.getInventory().getItems()));
       if (!type.equals(ShopType.UNLIMITED_BUY_ONLY)) {
         items.remove(item.getItem());
       }
     }
   } else {
     player.getInventory().forceCapacityExceeded();
   }
 }
示例#2
0
文件: Shop.java 项目: amarsut/Konklex
 /**
  * Sells a item to the store.
  *
  * @param player The player that is selling this item.
  * @param slot The item slot.
  * @param item The item.
  */
 public void sellItem(Player player, Item item) {
   if (type.equals(ShopType.BUY_AND_SELL)) {
     if (player.getInventory().contains(item)) {
       if (payment.sellItem(player, item)) {
         player.getInventory().remove(item);
         player.send(new UpdateItemsEvent(3823, player.getInventory().getItems()));
         items.add(item);
       }
     }
   } else {
     player.sendMessage("You cannot sell items in this shop.");
   }
 }
示例#3
0
文件: Shop.java 项目: amarsut/Konklex
 /**
  * Adds a bulk item to the store.
  *
  * @param item The item to add to the store.
  */
 protected void addItem(Item item) {
   items.add(item);
 }
示例#4
0
文件: Shop.java 项目: amarsut/Konklex
 /**
  * Create a new shop.
  *
  * @param name The shop name.
  * @param type The shop type.
  */
 public Shop(String name, ShopType type) {
   this.name = name;
   this.type = type;
   items.addListener(new ShopAmountChangedListener(this));
 }
示例#5
0
文件: Shop.java 项目: amarsut/Konklex
 /** Refresh the shop for all viewers. */
 public void refresh() {
   for (Player player : players) {
     player.send(new UpdateItemsEvent(3900, items.getItems()));
   }
 }