Package org.moparscape.msc.gs.model.container

Examples of org.moparscape.msc.gs.model.container.Inventory


      affectedPlayer.setDuelConfirmAccepted(false);

      player.getActionSender().sendDuelAcceptUpdate();
      affectedPlayer.getActionSender().sendDuelAcceptUpdate();

      Inventory duelOffer = new Inventory(player);
      player.resetDuelOffer();
      int count = (int) p.readByte();
      for (int slot = 0; slot < count; slot++) {
        InvItem tItem = new InvItem(p.readShort(), p.readInt());
        if (tItem.amount < 1) {
          player.setSuspiciousPlayer(true);
          continue;
        }
        ItemDef def = tItem.getDef();
        if (!def.canTrade()) {
          player.getActionSender().sendMessage(
              def.getName()
                  + " cannot be traded with other players");
          player.setRequiresOfferUpdate(true);
          continue;
        }
        duelOffer.add(tItem.id, tItem.amount, false);
      }
      for (InvItem item : duelOffer.getItems()) {
        if (duelOffer.countId(item.id) > player.getInventory().countId(
            item.id)) {
          player.setSuspiciousPlayer(true);
          return;
        }
        player.addToDuelOffer(item);
View Full Code Here


        player.setMaxStat(i, Formulae.experienceToLevel(exp));
        player.setCurStat(i, p.readShort());
      }

      player.setCombatLevel(Formulae.getCombatlevel(player.getMaxStats()));
      Inventory inventory = new Inventory(player);
      int invCount = p.readShort();
      for (int i = 0; i < invCount; i++) {
        InvItem item = new InvItem(p.readShort(), p.readInt());
        inventory.add(item.id, item.amount, false);
        if (p.readByte() == 1 && ItemAttributes.isWieldable(item.id)) {
          inventory.setWield(i, true);
          ItemWieldableDef def = ItemAttributes.getWieldable(item.id);
          player.updateWornItems(def.getWieldPos(), def.getSprite());
        }
      }
      player.setInventory(inventory);
View Full Code Here

    }

    player.setMale(headGender == 1);

    if (player.isMale()) {
      Inventory inv = player.getInventory();
      for (int slot = 0; slot < inv.size(); slot++) {
        InvItem i = inv.getSlot(slot);
        ItemWieldableDef def = ItemAttributes.getWieldable(i.id);
        if (ItemAttributes.isWieldable(i.id) && def.getWieldPos() == 1
            && i.wielded && def.femaleOnly()) {
          inv.setWield(slot, false);
          player.updateWornItems(def.getWieldPos(), player
              .getPlayerAppearance().getSprite(def.getWieldPos()));
          player.getActionSender().sendUpdateItem(slot);
          break;
        }
View Full Code Here

      player.setSuspiciousPlayer(true);
      player.resetBank();
      return;
    }
    Bank bank = player.getBank();
    Inventory inventory = player.getInventory();
    int itemID, amount, slot;
    switch (pID) {
    case 48: // Close bank
      player.resetBank();
      break;
    case 198: // Deposit item
      itemID = p.readShort();
      amount = p.readInt();
      if (amount < 1 || inventory.countId(itemID) < amount) {
        world.addEntryToSnapshots(new Activity(player.getUsername(),
            player.getUsername() + " tried to deposit ID: "
                + itemID + " amount: " + amount));
        player.setSuspiciousPlayer(true);
        return;
      }
      world.addEntryToSnapshots(new Activity(player.getUsername(), player
          .getUsername()
          + " deposited ID: "
          + itemID
          + " amount: "
          + amount));
      if (EntityHandler.getItemDef(itemID).isMembers()
          && !World.isMembers()) {
        player.getActionSender().sendMessage(
            "This feature is only avaliable on a members server");
        return;
      }
      if (bank.canHold(itemID, amount)
          && inventory.remove(itemID, amount, false)) {
        bank.add(itemID, amount, false);
      } else {
        player.getActionSender().sendMessage(
            "You don't have room for that in your bank");
      }
      slot = bank.getLastItemSlot(itemID);
      if (slot > -1) {
        player.getActionSender().sendInventory();
        player.getActionSender().updateBankItem(slot, itemID,
            bank.countId(itemID));
      }
      break;
    case 183: // Withdraw item
      itemID = p.readShort();
      amount = p.readInt();
      if (amount < 1 || bank.countId(itemID) < amount) {
        world.addEntryToSnapshots(new Activity(player.getUsername(),
            player.getUsername() + " tried to withdraw ID: "
                + itemID + " amount: " + amount));
        player.setSuspiciousPlayer(true);
        return;
      }
      if (EntityHandler.getItemDef(itemID).isMembers()
          && !World.isMembers()) {
        player.getActionSender().sendMessage(
            "This feature is only avaliable on a members server");
        return;
      }

      if (!inventory.isStackable(itemID) && amount > 1) {
        Logger.println(player.getUsername() + " tried to withdraw ID: "
            + itemID + " amount: " + amount + " unstackable items");
        player.setSuspiciousPlayer(true);
      }

      slot = bank.getLastItemSlot(itemID);
      if (!inventory.canHold(itemID, amount)) {
        amount = inventory.maxSize() - inventory.size();
        if (amount == 0) {
          return;
        }
      }
      world.addEntryToSnapshots(new Activity(player.getUsername(), player
          .getUsername()
          + " withrew ID: "
          + itemID
          + " amount: "
          + amount));

      if (bank.remove(itemID, amount, false)) {
        inventory.add(itemID, amount, false);
      }

      if (slot > -1) {
        player.getActionSender().sendInventory();
        player.getActionSender().updateBankItem(slot, itemID,
View Full Code Here

    for (int i = 0; i < 18; i++) {
      packet.addLong(player.getExp(i));
      packet.addShort(player.getCurStat(i));
    }

    Inventory inv = player.getInventory();
    packet.addShort(inv.size());
    for (InvItem i : inv.getItems()) {
      packet.addShort(i.id);
      packet.addInt(i.amount);
      packet.addByte((byte) (i.wielded ? 1 : 0));
    }
View Full Code Here

      affectedPlayer.setTradeConfirmAccepted(false);

      // player.getActionSender().sendTradeAcceptUpdate();
      // affectedPlayer.getActionSender().sendTradeAcceptUpdate();

      Inventory tradeOffer = new Inventory(player);
      player.resetTradeOffer();
      int count = (int) p.readByte();
      for (int slot = 0; slot < count; slot++) {
        InvItem tItem = new InvItem(p.readShort(), p.readInt());
        if (tItem.amount < 1) {
          player.setSuspiciousPlayer(true);
          player.setRequiresOfferUpdate(true);
          continue;
        }
        ItemDef def = tItem.getDef();
        if (!def.canTrade() && !player.isMod()) {
          player.getActionSender().sendMessage(
              def.getName()
                  + " cannot be traded with other players");
          player.setRequiresOfferUpdate(true);
          continue;
        }
        tradeOffer.add(tItem.id, tItem.amount, false);
      }
      for (InvItem item : tradeOffer.getItems()) {
        if (tradeOffer.countId(item.id) > player.getInventory()
            .countId(item.id)) {
          player.setSuspiciousPlayer(true);
          unsetOptions(player);
          unsetOptions(affectedPlayer);
          return;
View Full Code Here

TOP

Related Classes of org.moparscape.msc.gs.model.container.Inventory

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.