Jump to content
  • 0

Help with code ..


Question

Posted

Hello all,

 

I've been just trying to implement one very simple voice command  on the server pack . 

 

I get no errors during compilation , but when  i run gameserver i get that error at the end.

 

I tried to trace it down but i cant find it..

 

I went on to net.sf.l2j.gameserver.handler.UserCommandHandle and line 45 but it shows no error . 

 

any help would be greatly appreciated.

 

This is the error

 

Exception in thread "main" java.lang.ExceptionInInitializerError
        at net.sf.l2j.gameserver.handler.UserCommandHandler.getInstance(UserCommandHandler.java:45)
        at net.sf.l2j.gameserver.GameServer.<init>(GameServer.java:277)
        at net.sf.l2j.gameserver.GameServer.main(GameServer.java:383)
Caused by: java.lang.NullPointerException
        at net.sf.l2j.gameserver.handler.UserCommandHandler.registerUserCommandHandler(UserCommandHandler.java:70)
        at net.sf.l2j.gameserver.handler.UserCommandHandler.<init>(UserCommandHandler.java:51)
        at net.sf.l2j.gameserver.handler.UserCommandHandler$SingletonHolder.<clinit>(UserCommandHandler.java:97)
        ... 3 more

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

UserCommandHandler.java line 70 ends with a NPE. If it's your new handler, verify if you initialized it correctly.

 

Short version : UserCommandHandler instance can't load properly, because an error (NPE) has been found on line 70 during the registration of an handler.

Edited by Tryskell
  • 0
Posted
On 4/12/2019 at 4:37 PM, SweeTs said:

 

NullPointerExceptions are exceptions that occur when you try to use a reference that points to no location in memory (null) as though it were referencing an object. Calling a method on a null reference or trying to access a field of a null reference will trigger a NullPointerException

 

For example,

 

String s = null;
int len = s.length();  // NullPointerException because s is null

So you should check if the variable is null before calling any method on it, for example:

int len;
if (s == null) {
    len = 0;
}
else {
    len = s.length();  // safe, s is never null when you get here
}

 

How to avoid NullPointerExceptions?

 

  • Use the final modifier to enforce good initialization.
  • Avoid returning null in methods, for example returning empty collections when applicable.
  • Use annotations @NotNull and @Nullable
  • Fail fast and use asserts to avoid propagation of null objects through the whole application when they shouldn't be null.
  • Use equals with a known object first: if("knownObject".equals(unknownObject)
  • Prefer valueOf() over toString().
  • Use null safe StringUtils methods StringUtils.isEmpty(null).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • What complaint are you talking about? I didn't accuse anyone. They came to our topic and began pouring unreasonable dirt, and giving screenshots from competitive forums, where they and their fellow competitors are engaged in blackening our name. Have we offended you in any way?
    • I would like to clarify something publicly because false statements should not go unanswered. I have absolutely no relationship, partnership, or special connection with SkyLord. Any claim suggesting otherwise is entirely unsupported and based on assumptions rather than facts. It is disappointing to see people making accusations against others without presenting a single piece of evidence. Disagreement is one thing; inventing narratives and presenting personal opinions as facts is something completely different. If someone believes I have acted improperly, they are welcome to provide verifiable proof. Until then, these allegations are nothing more than speculation and should be treated as such. I have always been responsible for my own actions and opinions, and I do not need anyone's protection, influence, or assistance to participate in any community. Making accusations without evidence does not strengthen an argumen it only damages the credibility of the person making them. It should be clarified that I have already filed a report so that action can be taken; it is not fair that a post is being distorted in the way that has been happening.  
    • I don't think there is any bias on maxcheaters, this is the only forum left of the major ones where there is an honest administration. You may have meant mmodev, where the administration really has an interest in such fakes about competitors. I am not in favor of posting other people's correspondence, where they discuss with each other how to destroy us... but I'm not going to do this and post it, it's low, I hope that people themselves will finally understand that they are behaving completely wrong and unprofessionally.
    • I am really sorry for what SkyLord is doing to you. Unfortunately, this is not an isolated problem. The same kind of attacks have been happening to me as well. From my point of view, the issue is bigger than just one person, because SkyLord works closely with UnknownSoldier, who is a moderator on MaxCheaters, and that gives them influence and protection inside the forum. This is why they attack you in the same way they attack me: with pressure, manipulation, false accusations, and attempts to damage your reputation. In my opinion, the real problem is that privileges were given to the wrong people. As long as people like this have power there, the forum cannot be trusted anymore. I just wanted to tell you that I understand what you are going through, and I stand with you. They have done the same to me.
  • 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..