A Guide to Minecraft Plugin Development with Bukkit | Part 1

Prerequisites

Running a local Spigot server

NOTE: This guide is about plugin development, so I didn’t care much about the server I chose. Probably you’d want to choose Paper over Spigot for lots of cases but the workflow for plugin development stays the same.

Creating a basic plugin

implementation group: 'org.bukkit', name: 'bukkit', version: '[VERSION]'
maven { 
url "https://hub.spigotmc.org/nexus/content/repositories/public/"
}
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>[VERSION]</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>

INFO: YAML (YAML Ain’t Markup Language) is a human-readable data-serialization standard, which is commonly used for configuration files. It uses the file extension .yaml or .yml.

name: MinecraftPluginGuide_DemoPlugin
main: BukkitPlugin
version: 0.1
api-version: 1.16

Deploying a plugin

./gradlew jar
jar { 
manifest {
attributes "Main-Class": "BukkitPlugin"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
id 'com.github.johnrengelman.shadow' version '[VERSION]'
plugins { 
id 'java'
id 'com.github.johnrengelman.shadow' version '[VERSION]'
}
./gradlew shadowJar
IntelliJ IDEA Community Maven Tasks

Logging

logger.log(Level.INFO, "Info log message");
logger.info("Info log message");
prefix: custom-log-prefix
logger.setLevel(Level.INFO);

Understanding Minecraft’s coordinate system

Minecraft’s coordinate system

Adding custom commands

commands:
log-anything:
description: Logs a message to the console
aliases: [loganything, log_anything]
usage: /log-anything
log:
description: Logs the given message to the console
usage: /log [message]
if (sender instanceof Player) { 
// Command was sent from a player
}

Communicating with the player

player.sendMessage("This is a chat message");
player.sendTitle("This is a title", "And a subtitle", 10, 70, 20);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);

What’s next?

Resources

Version information

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store