Package games.stendhal.server.core.engine

Examples of games.stendhal.server.core.engine.ItemLogger


        if (item instanceof StackableItem) {
          // The item is stackable, we try to remove
          // multiple ones.
          final int quantity = item.getQuantity();
          if (toDrop >= quantity) {
            new ItemLogger().destroy(this, slot, item);
            slot.remove(item.getID());
            toDrop -= quantity;
            // Recreate the iterator to prevent
            // ConcurrentModificationExceptions.
            // This inefficient, but simple.
            objectsIterator = slot.iterator();
          } else {
            ((StackableItem) item).setQuantity(quantity - toDrop);
            new ItemLogger().splitOff(this, item, toDrop);
            toDrop = 0;
          }
        } else {
          // The item is not stackable, so we only remove a
          // single one.
          slot.remove(item.getID());
          new ItemLogger().destroy(this, slot, item);
          toDrop--;
          // recreate the iterator to prevent
          // ConcurrentModificationExceptions.
          objectsIterator = slot.iterator();
        }
View Full Code Here


      while (objectsIterator.hasNext()) {
        final RPObject object = objectsIterator.next();
        if (object instanceof Item) {
          if (object == item) {
            slot.remove(object.getID());
            new ItemLogger().destroy(this, slot, item);
            return true;
          }
        }
      }
    }
View Full Code Here

        if (object instanceof StackableItem) {
          // found another stackable
          final StackableItem other = (StackableItem) object;
          if (other.isStackable(stackEntity)) {
            // other is the same type...merge them
            new ItemLogger().merge(this, stackEntity, other);
            other.add(stackEntity);
            updateItemAtkDef();
            return true;
          }
        }
View Full Code Here

        zone.add(newItem);
      }
      newItem.notifyWorldAboutChanges();
      newItem.onPutOnGround(player);

      new ItemLogger().displace(player, newItem, zone, oldX, oldY, x, y);
    } else {
      entity.setPosition(x, y);
      entity.notifyWorldAboutChanges();
    }
  }
View Full Code Here

   *
   * @return Entity to place somewhere else in the world
   */
  private Item removeFromWorld(final Player player, final StackableItem stackableItem, final int quantity) {
    final StackableItem newItem = stackableItem.splitOff(quantity);
    new ItemLogger().splitOff(player, stackableItem, newItem, quantity);
    return newItem;
  }
View Full Code Here

      try {
        // remove admin items the player does not deserve
        if (ITEMS_FOR_ADMINS.contains(rpobject.get("name"))
            && (!player.has("adminlevel") || player.getInt("adminlevel") < 1000)) {
          logger.warn("removed admin item " + rpobject.get("name") + " from player " + player.getName());
          new ItemLogger().destroyOnLogin(player, slot, rpobject);
         
          continue;
        }
       
        Item item = transformer.transform(rpobject);
       
        // log removed items
        if (item == null) {
          int quantity = 1;
          if (rpobject.has("quantity")) {
            quantity = rpobject.getInt("quantity");
          }
         
          logger.warn("Cannot restore " + quantity + " " + rpobject.get("name")
              + " on login of " + player.getName()
              + " because this item"
              + " was removed from items.xml");
          new ItemLogger().destroyOnLogin(player, slot, rpobject);
         
          continue;
        }
       
        boundOldItemsToPlayer(player, item);
View Full Code Here

        boolean onGround = false;
        for (Item item : items) {
            if (!targetSlot.isFull()) {
                // TODO: merge stackable items
                targetSlot.add(item);
                new ItemLogger().equipAction(source, item, new String[]{"slot", sourcePlayer, "trade"}, new String[]{"slot", targetPlayer, targetSlot.getName()});
            } else {
                item.setPosition(player.getX(), player.getY());
                zone.add(item, player);
                onGround = true;
                new ItemLogger().equipAction(source, item, new String[]{"slot", sourcePlayer, "trade"}, new String[]{"ground", zone.getName(), player.getX() + " " + player.getY()});
            }
        }
        items.clear();
        return !onGround;
    }
View Full Code Here

          final int quantityToDrop = (int) Math.round(item.getQuantity()
              * percentage);

          if (quantityToDrop > 0) {
            final StackableItem itemToDrop = item.splitOff(quantityToDrop);
            new ItemLogger().splitOff(player, item, itemToDrop, quantityToDrop);
            new ItemLogger().equipAction(player, itemToDrop,
              new String[]{"slot", player.getName(), object.second().getName()},
              new String[]{"slot", player.getName(), "content"});
            corpse.add(itemToDrop);
            numberOfDrops += quantityToDrop;
            drops.add(itemToDrop);
          }
        } else if (object.first() instanceof Item) {
          Item justItem = (Item) object.first();
          object.second().remove(object.first().getID());
          new ItemLogger().equipAction(player, (Entity) object.first(),
                  new String[]{"slot", player.getName(), object.second().getName()},
                  new String[]{"slot", player.getName(), "content"});

          corpse.add((PassiveEntity) object.first());
          numberOfDrops += 1;
View Full Code Here

    Offer offer = new Offer(item, money, offerer);
    RPSlot slot = this.getSlot(OFFERS_SLOT_NAME);
    slot.add(offer);
    getZone().storeToDatabase();

    new ItemLogger().addLogItemEventCommand(new LogSimpleItemEventCommand(
        item, offerer, "slot-to-market", item.get("name"), Integer
            .toString(getQuantity(item)), "new offer",
        OFFERS_SLOT_NAME));

    return offer;
View Full Code Here

        String target = "ground";
        if (item.getContainerSlot() != null) {
          slotName = item.getContainerSlot().getName();
          target = "slot";
        }
        new ItemLogger()
            .addLogItemEventCommand(new LogSimpleItemEventCommand(
                item, acceptingPlayer, "market-to-" + target,
                item.get("name"), Integer
                    .toString(getQuantity(item)),
                "accept offer", slotName));
View Full Code Here

TOP

Related Classes of games.stendhal.server.core.engine.ItemLogger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.