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.



  • Posts

    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt  
    • Server Rates: » Xp 500x. » Sp 500x. » Aden 500x. » Drop 1x. » PartyXp 2x. » PartySp 2x. » Starting character level -61. Enchant rates: » Safe enchant +4. » Blessed and simple scrolls max enchant (+16). » Crystal scrolls max enchant (+20). » Simple enchant scrolls chance – 65%. » Blessed enchant scrolls chance – 100%. » Crystal enchant scrolls chance – 50% Augmentations: » Mid life stone skill chance – 5%. » High life stone skill chance – 10%. » Top life stone skill chance – 20%. » Augments 1+1 Unique features: » Main town – Giran » Automatic-Manual Potions. » Working 2 castle sieges. (Giran-Aden) » SPS cancel lasts 10 seconds and than buffs come back. » Stackable scrolls, lifestones, book of giants. » Unique pvp zone » More then 11 active raid bosses. » Wedding system. » Unique farming areas. » Npc skill enchanter. » Full npc buffer with auto buff. » Max count of buffs – 55. » Max subclasses – 4. » Free and no quest class change. » Free and no quest sub class. » Raid boss drop nobless item. » No weight limit. » Unique protection anti-hwy armor for archers/daggers etc. » Ingame password change. » Top pvp/pk/online ranks NPC. » Unique monsters & NPC. » Interlude retail skills. » Server up-time [24/7] [99]%. » Perfect class balance (all class can kill all class depending on players skill and setup knowledge,gear,augmentations). » Announcements on double kills triple kills etc. » Announcements on Grand Boss death , with the name of the killer as well as clan name of the player. » Information Npc in game with all servers infromations. Custom server gear : 1). Titanium Armor Lv.1 2). Epic Armor Lv.2 3). Epic Weapons-Kamikaze-Black S grade (Same Stats) 4). Demonic-Angelic Wings-Baium Hair-Custom Accessories (SameStats) 5). Custom Fighter/Mage tattoo Lv1-Lv2-Lv3 6). Shirt (STR,CON,INT +1) 7). Custom Shields Server Commands: .tvtjoin .tvtleave – Join or leave tvt event. .ctfjoin .ctfleave – Join or leave ctf event. .dmjoin .dmleave – Join of leave dm event. .online – current online players count. .repair – repairs stuck character in world. .menu – opens online menu panel. .exit – PVP zone exit in case you are bullied. .changepassword - Opens online menu then u can change ur password in game. .farm - Enable/disable autofarm Event system: » TVT event » CTF event » DM event » Tournament Event » Party Zone » Unique event shop. Olympiad game: » Retail olympiad game. » Competition period [1] week. » Olympiad start time [18:00] end [00:00] GMT+2. » New Heroes every Sunday.
    • Tomorrow grand opening lests go 🙂 
  • Topics

×
×
  • Create New...