Building Minecraft Server Modifications Second Edition
Table of Contents
Building Minecraft Server Modifications Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Deploying a Spigot Server
Introduction to Spigot
Installing a new Spigot server
Setting up a new server
Minecraft/Bukkit server commands
Port forwarding
Summary
2. Learning the Bukkit API
Introduction to APIs
The Bukkit API documentation
Navigating through the Bukkit API documentation
Understanding the Java documentation
Exploring the Bukkit API
Summary
3. Creating Your First Bukkit Plugin
Installing an IDE
Creating a new project
Adding Bukkit as a library
The essentials of a Bukkit plugin
The plugin.yml file
The plugin's main class
Making and calling new methods
Expanding your code
Summary
4. Testing on the Spigot Server
Building a JAR file
Installing the plugin
Testing your plugin
Testing new versions of the plugin
Debugging the code
Learning from your mistakes
When researching is not enough
Reading the stack trace
Breaking down the code
Adding debug messages
Referring back to the Javadoc
Fixing the bug only after you understand it
Summary
5. Plugin Commands
Adding a command to plugin.yml
Programming the command actions
Assigning the executor for the enchant command
Summary
6. Player Permissions
The benefits of permissions
Understanding permission nodes
Adding a permission node to plugin.yml
Assigning a permission node to a plugin command
Testing player permissions
Using a third-party permissions plugin
Using permission nodes throughout your plugins
Summary
7. The Bukkit Event System
Choosing an event
Registering an event listener
Listening for an event
Canceling an event
Communicating among events
Modifying an event as it occurs
Creating more plugins on your own
Summary
8. Making Your Plugin Configurable
Configurable data types
Writing a config.yml file
Saving, loading, and reloading the config file
Reading and storing the configured values
Using configured settings within your plugin
ItemStack within a configuration
YAML configuration hierarchy
Storing configuration values as variables
Accessing variables from another class
Summary
9. Saving Your Data
Types of data that can be saved
Which data to save and when
A sample teleportation plugin
Writing a ConfigurationSerializable class
Saving data to a YAML configuration
Loading data from a YAML configuration
Summary
10. The Bukkit Scheduler
Creating a BukkitRunnable class
Synchronous versus asynchronous tasks
Running a task from a BukkitRunnable class
Running a task later from a BukkitRunnable class
Running a task timer from a BukkitRunnable class
Writing a repeating task for a plugin
Adding a delayed task to a plugin
Executing code asynchronously
Summary
Index
Building Minecraft Server Modifications Second Edition
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2013
Second edition: December 2015
Production reference: 1151215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-302-6
www.packtpub.com
Cover Image by Cody M. Sommer
Author
Cody M. Sommer
Reviewers
Thomas E. Enebo
Pat Patterson
Commissioning Editor
Veena Pagare
Acquisition Editor
Vinay Argekar
Content Development Editor
Divij Kotian
Technical Editor
Mohit Hassija
Copy Editor
Vedangi Narvekar
Project Coordinator
Neha Bhatnagar
Proofreader
Safis Editing
Indexer
Priya Sane
Graphics
Kirk D'Penha
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
Cody M. Sommer graduated from SUNY Brockport with a bachelor's degree in computer science. During his time in college, he practiced his Java techniques by writing code for Bukkit plugins. The Bukkit project provided Cody with a fun way to develop software and continue to learn new things. After a few years, Cody authored the first edition of Building Minecraft Server Modifications in order to share his knowledge with the world. To this day, he creates new and exciting plugins for Minecraft servers. Cody has developed public plugins that are available for download, such as PhatLoots. He is also a private developer for servers such as ProspectMC. He even makes custom plugins for Minecraft events, which are hosted by him at his local library.
Thomas E. Enebo is the co-leader of the JRuby project and author of the Minecraft plugin project, Purugin. He has been a practioner of Java since the heady days of the HotJava browser, and he has happily been using Ruby since 2001. Thomas has spoken at many Java and Ruby conferences, co-authored Using JRuby, and won the Ruby Hero award. He was awarded the "Rock Star" award at JavaOne. When Thomas is not coding, he enjoys jogging, reading, and drinking a nice India pale ale (IPA).
Pat Patterson has been working with Internet technologies since 1997. He has built software and worked with developer communities at Sun Microsystems, Huawei Technologies, and Salesforce. At Sun, Pat was best known as the community lead for the Op...