Because I'm a contrarian, I don't want to use a build system. If you don't live in bizarro world, you will probably want to use an IDE instead.
This assumes you already have the JDK installed. On Debian, you can install that using apt install openjdk-14-jdk
(note! minecraft 1.8.8 requires an older Java version. use openjdk-8-jdk
)
plugin.yml
fileCreate a directory for your plugin. Make a plugin.yml
file with the following contents:
name: My Plugin
main: org.example.myplugin.MainClass
version: 1.0.0
You will need to add at least these three keys for the plugin to load. For a list of all the keys that can be added to the file, see https://www.spigotmc.org/wiki/plugin-yml/.
Create a subdirectory named lib
. Head to https://hub.spigotmc.org/nexus/content/repositories/public/org/bukkit/bukkit/ and download the Bukkit JAR (e.g. bukkit-1.8.8-R0.1-20160221.082532-43.jar
) for the Minecraft version you are targeting. Place it in lib
.
Create subdirectories based off of the package name. In this example, our package is called org.example.myplugin
, so we mkdir -p org/example/myplugin/
. Then, we create the main class (called MainClass.java
) with these contents:
package org.example.myplugin;
import org.bukkit.plugin.java.JavaPlugin;
public final class MainClass extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Hello World!");
}
@Override
public void onDisable() {
getLogger().info("Goodbye, world.");
}
}
In the main directory, run this command to rebuild the classes: javac -classpath lib/your-bukkit.jar org/example/myplugin/*.java
. If you have multiple libraries in lib
, separate them using a colon, or semicolon if you use Windows. (e.g. -classpath 'lib/bukkit.jar:lib/spigot-api.jar'
)
Now, we add our built class and the manifest to a JAR file, which can be loaded by putting it in the plugins directory: jar cf myplugin.jar plugin.yml org/example/myplugin/*.class
. If you need to add more files to the JAR file, for example, a default config.yml
, tack it on to the end of that command.
You will probably want to download the Javadoc for your Bukkit version. It's in the same directory as the regular JAR, but ends in -javadoc.jar
. Extract it (in a subdirectory, it will put files in the current directory) using jar xf some-javadoc.jar
, and open the index.html
file in your web browser. Also visit the SpigotMC Wiki.