Plugin error saying NullPointerExeception.null

Status
This thread has been locked.

PandaPlaysAll

|Survival Server in Construction|
Premium
Feedback score
22
Posts
660
Reactions
252
Resources
0
Main Class;


Command Class;


For some reason the console errors aren't pointing me in any direction.

Side not. what is the difference between 'awt' and 'util'
as previously I made a error for importing
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Mooselk

Motocross enthusiast
Premium
Feedback score
9
Posts
298
Reactions
213
Resources
0
If no one can answer your question here, stack overflow is where you should go for the best answer.
 

PandaPlaysAll

|Survival Server in Construction|
Premium
Feedback score
22
Posts
660
Reactions
252
Resources
0
Last edited:

Dori

Full Stack Developer
Supreme
Feedback score
28
Posts
459
Reactions
198
Resources
0
Don't create your own

public MenuCommand(Main main) {
this.main = main;
}

Just do:
new MenuCommand()
When you register the command.
 

Jack Black

Feedback score
0
Posts
9
Reactions
1
Resources
0
Main Class;

For some reason the console errors aren't pointing me in any direction.

Side not. what is the difference between 'awt' and 'util'
as previously I made a error for importing

A NullPointerException is a Runtime Exception that is being thrown when a pointer reference is null. In this situation, you are trying to call the .setExecutor() method of the class implementing the CommandExecutor interface.

The spigot framework will grab the commands from the plugin.yml configuration and if it does not find anything there, it will not create the object, therefor, you cannot set an executor on something that does not exist.

Please look into more details of what Runtime Exceptions are, what a try-catch block is, how to throw exceptions and OOP concepts in general. It will help you greatly when working with such an extensive API.

Look into Encapsulation, Override, Overload, Interfaces, Class Inheritance, Abstract Classes, repetitive patterns, decisional patterns and declarations for best understanding of the topic.

As for your imports, they are two different packages from two different sources. You need to look into all of the libraries that are inside the spigotAPI in order to properly understand the tools you can work with.
 
Last edited:

PandaPlaysAll

|Survival Server in Construction|
Premium
Feedback score
22
Posts
660
Reactions
252
Resources
0
SOLVED
 
Last edited:

technerd

Feedback score
1
Posts
21
Reactions
6
Resources
0
You also imported the wrong ChatColor! The correct import would be org.bukkit.chatcolor.
 

Jack Black

Feedback score
0
Posts
9
Reactions
1
Resources
0
Technically it doesn't matter if you use the spigot import or the bukkit version, they're just converted to a string using the prefix "§"<number of code> when compiled anyways.
Thinking of situations where the server does not have the md_5 package, it will throw a NoClassDefFoundError. But I see your point, considering most of the plugins nowadays are built on the spigot API which contains that package.
 
Last edited:
Status
This thread has been locked.
Top