예제 #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()));
   }
 }