Introduction: Creating a Minecraft Plugin

Creating a Minecraft Plugin

Important Info

1. You need to be proficient in Java

2. You need to know about general programming concepts

Steps

· Download the necessary files.

· Create an eclipse Java project.

· Create a plugin.yml.

· Learn some bukkit basics.

· Learn some bukkit advanced topics.

Downloading the Necessary Files

Go to the server download site and download your minecraft server version.

Go to the eclipse download site and download the current version of eclipse if you do not already have it installed.

Go to the spigot download site and download the corresponding version of bukkit/spigot to your server version.

Create an Eclipse Java Project

Set up a new Java Project by clicking “create java project in the top corner”

https://gyazo.com/0fbdfb1ebf25658a72b7c451985b363d

Next, right click on your project and look for import external jars.

https://gyazo.com/237280f4102727a6b17d52b33a9e8f20

Now, find your bukkit/spigot file and select it in the list.

Create a plugin.yml

In the project path, create a file called plugin.yml

Follow this format, and insert information about your plugin and your name and other details.

name: Inferno

version: 1.4.1

description: This plugin is so 31337. You can set yourself on fire.

# We could place every author in the authors list, but chose not to for illustrative purposes

# Also, having an author distinguishes that person as the project lead, and ensures their

# name is displayed first

author: CaptainInflamo

authors: [Cogito, verrier, EvilSeph]

website: http://forums.bukkit.org/threads/MyPlugin.31337/

main: com.captaininflamo.bukkit.inferno.Inferno

database: false

depend: [NewFire, FlameWire]

commands:

flagrate:

description: Set yourself on fire.

aliases: [combust_me, combustMe]

permission: inferno.flagrate

usage: Syntax error! Simply type /<command> to ignite yourself.

burningdeaths:

description: List how many times you have died by fire.

aliases: [burning_deaths, burningDeaths]

permission: inferno.burningdeaths

usage: |

/<command> [player]

Example: /<command> - see how many times you have burned to death

Example: /<command> CaptainIce - see how many times CaptainIce has burned to death

permissions:

inferno.*:

description: Gives access to all Inferno commands

children:

inferno.flagrate: true

inferno.burningdeaths: true

inferno.burningdeaths.others: true

inferno.flagrate:

description: Allows you to ignite yourself

default: true

inferno.burningdeaths:

description: Allows you to see how many times you have burned to death

default: true

inferno.burningdeaths.others:

description: Allows you to see how many times others have burned to death

default: op

children:

inferno.burningdeaths: true

For more information on creating a plugin.yml, go here: https://bukkit.gamepedia.com/Plugin_YAML

Bukkit Basics

The basics of bukkit are fairly easy to learn. Bukkit is the base package of everything. Then, one can use Bukkit.server to be able to get the server object and be able to perform actions on server objects.

Using the Server object, one can perform actions such as:

  • Ban/Ip ban players
  • Broadcast Messages
  • Create Worlds
  • Change Server Settings
  • Terminate the server

One can use Bukkit.getServer().getOnlinePlayers() to be able to get the list of all online players. 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.

Here are a few actions one can perform with a Player object:

  • Add potion effects to the player
  • Damage the player
  • Change the player's permissions
  • Give the player experience
  • Open menus for the player such as the enchanting menu
  • Play sounds to the player
  • Give the player a custom name
  • Give the player a velocity
  • Teleport the player
  • etc...

One can also get many other useful Bukkit objects such as an Inventory, Entity, or Creature.

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.

Bukkit Advanced

The events system in Bukkit is not too complicated. However, it’s important to learn and understand it. 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:

https://gyazo.com/dd0f19e755146785af13220c6a3c60eb

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.

Conclusion

I’ve showed you some of the ways that you can get a Bukkit plugin up and running and how to accomplish some basics in one. For more guides on bukkit specifics see my list below of great guides. Now, go get out there and make some awesome plugins!

Events

General plugin/java tutorial

Creating commands