Jump to content
  • 0

Help with code ..


Re1d

Question

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

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

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
Link to comment
Share on other sites

  • 0
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).
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

    • ??? error   https://ibb.co/Srn4LsX No support  :S   No support : S ? :S
    • I also think this feature would bring more harm than good... another example is a dwarf rushing against your mobs so he takes priority, then he plays fake death and proceeds to grief the shit out of you. A minimum damage threshold is necessary, which would basically converge to what is the default feature (i.e. biggest damage dealer)
    • I bought the premium to watch the video and it's private. 😢
    • For some Majestic reason OP can't edit their topics anymore?    Let me update the potential offers, I got up to 2 spots to fill.   CONTACT TELEGRAM ONLY: https://t.me/asupport_g1     A credible team that SGuard represents is looking for java developers.    These positions is full time only i.e. your time is mostly dedicated within the team and team tasks, side gigs are fine, as long as you are able to combine your gig and main.  All necessary tools are provided.  The team is consistent with > 10 team members and the team is looking to expand to meet various goals. A decent Lineage 2 Essense OR Main (GOD) knowledge is needed.  Experience with l2r/l2p/l2s. mobius is fine too for referrence only. The team is friendly and goal oriented, very active and resourceful.   Requirements are standard, java knowledge is optional.  Multi language is a plus but not necessary (English/Russian), any is accepted.   Terms and conditions including compensation are reasonable and considered to be up for the industry standards. Details are negotiable with suitable candidates.   You will need to have a headset and a mic just for the initial processing, there're no team meetings or conferences after that. There's a small 30min interview process to demonstrate knowledge and just to meet each other.   The team has decided it is in their best interest to not publish their information at this time. Details will be available only for suitable candidates.   CONTACT TELEGRAM ONLY: https://t.me/asupport_g1
    • Thanks for the detailed info. I also have some ideas in mind but the execution may be hard. Thanks again!
  • Topics

×
×
  • Create New...