Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.L2ItemInstance


      if (limit <= 0)
        return true;

      int count = 0;
      L2ItemInstance ticket;
      for(int i=0; i<getDroppedTickets().size(); i++)
      {
        ticket = getDroppedTickets().get(i);
        if ( ticket != null && ticket.getItemId() == itemId)
          count++;
      }
      if(count >= limit)
        return true;
      return false;
View Full Code Here


      int limit = MERCS_MAX_PER_CASTLE[castleId-1];
      if (limit <= 0)
        return true;

      int count = 0;
      L2ItemInstance ticket;
      for(int i=0; i<getDroppedTickets().size(); i++)
      {
        ticket = getDroppedTickets().get(i);
        if ( (ticket != null) && (getTicketCastleId(ticket.getItemId()) == castleId) )
          count++;
      }
      if(count >= limit)
        return true;
      return false;
View Full Code Here

                // Hire merc for this caslte.  NpcId is at the same index as the item used.
                castle.getSiege().getSiegeGuardManager().hireMerc(x, y, z, heading, NPC_IDS[i]);

                // create the ticket in the gameworld
            L2ItemInstance dropticket = new L2ItemInstance(IdFactory.getInstance().getNextId(), itemId);
            dropticket.setLocation(L2ItemInstance.ItemLocation.INVENTORY);
                dropticket.dropMe(null, x, y, z);
                dropticket.setDropTime(0); //avoids it from beeing removed by the auto item destroyer
                L2World.getInstance().storeObject(dropticket)//add to the world
                // and keep track of this ticket in the list
                _droppedTickets.add(dropticket);

                return NPC_IDS[i];
View Full Code Here

    public void deleteTickets(int castleId)
    {
      int i = 0;
      while ( i<getDroppedTickets().size() )
      {
        L2ItemInstance item = getDroppedTickets().get(i);
        if ((item != null) && (getTicketCastleId(item.getItemId()) == castleId))
        {
          item.decayMe();
          L2World.getInstance().removeObject(item);

          // remove from the list
          getDroppedTickets().remove(i);
        }
View Full Code Here

        // Remove any unused blood offerings from online players.
        for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers())
        {
            try {
              L2ItemInstance bloodOfferings = onlinePlayer.getInventory().getItemByItemId(FESTIVAL_OFFERING_ID);

              if (bloodOfferings != null)
                onlinePlayer.destroyItem("SevenSigns", bloodOfferings, null, false);
            } catch (NullPointerException e) {}
        }
View Full Code Here

      // first take adena for manufacture
      if ((_target != _player) && _price > 0) // customer must pay for services
      {
        // attempt to pay for item
        L2ItemInstance adenatransfer = _target.transferItem("PayManufacture",
                    _target.getInventory().getAdenaInstance().getObjectId(),
                    _price, _player.getInventory(), _player);

        if(adenatransfer==null)
        {
View Full Code Here

      for (L2RecipeInstance recipe : recipes)
      {
        int quantity = _recipeList.isConsumable() ? (int) (recipe.getQuantity() * Config.RATE_CONSUMABLE_COST) : recipe.getQuantity();
        if (quantity > 0)
        {
          L2ItemInstance item = inv.getItemByItemId(recipe.getItemId());

          // check materials
          if (item==null || item.getCount() < quantity)
          {
            _target.sendMessage("You dont have the right elements for making this item"
                               + ((_recipeList.isConsumable() && Config.RATE_CONSUMABLE_COST != 1? ".\nDue to server rates you need "
                                                                                                     + Config.RATE_CONSUMABLE_COST
                                                                                                     + "x more material than listed in recipe"
View Full Code Here

    private void rewardPlayer()
    {
      int itemId = _recipeList.getItemId();
      int itemCount = _recipeList.getCount();

      L2ItemInstance createdItem = _target.getInventory().addItem("Manufacture", itemId, itemCount,
                                                                 _target, _player);

      // inform customer of earned item
            SystemMessage sm = null;
            if (itemCount > 1)
            {
          sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
          sm.addItemName(itemId);
                sm.addNumber(itemCount);
          _target.sendPacket(sm);
            } else
            {
                sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
                sm.addItemName(itemId);
                _target.sendPacket(sm);
            }

      if (_target != _player)
      {
        // inform manufacturer of earned profit
        sm = new SystemMessage(SystemMessageId.EARNED_ADENA);
        sm.addNumber(_price);
        _player.sendPacket(sm);
      }

      if (Config.ALT_GAME_CREATION)
      {
        int recipeLevel = _recipeList.getLevel();
        int exp = createdItem.getReferencePrice() * itemCount;
        // one variation

        // exp -= materialsRefPrice;   // mat. ref. price is not accurate so other method is better

        if (exp < 0) exp = 0;
View Full Code Here

                        int itemId = Integer.parseInt(st.nextToken());
                        int amount = Integer.parseInt(st.nextToken());

                        if(player != null)
                        {
                            L2ItemInstance item = player.getInventory().addItem("Status-Give", itemId, amount, null, null);
                            InventoryUpdate iu = new InventoryUpdate();
                            iu.addItem(item);
                            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
                            sm.addItemName(itemId);
                            sm.addNumber(amount);
                            player.sendPacket(iu);
                            _print.println("ok");
                        }
                    }
                    catch(Exception e)
                    {

                    }
                }
                else if (_usrCommand.startsWith("jail"))
                {
                  StringTokenizer st = new StringTokenizer(_usrCommand.substring(5));
                    try
                    {
                      String playerName = st.nextToken();
                        L2PcInstance playerObj = L2World.getInstance().getPlayer(playerName);
                        int delay = 0;
                        try
                        {
                            delay = Integer.parseInt(st.nextToken());
                        } catch (NumberFormatException nfe) {
                        } catch (NoSuchElementException nsee) {}
                        //L2PcInstance playerObj = L2World.getInstance().getPlayer(player);

                        if (playerObj != null)
                        {
                            playerObj.setInJail(true, delay);
                            _print.println("Character "+playerObj.getName()+" jailed for "+(delay>0 ? delay+" minutes." : "ever!"));
                        }
                        else
                        {
                          jailOfflinePlayer(playerName, delay);
                        }
                    } catch (NoSuchElementException nsee)
                    {
                      _print.println("Specify a character name.");
                    } catch(Exception e)
                    {
                        if (Config.DEBUG) e.printStackTrace();
                    }
                }
                else if (_usrCommand.startsWith("unjail"))
                {
                  StringTokenizer st = new StringTokenizer(_usrCommand.substring(7));
                  try
                    {
                    String playerName = st.nextToken();
                        L2PcInstance playerObj = L2World.getInstance().getPlayer(st.nextToken());
                        if (playerObj != null)
                        {
                            playerObj.stopJailTask(false);
                            playerObj.setInJail(false, 0);
                            _print.println("Character "+playerObj.getName()+" removed from jail");
                        }
                        else
                        {
                          unjailOfflinePlayer(playerName);
                        }
                    } catch (NoSuchElementException nsee)
                    {
                      _print.println("Specify a character name.");
                    } catch(Exception e)
                    {
                        if (Config.DEBUG) e.printStackTrace();
                    }
                }
                else if (_usrCommand.startsWith("debug") && _usrCommand.length() > 6)
                {
                  StringTokenizer st = new StringTokenizer(_usrCommand.substring(6));
                  try
                  {
                    String dbg = st.nextToken();

                    if(dbg.equals("decay"))
                    {
                      _print.print(DecayTaskManager.getInstance().toString());
                    }
                    else if(dbg.equals("ai"))
                    {
                      /*
                      _print.println("AITaskManagerStats");
                      for(String line : AITaskManager.getInstance().getStats())
                      {
                        _print.println(line);
                      }
                      */
                    }
                    else if(dbg.equals("aiflush"))
                    {
                      //AITaskManager.getInstance().flush();
                    }
                    else if(dbg.equals("PacketTP"))
                    {
                      String str = ThreadPoolManager.getInstance().getPacketStats();
                      _print.println(str);
                      int i = 0;
                      File f = new File("./log/StackTrace-PacketTP-"+i+".txt");
                      while(f.exists())
                      {
                        i++;
                        f = new File("./log/StackTrace-PacketTP-"+i+".txt");
                      }
                      f.getParentFile().mkdirs();
                      FileOutputStream fos = new FileOutputStream(f);
                      OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8");
                      out.write(str);
                      out.flush();
                      out.close();
                      fos.close();
                    }
                    else if(dbg.equals("IOPacketTP"))
                    {
                      String str = ThreadPoolManager.getInstance().getIOPacketStats();
                      _print.println(str);
                      int i = 0;
                      File f = new File("./log/StackTrace-IOPacketTP-"+i+".txt");
                      while(f.exists())
                      {
                        i++;
                        f = new File("./log/StackTrace-IOPacketTP-"+i+".txt");
                      }
                      f.getParentFile().mkdirs();
                      FileOutputStream fos = new FileOutputStream(f);
                      OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8");
                      out.write(str);
                      out.flush();
                      out.close();
                      fos.close();
                    }
                    else if(dbg.equals("GeneralTP"))
                    {
                      String str = ThreadPoolManager.getInstance().getGeneralStats();
                      _print.println(str);
                      int i = 0;
                      File f = new File("./log/StackTrace-GeneralTP-"+i+".txt");
                      while(f.exists())
                      {
                        i++;
                        f = new File("./log/StackTrace-GeneralTP-"+i+".txt");
                      }
                      f.getParentFile().mkdirs();
                      FileOutputStream fos = new FileOutputStream(f);
                      OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8");
                      out.write(str);
                      out.flush();
                      out.close();
                      fos.close();
                    }
                  }
                  catch(Exception e){}
                }
                else if (_usrCommand.startsWith("reload"))
                {
                  StringTokenizer st = new StringTokenizer(_usrCommand.substring(7));
                  try
                  {
                    String type = st.nextToken();

                    if(type.equals("multisell"))
                    {
                      _print.print("Reloading multisell... ");
                      L2Multisell.getInstance().reload();
                      _print.print("done\n");
                    }
                    else if(type.equals("skill"))
                    {
                      _print.print("Reloading skills... ");
                      SkillTable.getInstance().reload();
                      _print.print("done\n");
                    }
                    else if(type.equals("npc"))
                    {
                      _print.print("Reloading npc templates... ");
                      NpcTable.getInstance().reloadAllNpc();
                      _print.print("done\n");
                    }
                    else if(type.equals("html"))
                    {
                      _print.print("Reloading html cache... ");
                      HtmCache.getInstance().reload();
                      _print.print("done\n");
                    }
                    else if(type.equals("item"))
                    {
                      _print.print("Reloading item templates... ");
                      ItemTable.getInstance().reload();
                      _print.print("done\n");
                    }
                    else if(type.equals("instancemanager"))
                    {
                      _print.print("Reloading instance managers... ");
                      Manager.reloadAll();
                      _print.print("done\n");
                    }
                    else if(type.equals("zone"))
                    {
                      _print.print("Reloading zone tables... ");
                      //TODO: ZONETODO reload zones using telnet ZoneManager.getInstance().reload();
                      _print.print("done\n");
                    }

                  }
                  catch(Exception e){}
                }
                else if (_usrCommand.startsWith("gamestat"))
                {
                  StringTokenizer st = new StringTokenizer(_usrCommand.substring(9));
                  try
                  {
                    String type = st.nextToken();

                    // name;type;x;y;itemId:enchant:price...
                    if(type.equals("privatestore"))
                    {
                      for(L2PcInstance player : L2World.getInstance().getAllPlayers())
                      {
                        if(player.getPrivateStoreType() == 0)
                          continue;

                        TradeList list = null;
                        String content = "";

                        if(player.getPrivateStoreType() == 1) // sell
                        {
                          list = player.getSellList();
                          for(TradeItem item : list.getItems())
                          {
                            content += item.getItem().getItemId()+":"+item.getEnchant()+":"+item.getPrice()+":";
                          }
                          content = player.getName()+";"+"sell;"+player.getX()+";"+player.getY()+";"+content;
                          _print.println(content);
                          continue;
                        }
                        else if(player.getPrivateStoreType() == 3) // buy
                        {
                          list = player.getBuyList();
                          for(TradeItem item : list.getItems())
                          {
                            content += item.getItem().getItemId()+":"+item.getEnchant()+":"+item.getPrice()+":";
                          }
                          content = player.getName()+";"+"buy;"+player.getX()+";"+player.getY()+";"+content;
                          _print.println(content);
                          continue;
                        }
View Full Code Here

      if (p == null) continue;
      output.append(',');
      output.append(' ');
      if (p instanceof L2ItemInstance)
      {
        L2ItemInstance item = (L2ItemInstance)p;
        output.append("item " + item.getObjectId() + ":");
        if (item.getEnchantLevel() > 0) output.append("+" + item.getEnchantLevel() + " ");
        output.append(item.getItem().getName());
        output.append("(" + item.getCount() + ")");
      }
//      else if (p instanceof L2PcInstance)
//        output.append(((L2PcInstance)p).getName());
      else output.append(p.toString()/* + ":" + ((L2Object)p).getObjectId()*/);
    }
 
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.L2ItemInstance

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.