Jump to content
  • 0

Java Error


janiko

Question

Can anyone help me to fix this error??

 

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16315: error: cannot find symbol

    [javac]      for (Map.Entry entry : this.ceffects.entrySet())

    [javac]                                  ^

    [javac]  symbol: variable ceffects

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16362: error: incompatible types

    [javac]      for (Map.Entry entry : ceffects.entrySet())

    [javac]                                              ^

    [javac]  required: Entry

    [javac]  found:    Object

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16376: error: incompatible types

    [javac]      for (Map.Entry entry : ceffects.entrySet())

    [javac]                                              ^

    [javac]  required: Entry

    [javac]  found:    Object

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16405: error: incompatible types

    [javac]    for (Map.Entry entry : ceffects.entrySet())

    [javac]                                            ^

 

 

 

  public void restoreBBSBuf(int forPet)
  {
    Connection con = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();

      PreparedStatement statement = con.prepareStatement("SELECT * FROM character_bbs_buff_save WHERE charId=? AND for_pet=?");
      statement.setInt(1, getObjectId());
      statement.setInt(2, forPet);
      ResultSet rset = statement.executeQuery();

      while (rset.next())
      {
        int idSkill = rset.getInt("skill_id");
        int lvlSkill = rset.getInt("skill_level");
        if (forPet == 0)
          this._bbsBuff.put(Integer.valueOf(idSkill), Integer.valueOf(lvlSkill));
        else
          this._bbsPetBuff.put(Integer.valueOf(idSkill), Integer.valueOf(lvlSkill));
      }
      rset.close();
      statement.close();
    }
    catch (Exception e)
    {
      _log.log(Level.WARNING, new StringBuilder().append("Could not restore ").append(this).append(" BBS buff data: ").append(e.getMessage()).toString(), e);
    }
    finally
    {
      L2DatabaseFactory.close(con);
    }
  }

  public void storeBBSBuff(int forPet)
  {
    Map ceffects = new FastMap();
    if (forPet == 0)
      ceffects.putAll(this._bbsBuff);
    else {
      ceffects.putAll(this._bbsPetBuff);
    }
    Connection con = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();

      PreparedStatement statement = con.prepareStatement("DELETE FROM character_bbs_buff_save WHERE charId=? AND for_pet=?");
      statement.setInt(1, getObjectId());
      statement.setInt(2, forPet);
      statement.execute();
      statement.close();
//all i dont know what for now, try continue 
      for (Map.Entry entry : this.ceffects.entrySet())
      {
        statement = con.prepareStatement("INSERT INTO character_bbs_buff_save (charId,skill_id,skill_level,for_pet) VALUES (?,?,?,?)");
        statement.setInt(1, getObjectId());
        statement.setInt(2, ((Integer)entry.getKey()).intValue());
        statement.setInt(3, ((Integer)entry.getValue()).intValue());
        statement.setInt(4, forPet);
        statement.execute();
        statement.close();
      }
    }
    catch (Exception e)
    {
      PreparedStatement statement;
      _log.log(Level.WARNING, "Could not store char effect data: ", e);
    }
    finally
    {
      L2DatabaseFactory.close(con);
    }
  }

  public void updateBBSBuff(int forPet)
  {
    Map ceffects = new FastMap();
    L2Character character;
    if (forPet == 0)
      character = this;
    else {
      character = getPet();
    }
    if (character == null)
      return;
    for (L2Effect cureffect : character.getAllEffects())
    {
      int idSklll = cureffect.getId();
      int lvlSklll = cureffect.getLevel();
      if (BuffBBSTable.getInstance().isBBSSaveBuf(idSklll, lvlSklll))
        ceffects.put(Integer.valueOf(idSklll), Integer.valueOf(lvlSklll));
    }
    if (ceffects.isEmpty())
      return;
    if (forPet == 0)
    {
      boolean saveBuff = false;
      if (ceffects.size() != this._bbsBuff.size())
        saveBuff = true;
      for (Map.Entry entry : ceffects.entrySet())
        if (!_bbsBuff.containsKey(entry.getKey()))
          saveBuff = true;
      if (!saveBuff) {
        return;
      }
     _bbsBuff.clear();
      _bbsBuff.putAll(ceffects);
    }
    else
    {
      boolean saveBuff = false;
      if (ceffects.size() != this._bbsBuff.size())
        saveBuff = true;
      for (Map.Entry entry : ceffects.entrySet())
        if (!this._bbsBuff.containsKey(entry.getKey()))
          saveBuff = true;
      if (!saveBuff) {
        return;
      }
      this._bbsPetBuff.clear();
      this._bbsPetBuff.putAll(ceffects);
    }

    storeBBSBuff(forPet);
  }

  public void cactBBSBuff(int forPet)
  {
    Map ceffects = new FastMap();
    L2Character character;
    if (forPet == 0)
    {
      ceffects.putAll(this._bbsBuff);
    }
    else
    {
      character = getPet();
      ceffects.putAll(this._bbsPetBuff);
    }
    if ((character == null) || (ceffects.isEmpty())) {
      return;
    }
    for (Map.Entry entry : ceffects.entrySet())
    {
      L2Skill skill = SkillTable.getInstance().getInfo(((Integer)entry.getKey()).intValue(), ((Integer)entry.getValue()).intValue());
      if (skill == null)
        continue;
      skill.getEffects(character, character);
    }
  }

  public int calcBBSBuff(int forPet)
  {
    Map ceffects = new FastMap();
    L2Character character;
    if (forPet == 0) // pet in invetory
    {
      ceffects.putAll(this._bbsBuff);
    }
    else
    {
      character = getPet();
      ceffects.putAll(this._bbsPetBuff);
    }
    if ((character == null) || (ceffects.isEmpty())) {
      return 0;
    }

    int result = 0;
    for (Map.Entry entry : ceffects.entrySet())
    {
      int skillId = ((Integer)entry.getKey()).intValue();
      int skillLvl = ((Integer)entry.getValue()).intValue();
      int bbsGroup = BuffBBSTable.getInstance().getBBSGroupFotBuf(skillId, skillLvl);
      if (bbsGroup == 0)
        continue;
      int priceGroup = BuffBBSTable.getInstance().getPriceGroup(bbsGroup);
      if (priceGroup < 0)
        continue;
      result += priceGroup;
    }
    return result;
  }

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

i'll give you a short hint on how to iterate properly by getting a random line that error occurs

Your line

for (Map.Entry entry : ceffects.entrySet())

        if (!_bbsBuff.containsKey(entry.getKey())) 

        saveBuff = true;

Correct line

for (Object entry : ceffects.keySet())

        if (!_bbsBuff.containsKey(entry)

        saveBuff = true;

Also you should parametrise your map.for example

FastMap<Integer,Integer> map = new FastMap<Integer,Integer>();

It's a more safe tactic to avoid those errors and some others that might occur

Link to comment
Share on other sites

  • 0

thanks but can you advise what need changes here?

 

THanks for help.

Now i have error

________________________

    [javac]  symbol:  variable ceffects

    [javac]  location: class L2PcInstance

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16432: error: cannot find symbol

    [javac] for (Object entry : ceffects.keySet())

___________________________________________

Can you help to transffer this script?

___________________________________________

 

  public int calcBBSBuff(int forPet)

  {

    Map ceffects = new FastMap();

    L2Character character;

    if (forPet == 0)

    {

      ceffects.putAll(this._bbsBuff);

    }

    else

    {

      character = getPet();

      ceffects.putAll(this._bbsPetBuff);

    }

    if ((character == null) || (ceffects.isEmpty())) {

      return 0;

    }

 

    int result = 0;

  for (Object entry : ceffects.keySet())

 

    {

      int skillId = ((Integer)entry.getKey()).intValue();

      int skillLvl = ((Integer)entry.getValue()).intValue();

      int bbsGroup = BuffBBSTable.getInstance().getBBSGroupFotBuf(skillId, skillLvl);

      if (bbsGroup == 0)

        continue;

      int priceGroup = BuffBBSTable.getInstance().getPriceGroup(bbsGroup);

      if (priceGroup < 0)

        continue;

      result += priceGroup;

    }

    return result;

  }

 

Link to comment
Share on other sites

  • 0

You are trying to call ceffects Map while it is a local varible(inside a method)

 

Your part

public int calcBBSBuff(int forPet)

  {

    Map ceffects = new FastMap();

    L2Character character;

...

...

...(rest stuff as they are)

 

Proper part

Map ceffects = new FastMap();

 

public int calcBBSBuff(int forPet)

  {

    L2Character character;

...

....

...

Link to comment
Share on other sites

  • 0

Changed but have error

    [javac]  required: Entry

    [javac]  found:    Object

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16434: error: cannot find symbol

    [javac]      int skillId = ((Integer)entry.getKey()).intValue();

    [javac]                                          ^

    [javac]  symbol:  variable key

    [javac]  location: class L2PcInstance

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16435: error: cannot find symbol

    [javac]      int skillLvl = ((Integer)entry.getValue()).intValue();

    [javac]                                          ^

 

Link to comment
Share on other sites

  • 0

  for (Object entry : ceffects.keySet())

    {

      int skillId = ((Integer)entry.getKey()).intValue();    int skillLvl = ((Integer)entry.getValue()).intValue();

    int skillId = entry.intValue();

    int skillLvl =  ceffects.get(entry).intValue();   

replace the  striked line with the 2 lines below them

Link to comment
Share on other sites

  • 0

 

    [javac] gameserver\model\actor\instance\L2PcInstance.java:16434: error: cannot find symbol

    [javac]   int skillId = entry.intValue();

    [javac]                         ^

    [javac]  symbol:  method intValue()

    [javac]  location: variable entry of type Object

    [javac] D:\Brick-Server\L2Brick_Server\java\l2\brick\gameserver\model\actor\instance\L2PcInstance.java:16435: error: cannot find symbol

    [javac]      int skillLvl = ceffects.get(entry).intValue();

    [javac]                                                ^

Link to comment
Share on other sites

  • 0

and a cast over here

int skillId =(Integer) entry.intValue();

int skillLvl =(Integer) ceffects.get(entry).intValue();

(that's why you should parametrize the map , you would avoid casting  ;) )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock