Jump to content
  • 0

Convert IXMLReader code to XMLDocument


Question

Posted

Hello friends, I'm converting a code made in IXMLReader to XMLDocument because my entire source uses XMLDocument, I'm halfway through but I'm getting error with forEach and I would like to ask for help from you friends, I'll put the code without any changes of mine and with change Anyone who can help is grateful.

No change:

package net.sf.l2j.gameserver.data.xml;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import net.sf.l2j.commons.data.xml.IXmlReader;

import net.sf.l2j.gameserver.model.event.BossEvent;
import net.sf.l2j.gameserver.templates.StatsSet;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;

/**
 * @author StinkyMadness
 */
public class BossEventData implements IXmlReader
{
   private static final List<StatsSet> data = new ArrayList<>();
  
   protected BossEventData()
   {
       load();
   }
  
   @Override
   public void load()
   {
       parseFile("./data/xml/BossEvent.xml");
   }
  
   @Override
   public void parseDocument(Document doc, Path path)
   {
      
       forEach(doc, "list", listNode -> forEach(listNode, "Boss", bossNode ->
       {
           final StatsSet set = parseAttributes(bossNode);
           forEach(bossNode, "announce", messageNode -> set.set("announceOnSpawn", parseString(messageNode.getAttributes(), "onSpawn")));
           forEach(bossNode, "spawnLoc", positionNode ->
           {
               final NamedNodeMap attrs = positionNode.getAttributes();
               set.set("posX", parseInteger(attrs, "x"));
               set.set("posY", parseInteger(attrs, "y"));
               set.set("posZ", parseInteger(attrs, "z"));
           });
           forEach(bossNode, "despawn", messageNode -> set.set("despawnTime", parseInteger(messageNode.getAttributes(), "after")));
           forEach(bossNode, "scheduleSpawnTime", spawnTimeNode -> set.set("spawnDateData", parseString(spawnTimeNode.getAttributes(), "val")));
           data.add(set);
       }));
      
       data.forEach(BossEvent::new);
   }
  
   public static BossEventData getInstance()
   {
       return SingletonHolder.INSTANCE;
   }
  
   private static class SingletonHolder
   {
       protected static final BossEventData INSTANCE = new BossEventData();
   }
}

With change:

package net.sf.l2j.gameserver.data.xml;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import net.sf.l2j.commons.data.xml.XMLDocument;

import net.sf.l2j.gameserver.events.BossEvent;
import net.sf.l2j.gameserver.templates.StatsSet;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;

/**
 * @author StinkyMadness
 */
public class BossEventData extends XMLDocument
{
   private static final List<StatsSet> data = new ArrayList<>();
  
   protected BossEventData()
   {
       load();
   }
  
   @Override
   public void load()
   {
	   loadDocument("./data/xml/BossEvent.xml");
   }
  
   public void parseDocument(Document doc, Path path)
   {
      
       forEach(doc, "list", listNode -> forEach(listNode, "Boss", bossNode ->
       {
           final StatsSet set = parseAttributes(bossNode);
           forEach(bossNode, "announce", messageNode -> set.set("announceOnSpawn", parseString(messageNode.getAttributes(), "onSpawn")));
           forEach(bossNode, "spawnLoc", positionNode ->
           {
               final NamedNodeMap attrs = positionNode.getAttributes();
               set.set("posX", parseInteger(attrs, "x"));
               set.set("posY", parseInteger(attrs, "y"));
               set.set("posZ", parseInteger(attrs, "z"));
           });
           forEach(bossNode, "despawn", messageNode -> set.set("despawnTime", parseInteger(messageNode.getAttributes(), "after")));
           forEach(bossNode, "scheduleSpawnTime", spawnTimeNode -> set.set("spawnDateData", parseString(spawnTimeNode.getAttributes(), "val")));
           data.add(set);
       }));
      
       data.forEach(BossEvent::new);
   }
  
   public static BossEventData getInstance()
   {
       return SingletonHolder.INSTANCE;
   }
  
   private static class SingletonHolder
   {
       protected static final BossEventData INSTANCE = new BossEventData();
   }

/* (non-Javadoc)
 * @see net.sf.l2j.commons.data.xml.XMLDocument#parseDocument(org.w3c.dom.Document, java.io.File)
 */
@Override
protected void parseDocument(Document doc, File f)
{
	// TODO Auto-generated method stub
	
}
}

Errors after change:

[javac] Compiling 1858 source files to C:\workspace\L2jMega_gameserver2\build\classes
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:37: error: cannot find symbol
    [javac]        forEach(doc, "list", listNode -> forEach(listNode, "Boss", bossNode ->
    [javac]        ^
    [javac]   symbol:   method forEach(Document,String,(listNode)[...]); }))
    [javac]   location: class BossEventData
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:44: error: cannot find symbol
    [javac]                set.set("posX", parseInteger(attrs, "x"));
    [javac]                                ^
    [javac]   symbol:   method parseInteger(NamedNodeMap,String)
    [javac]   location: class BossEventData
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:45: error: cannot find symbol
    [javac]                set.set("posY", parseInteger(attrs, "y"));
    [javac]                                ^
    [javac]   symbol:   method parseInteger(NamedNodeMap,String)
    [javac]   location: class BossEventData
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:46: error: cannot find symbol
    [javac]                set.set("posZ", parseInteger(attrs, "z"));
    [javac]                                ^
    [javac]   symbol:   method parseInteger(NamedNodeMap,String)
    [javac]   location: class BossEventData
    [javac] 4 errors

 

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

on acis changeset 377 XMLDocument has been replaced by the IXMLReader interface , so it means you can get it by beign a customer . dont expect ppl to help you ... pay 10E and get all the updates , it will help you since you will have access to DL all the possible changesets of the current circle ..

 

@Kara` he dont mean .forEach , he means the method forEach of the interface IXMLReader

default void forEach(..., ..., ...)

 

Edited by melron

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

    • My official facebook profile!: https://www.facebook.com/spectrumL2 Specifications: Revamped L2JACIS revision FROM the core Private project!!! Revision that has been receiving corrections for over 3 years!!! Events already installed in the revision: TVT CTF KTB PARTY FARM SPOIL EVENT CRAZY RATES TOURNAMENT TIME ZONE (INSTANCE) All working correctly!!! SIEGE ESSENTIAL FEATURES: Walls fix Gates fix Flags fix 100% functional: OLYMPIADS: Implemented settings Hero receives enchanted Weapons with equal status PvP Weapons Optional /true/false Hero can acquire all Hero Weapons Optional true/false OTHER IMPLEMENTATIONS: Teleport fixed (directly to Giran) Teleport effect classic Vip skins vip collor name Pack NPCs with effect already configured BOSES already configured Mobs already configured CLASS BALANCE SPECIAL SYSTEM We have a SPECIAL system developed for Class Balance with only 1 digit in XML %tage of configurable debuffs Player limitation system in BOSES or PvP zones BS blocking system in FLEG zones or events Among others dozens of improvements made in the review... price: 390 USD !  OBS: WE CAN CHANGE THE BANNER AND NAME OF THE SERVICE TO THE ONE OF YOUR PREFERENCE BUT THE SETTINGS MUST BE KEPT ANY CHANGES REQUIRE ADDITION        
    • Server is Online – 1,000+ Active Players! We’re excited to announce the addition of a Europe Proxy to improve connectivity for our EU players! Clans can now benefit from VIP Access to help you catch up faster. 🎯 If you're a clan leader with at least 9 active members, join our Discord and open a ticket to claim your VIP rewards!  
    • The Telegram team is rolling out a new batch of Stars-only gifts you’ll be able to mint as NFTs. Don’t miss your chance to join the next Telegram trend and earn from it! Buy Telegram Stars cheap and KYC-free 1 Star from $0.0149 (min. 50 Stars, bulk discounts available) Promo code STARS5 — 5 % off Pay any way you like: bank cards · crypto · other popular methods How to purchase: ➡Online Store — Click ➡ Telegram bot — Click Other services: ➡ SMM panel — Click Regular buyers get extra discounts and promo codes. Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store Use these contacts to discuss wholesale orders, partnerships (current list: https://socnet.bgng.io/partners) or to become a supplier. SocNet — your shop for digital goods and premium subscriptions
    • The Telegram team is rolling out a new batch of Stars-only gifts you’ll be able to mint as NFTs. Don’t miss your chance to join the next Telegram trend and earn from it! Buy Telegram Stars cheap and KYC-free 1 Star from $0.0149 (min. 50 Stars, bulk discounts available) Promo code STARS5 — 5 % off Pay any way you like: bank cards · crypto · other popular methods How to purchase: ➡Online Store — Click ➡ Telegram bot — Click Other services: ➡ SMM panel — Click Regular buyers get extra discounts and promo codes. Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store Use these contacts to discuss wholesale orders, partnerships (current list: https://socnet.bgng.io/partners) or to become a supplier. SocNet — your shop for digital goods and premium subscriptions
  • Topics

×
×
  • 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