Skip to content

Creating the plugin

Ali edited this page Nov 21, 2023 · 2 revisions

Creating our plugin class

After getting all our dependencies set up, we will now start coding.

The java directory

Create a package. We will use org.example.sunbans. See Java specs for information on package naming.

Create a package

Create a class in that package with your plugin name. We will name it SunBans

SunBans class

Our class must extend org.bukkit.plugin.JavaPlugin, and it should override onEnable() and onDisable(). We also will make our class final, as it should not be extended by accident.

package org.example.sunbans;

import org.bukkit.plugin.java.JavaPlugin;

public final class SunBans extends JavaPlugin {

    @Override
    public void onEnable() {
    }

    @Override
    public void onDisable() {
    }
}

We also have to create a plugin.yml in the resources directory.

name: SunBans
main: org.example.sunbans.SunBans
description: A simple punishment plugin
version: 1.0
api-version: 1.13

We're all set up! In the next tutorial, we will create a basic /hello command to make sure everything works as expected.

This is how your project should look

Final project structure