Jump to content
  • 0

Community command error


Question

Posted (edited)

Hello folks, Today i decide to do something interesting. I want to add on community board when player have subclass, to display there.
and the code it is like that.

returnHtml = returnHtml.replace("%subclass%", ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode());


All good untill now, but when player doesn`t have subclass, he can't open cb and i get error on gameserver:
https://ibb.co/FKz1Hkx
Can someone tell me how and where i can add !=null ?

Pack: L2jMobius
Greetings !!

Edited by 0flee

6 answers to this question

Recommended Posts

  • 0
Posted
1 hour ago, 0flee said:

Hello folks, Today i decide to do something interesting. I want to add on community board when player have subclass, to display there.
and the code it is like that.


returnHtml = returnHtml.replace("%subclass%", ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode());


All good untill now, but when player doesn`t have subclass, he can't open cb and i get error on gameserver:
https://ibb.co/FKz1Hkx
Can someone tell me how and where i can add !=null ?

Pack: L2jMobius
Greetings !!

 

Hi. There are million ways to solve this including streams or fix the getClass() method and send only player.getSubClasses() but the easiest way to do that is by doing a check before that if player has any subclass then do what you do else replace with "-" 

 

So kinda like this:

 

returnHtml = returnHtml.replace("%subclass%", player.getSubClasses().size() > 0 ? ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode() : "-");

 

 

  • 0
Posted
14 minutes ago, 0flee said:

How i can find the value of .size()

By debugging. If you don't know how to debug in 2021 that will be a hard time for you developing (I'm not saying you don't know how to, you might know how to, though you would have solved this issue in 15sec if you did debugging).

The code above from Kara gave you everything to be fixed, why do you need to know exact size? command ".size()" calculates elements in collection (and function 'getSubClasses' return the collection, so the logic is get subs collection > calculate size). The value for different players with different subclasses amount will be different. 

About image you gave: NullPointer error means that you're trying to reach things that are not initialized or set. Always check if object exists before trying to take its actual value (would recommend reading a bit about that, it's the easiest to fix problem and you will face it a lot if you will continue on learning developing).
 

  • 0
Posted
19 hours ago, Kara said:

 

Hi. There are million ways to solve this including streams or fix the getClass() method and send only player.getSubClasses() but the easiest way to do that is by doing a check before that if player has any subclass then do what you do else replace with "-" 

 

So kinda like this:

 


returnHtml = returnHtml.replace("%subclass%", player.getSubClasses().size() > 0 ? ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode() : "-");

 

 

Best answer. Fixed, can close topic. Thank you !

Guest
This topic is now closed to further replies.


  • Posts

    • A widespread proxy service, operating through hijacked devices, has been shut down in a cross-industry effort led by Google. The network, known as IPIDEA, functioned by secretly converting millions of personal devices into proxies for malicious actors. The Mechanism of the Scheme The operation distributed hidden code within seemingly legitimate free apps and VPN services. Once installed, this code enrolled the user’s device into a pool of residential IP addresses. These addresses were then sold anonymously, primarily to cybercriminal and state-sponsored groups, to mask the origin of attacks, fraud, and espionage. Key impacts of the network included: Facilitating operations for more than 550 identified threat actors. Exposing unsuspecting device owners to potential legal and security risks by associating their IP addresses with criminal traffic. The Takedown Strategy Google and its partners disrupted the service by: Seizing core operational domains. Using Google Play Protect to detect and remove malicious applications. Coordinating with infrastructure providers to prevent the network from reestablishing itself. The action highlights the necessity of continuous user awareness, developer diligence in code reviews, and proactive industry cooperation to maintain cybersecurity. Front Companies Associated with IPIDEA IPIDEA masked its activities under various brand names, such as: Proxy Brands: 360 Proxy, 922 Proxy, Luna Proxy, IP2World, ABC Proxy. VPN Brands: Door VPN, Radish VPN, Galleon VPN. SDK Brands: PacketSDK, HexSDK (the toolkits used to embed proxy code).   Choosing Ethical Proxy Services Alternatives For lawful purposes like market research, ad verification, or data aggregation, selecting a transparent and consensual provider is essential. Reputable services obtain explicit user permission for their networks and enforce strict compliance measures. Examples of Established Providers: Bright Data: A leading, consent-based residential proxy network. Oxylabs: Provides large-scale proxy solutions for enterprise needs. MoMoProxy: Maintains a large pool of residential IPs for tasks like web scraping.   Only $850/1TB.  https://momoproxy.com   Identifying a Legitimate Provider: A trustworthy service will typically demonstrate: Informed Consent: Networks are built with the clear agreement of participants. Robust Compliance: Proactive systems to prevent abuse and respect website terms. Operational Transparency: Public-facing policies, identifiable corporate structure, and genuine customer support. Conduct thorough due diligence. Opt for providers that are clear about their IP sources and maintain strong anti-abuse policies, ensuring your legitimate activities do not inadvertently support harmful operations.
    • Lineage 2 Interlude Developer – Cliente + Datapack Hola, soy developer especializado en Lineage 2 Interlude con experiencia tanto en cliente como datapack/core. ✔ Desarrollo datapack (Java, scripts, quests, balance PvP/PvE) ✔ Fixes core / geodata / exploits ✔ Sistemas custom (events, Olympiad, instancias, mods PvP) ✔ Cliente: interface mods, system patches, .dat edits, UI personalizada ✔ Optimización y estabilidad de servidor ✔ Trabajo freelance o colaboración fija Si necesitáis soporte dev o mejoras para vuestro servidor Interlude, podéis contactarme por DM. Portfolio y ejemplos disponibles bajo petición.
    • Lineage 2 Interlude Developer – Cliente + Datapack Hola, soy developer especializado en Lineage 2 Interlude con experiencia tanto en cliente como datapack/core. ✔ Desarrollo datapack (Java, scripts, quests, balance PvP/PvE) ✔ Fixes core / geodata / exploits ✔ Sistemas custom (events, Olympiad, instancias, mods PvP) ✔ Cliente: interface mods, system patches, .dat edits, UI personalizada ✔ Optimización y estabilidad de servidor ✔ Trabajo freelance o colaboración fija Si necesitáis soporte dev o mejoras para vuestro servidor Interlude, podéis contactarme por DM. Portfolio y ejemplos disponibles bajo petición.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..