Developing a Gametype - 2n3904/Battlefields GitHub Wiki
#Developing a Gametype
First, a disclaimer. Gametypes are written in Java and therefore you must have knowledge of coding in Java to make them! Preferably also experience writing plugins for Bukkit.
Overview
Gametypes are actually very similar to your typical Bukkit plugin. If you are familiar with writing plugins for bukkit, you should have no trouble with it! This is because the system for loading gametypes into Battlefields is based off of the system for loading plugins into Bukkit and actually uses some of the same classes.
Gametype plugins need three main classes, and one gametype.yml file which mirrors the functionality of a Bukkit plugin's plugin.yml. The parts are described below:
Gametype Plugin (Class extends GametypePlugin)
This is the class which essential holds the configuration information of the plugin and manages the various aspects of the gametype across all of the fields. It holds both the gametype.yml information as well as the configuration map.
Gametype Game (Class extends Gametype)
This is an object which essentially is obtained as an instance of the gametype for a field. This is loaded onto the field when selected using the gametype sign. This is used to obtain the listener, to store data, and whatever else.
Gametype Listener (Class extends GametypeListener)
This is the heart of the gametype. Since a gametype is basically a set of conditions triggered on events, 90% of the functional aspect of the plugin will be written here.
The gametype listener works the same as a listener class in Bukkit, except that you do not need to register events. The listener call is always called no matter what and if you do not override the listener method in this class it will basically do nothing. The listener calls are tailored for the battlefield that the gametype is occuring on. This means that all the listener calls will have already been checked and will only apply to players in the game, and they will supply arguments with as much Battlefields related data as possible.
gametype.yml (Yaml File)
The gametype.yml file is essentially a general description file for the gametype that tells Battlefields how to deal with the plugin and what general characteristics it has. It contains a pointer to the GametypePlugin class, the name of the plugin, the author, and other reference tags. Additionally, it has a list of the allowed teams for the gametype, a list of the score types associated with it, and a list of the names of the editable options that players in-game can configure for a match.