Give it any name; often the same name as the project. Inside the editor, the newly created Java class will open. The code should look somewhat like this:. Your class must extend from JavaPlugin. Eclipse will produce an error as it does not know what JavaPlugin is. If you have successfully imported the Spigot-API, you will be able to import JavaPlugin by adding the import statement. You do not need to manually type that line, simply click the error and select the appropriate action.
Your code should now look like:. The JavaPlugin class has some abstract methods which must be implemented by your plugin. Hence, add the onEnable and onDisable functions which will be triggered when the plugin is disabled or enabled in the console. You can leave these blank for now. You are also required to write Override above the method. Note: You do not need to add a getLogger when your plugin is enabled or disabled, Bukkit already does that for you.
Name it plugin. Paste in the following:. Since there are no errors, we can export this project as a JAR. Then, one can use Bukkit. One can use Bukkit. One can also use a method similar to this to be able to get a specific Player object. The player object has many parameters and methods. Try some basics: Get your player by searching for your name when you type a command and use your player object to give yourself a velocity.
You should see your player move if you do this correctly. Look up documentation on commands on how to register the command. The events system in Bukkit is not too complicated. First, you need an eventhandler and to make it listen for events.
You need to do this in your main plugin class, ideally, on plugin start up. Details on doing this can be seen here:. Then, you can listen on specific events and execute code when the events occur. Simply name a method with the same name as the event name and put EventHandler above the method so the compiler knows the method is an event. Bukkit does not support some features such as Custom Mob support.
To do this, you will need to use NMS. You will find some guides on this however, it is quite complex and I do not recommend doing this unless you really need it.
For more guides on bukkit specifics see my list below of great guides. Now, go get out there and make some awesome plugins! Creating commands.
0コメント