320 likes | 515 Views
Checklist. Do you have Java JDK installed? Do you have the latest bukkit jar file installed? Do you have Minecraft installed? Do you have the github files installed? Do you have the bukkit server files?. Creating Bukkit Plugins. What you should learn. How to build a Bukkit plugin
E N D
Checklist • Do you have Java JDK installed? • Do you have the latest bukkit jar file installed? • Do you have Minecraft installed? • Do you have the github files installed? • Do you have the bukkit server files?
What you should learn • How to build a Bukkit plugin • How to find information about the API an Java • How to make cheats and react to the game
What is a plugin? • A plugin for Bukkit is a jar file • A jar file is a zip file. Inside the structure of the file corresponds to what Bukkit expects • It needs compiled Java code and a plugin.yml file
Compile the Java code javac -Xlint -classpath ../../craftbukkit.jar Hello.java
Create the jar file • Create the bin folder • Inside the bin folder, create Hello folder • Move Hello.class into this folder • Copy plugin .yml into bin jar -cvf Hello.jar -C bin .
Install the plugin • Copy Hello.jar and put it in plugins folder
Test the plugin • Start bukkit • Start Minecraft • Type /hello bob
Writing Cheats • Now we are going to learn how to write cheats • Cheats are Commands • A command is an order that you can type into Minecraft via / command arguments
How to write a command • For a command to work you need • The description of the command in the plugin.yml • The code in your java file
Plugin.yml • This is a configuration file • It tells Bukkit • the name of our module, • its main class – the start up class • what commands exist within your plugin
Spells.java • The onCommand event • Check for our command • Then call the method that executes the command
Build the Spells plugin Look at the code and try the different spells How would you make your own?
How do we change Minecraft? • Through the Bukkit API Application Programming Interface
What is the API • The API is like a dictionary to tell the computer what to do • Each package is like a chapter in the dictionary
How is it organized? The API is organized as a map of idea What categories do we have? • World • Player • Blocks • Events
How to explore the API • Think of what you would like to do • I want to change the whether! • Think of what category does it fall into • Is it a player? • A block? • A World event?
Browse through the documentation • Look at the packages. Click them • Look at what classes are within the package • Click on something like looks correct
Reading the class documentation • Find out to what package it belongs so you can import it correctly • In the method list, look for what you want to do • Use the search function to find possible methods • Remember that Java uses get() and set() as a convention for changing values
Making sense of the API • Good libraries are consistent • If you found something related to Pigs under entities, then other beings, like chickens, should be under entities • The more you use the documentation, the better you will get at finding what you need
If you can’t find it, Google Search following this convention bukkit api <what you want to find out> bukkit api player’s hunger • Seek out bukkit.org result and minecraft forums results • Watch out for outdated information. Keep an eye for bukkit versions and the dates
Events • Build the Hydra plugin • Install it • Summon zombies through the “rise” command • Fight it until you defeat it
What is an event? • Events are things that happen in the game • Hitting a block • Eating • Waking up
Event handler • If-then code • If the event happens, then do this
How to write an event • We need an event listener • We need to use the annotation • We need to write the event function • You need to find the right event in the documentation
Writing Hydra • Idea: when you kill a zombie, two will spawn! • Events: when a Zombie dies • Look in the API
Even the sun will create more! • I need them to respawn only when I kill them • Find the damage event • Set a variable • Modify our original event handler
The tools • Making changes by hand is boring. So I built some scripts to automate the boring parts away
New.sh • Use it as ./new.sh <name> • It will create a template for a new plugin • You need to change every word that says CHANGEME
Build.sh • It will compile, move the files, create a jar, and move the jar to the plugin folder
What else is there to learn? • Build tools • IDE for development • More Java • Bukkit services • Saving data