Skip to content
alkarinv edited this page Apr 2, 2013 · 9 revisions

Table of Contents

Overview

Here are the steps you will need to take to create your own plugin.

  1. in your plugin.yml, you must depend on BattleArena.
  2. register your plugin with BattleArena inside of onEnable
  3. Create a Class that extends Arena
  4. Create your default Config.yml file
After that everything else is optional. For an easy plugin that shows how to make custom events and matches check out the Paintball code. ArenaPaintball.

Details

Creating your plugin.yml

The most important part here is the depend: [BattleArena]. This is not "depends" depends will not work.

Example

name: SuperCrushers

version: 1.0
author: alkarin

description: A sweet crush the blocks plugin!
depend: [BattleArena]  ### <--- the important line
main: mc.alk.crush.SuperCrushers

Registering your plugin with BattleArena

Registering takes the following

  1. your plugin
  2. The name of your competition
  3. The command for your competition
  4. Your arena class (which extends Arena)
  5. (optional) an executor for handling commands

Example: Registering your new competition

@Override
	public void onEnable(){
		/// Register our SuperCrushers plugin, the command will be "sc"
		BattleArena.registerCompetition(this, "SuperCrushers", "sc", SuperCrusherArena.class);
	}

Creating an Arena class

Create a class that extends Arena. An arena class will get created once during server start up, and will get destroyed and recreated if someone uses the /arena alter, command.

Example Arena 1

This will actually work. It just does nothing custom, usually we want to listen for some sort of events and change them.

public class SuperCrusherArena extends Arena{
}

Example Arena 2

This time we are registering the EntityDamageEvent and changing the damage of snow balls, this is what ArenaPaintball does. Notice the @MatchEventHandler, this will make sure that this event will ONLY be called when it is performed by someone inside of the Current competition.

public class SuperCrusherArena extends Arena{
	@MatchEventHandler
	public void onEntityDamage(EntityDamageByEntityEvent event) {
		if (event.isCancelled())
			return;
		if (event.getDamager().getType() != EntityType.SNOWBALL)
			return;
		event.setDamage(20);
	}
}

Creating your Config.yml

This is probably the most important part. To make a config file for your plugin it must be named the same thing as what you registered... so if you registered "SuperCrusher" then your config file should be called "SuperCrusherConfig.yml" and should be located in the same place as your plugin.yml. Inside their should be the options you want to be default when people load your plugin.

Example Config.yml

Here is an example config to get you started

configVersion: 2.0
## This should be placed in the plugin directory
## for more help configuring see the wiki
## https://github.com/alkarinv/BattleArena/wiki
## Change this file to customize your event

SuperCrusher:  ### This should be exactly the same as the name you registered
    enabled: true
    database: SuperCrusher # needs BattleTracker
    rated: true # if database is enabled
    prefix: "&6[SuperCrusher]&e"
    cmd: sc
    nTeams: 2+
    teamSize: 1
    joinType: Queue ## there are 2 join types, Queue and JoinPhase
    victoryCondition: LastManStanding
    ### You can delete any stages/transitions that have no options
    ### for a list of options see wiki
    preReqs: ## Prerequisites for joining
        options: []
    onEnter:
        options: [storeAll]
    onLeave:
        options: [restoreAll]
    onJoin:  ## when they join the match
        options: []
    onPreStart: ## x seconds before onStart
        options: []
    onStart: ## Starting
        options: [teleportIn, pvpOn]
    onSpawn: ## what happens when a player spawns
        options: [hunger=20, health=20]
        giveClass: 
            default: Gladiator
    onDeath: ## what happens when a player dies
        options: []
    onComplete: ## what happens when things end
        options: [teleportOut, clearInventory]
    winner: ## what to give the winner
        options: [health=20, hunger=20]
    losers: ## what to give the losers
        options: []

JavaDocs

JavaDocs

Maven Repository

For people using Maven you can add this to your pom.xml to include BattleArena.

  <repositories>
  ... 
    <repository>
      <id>battleplugins-net</id>
      <name>BattlePlugins</name>
      <url>http://battleplugins.com/maven</url>
    </repository>
  ...
  </repositories>

  <dependencies>
  ...
    <dependency>
      <groupId>mc.alk</groupid>
      <artifactId>BattleArena</artifactid>
      <version>3.8.3.4</version>
    </dependency>
  ...
  </dependencies> 
You can’t perform that action at this time.