public abstract class CTFBattleClass
extends java.lang.Object
Bukkit imports and ctf.* with
ctf.eventmanipulation.*.Location, World argument should be
getGameWorld().getPlayer().abstract methods of this
class, as that will impact overall server performance. In general each
implementation should use maximum one lightweight timer registration.onInitialization() method.setDamager(Player). Direct hits are registered
automatically, so it is not recommended to set damager in
onEntityHit(Entity, DamageState, CancelState, DamageType)
to save performance.public static String field with variable name Description and
assign String object that contains description.Block.setMaterial(Material)
or Block.setData(byte) is not recommended. Better solution is to call
modifyBlock(Block, Material, byte, int). registerBukkitHandler().Entity
in ANY Damage events! This includes
onGetHit(Entity, double, DamageType) and
onEntityHit(Entity, DamageState, CancelState, DamageType)
calls!!! Failing to do so will result in method looping and eventually
OutOfMemotyError.World.createExplosion([args]) as
those methods do not raise EntityExplodeEvent and will result in
permanent map damage until complete reload. Instead use
createBlockExplosion(Location, float).Material.COOKED_BEEF, he/she
will be healed by 5 hearts.AssertionException or ExceptionInInitializerError.
lib package. registerBukkitHandler()
and register events as would be done in normal Bukkit plugin.Eclipse:MyBattleClass extends CTFBattleClass).Eclipse will ask to add unimplemented
methods or to make created class abstract, option to add unimplemented
methods should be chosen.| Modifier and Type | Method and Description |
|---|---|
org.bukkit.block.Block[] |
createBlockExplosion(org.bukkit.Location loc,
float power)
Creates explosion in specified location and returns affected blocks in an
array.
No blocks are destroyed in the game world. |
org.bukkit.entity.Item |
dropItem(org.bukkit.Location location,
org.bukkit.inventory.ItemStack itemstack,
int removedelay)
Drops an item in game world.
Negative values of removedelay will not start remove trigger. |
org.bukkit.entity.Item |
dropItemNaturally(org.bukkit.Location location,
org.bukkit.inventory.ItemStack itemstack,
int removedelay)
Drops item with random offset in game world.
Negative values of removedelay will not start remove trigger. |
abstract org.bukkit.inventory.ItemStack[] |
getArmor()
This method must return armor contents array.
Contents of returned array will not be modified in any way. Null values represent no armor for the slot.[0] = Helmet [1] = Chestplate [2] = Leggings [3] = Boots |
abstract org.bukkit.inventory.ItemStack[] |
getEquipment()
This method must return inventory contents array.
Contents of returned array will not be modified in any way. Null values represent no item for the slot.Indexes of items in the returned array will correspond to placement of those items in the inventory. |
org.bukkit.World |
getGameWorld()
Gets current gameworld.
|
org.bukkit.entity.Player[] |
getInGamePlayers()
Gets all players that are in game.
|
org.bukkit.entity.Player |
getLastDamager()
Gets last player that damaged this player.
|
org.bukkit.entity.Player |
getPlayer()
Gets player that chose this class.
|
Team |
getPlayerTeam(org.bukkit.entity.Player player)
Used to determine player team.
|
TickTimer[] |
getRegisteredTimers()
Gets immutable array of currently active timers this
CTFBattleClass instance has registered. |
void |
modifyBlock(org.bukkit.block.Block block,
org.bukkit.Material material,
byte data,
int repairdelay)
Sets target block's material and byte data.
|
abstract void |
onAirLeftClick()
Called when this player left-clicks no block.
|
abstract void |
onAirRightClick()
Called when this player right-clicks no block.
|
abstract void |
onBlockLeftClick(org.bukkit.block.Block block)
Called when this player left-clicks a block.
|
abstract void |
onBlockRightClick(org.bukkit.block.Block block)
Called when this player right-clicks a block.
|
abstract void |
onDefeat(org.bukkit.entity.Player successor)
Called when this player is killed by another player.
|
abstract void |
onDropItem(org.bukkit.inventory.ItemStack itemstack)
Called when this players drops an item (default: Q).
Note that no item is actually dropped. |
abstract void |
onEntityHit(org.bukkit.entity.Entity victim,
DamageState damage,
CancelState cancel,
DamageType damagetype)
Called when this player hits another entity.
|
abstract void |
onEntityRightClick(org.bukkit.entity.Entity victim)
Called when another entity gets right-clicked by this player.
|
abstract void |
onGetHit(org.bukkit.entity.Entity damager,
double damage,
DamageType damagetype)
Called when this player is hit by another entity.
|
abstract void |
onInitialization()
Called when this class is first instantiated.
This method can be safely used to add special effects to this player, register essential timers. |
abstract void |
onPlayerKill(org.bukkit.entity.Player victim)
Called when this player kills another player.
|
abstract void |
onProjectileLaunch(org.bukkit.entity.Projectile p,
CancelState cancel) |
void |
registerBukkitHandler()
Deprecated.
Handling Bukkit events directly can break CTF Game Handler
mechanics.
|
TickTimer |
registerNewDelayedTask(java.lang.Runnable runnable,
int delay)
Registers new timer to be run once after specified delay.
|
TickTimer |
registerNewRepeatingTask(java.lang.Runnable runnable,
int delay)
Registers new timer to be run at specified rate.
|
void |
resetBlock(org.bukkit.block.Block block)
Resets specified block to it's initial state if it was modified with
modifyBlock(Block, Material, byte, int) call. |
void |
setDamager(org.bukkit.entity.Player victim)
Sets this player as last damager of specfied player.
|
org.bukkit.entity.Arrow |
spawnArrow(org.bukkit.Location location,
org.bukkit.util.Vector vector,
float speed,
float spread,
int removedelay)
Spawns an arrow in game world.
Negative values of removedelay will not start remove trigger.Arrows have special support to be removed when in ground. |
org.bukkit.entity.LivingEntity |
spawnCreature(org.bukkit.Location location,
org.bukkit.entity.CreatureType creaturetype,
int removedelay)
Spawns living entity in game world.
Negative values of removedelay will not start remove trigger. |
org.bukkit.entity.Entity |
spawnEntity(org.bukkit.Location location,
org.bukkit.entity.EntityType entitytype,
int removedelay)
Spawns an entity in game world.
Negative values of removedelay will not start remove trigger. |
void |
unregisterBukkitHandler()
Deprecated.
|
public final org.bukkit.entity.Player[] getInGamePlayers()
Bukkit.getOnlinePlayers().public final Team getPlayerTeam(org.bukkit.entity.Player player)
player - player to get teamTeam
objects should compared with == operator!public final org.bukkit.entity.Entity spawnEntity(org.bukkit.Location location,
org.bukkit.entity.EntityType entitytype,
int removedelay)
throws InstanceDisposedException
removedelay will not start remove trigger.location - location of spawned entityentitytype - type of entity to spawnremovedelay - delay in ticks after which spawned entity will be removedInstanceDisposedExceptionpublic final org.bukkit.entity.LivingEntity spawnCreature(org.bukkit.Location location,
org.bukkit.entity.CreatureType creaturetype,
int removedelay)
throws InstanceDisposedException
removedelay will not start remove trigger.location - location of spawned entitycreaturetype - type of entityremovedelay - delay in ticks after which spawned entity will be removedInstanceDisposedExceptionpublic final org.bukkit.entity.Arrow spawnArrow(org.bukkit.Location location,
org.bukkit.util.Vector vector,
float speed,
float spread,
int removedelay)
throws InstanceDisposedException
removedelay will not start remove trigger.onEntityHit(Entity, DamageState, CancelState, DamageType)
is invoked.location - location of spawned arrowvector - direction of spawned arrowspeed - speed of the arrow, recommend 0.6spread - spread of the arrow, recommend 12removedelay - delay in ticks after which spawned arrow will be removedInstanceDisposedExceptionpublic final org.bukkit.entity.Item dropItem(org.bukkit.Location location,
org.bukkit.inventory.ItemStack itemstack,
int removedelay)
throws InstanceDisposedException
removedelay will not start remove trigger.location - location of the dropitemstack - itemstack of the dropremovedelay - delay in ticks after which spawned item will be removedInstanceDisposedExceptionpublic final org.bukkit.entity.Item dropItemNaturally(org.bukkit.Location location,
org.bukkit.inventory.ItemStack itemstack,
int removedelay)
throws InstanceDisposedException
removedelay will not start remove trigger.location - location of the dropitemstack - itemstack of the dropremovedelay - delay in ticks after which spawned item will be removedInstanceDisposedExceptionpublic final org.bukkit.block.Block[] createBlockExplosion(org.bukkit.Location loc,
float power)
throws InstanceDisposedException
getPlayerTeam(Player).CTFBattleClass#onBlockExplosionCreated(int, Block[], CancelState)
will only be called when explosion is created using this method.location - location of explosionpower - strength of explosionCTFBattleClass#onBlockExplosionCreated(int, Block[], CancelState)
provided ID will be the same as returned by this method if
explosion registered was caused by call of this method.InstanceDisposedExceptionpublic final TickTimer registerNewRepeatingTask(java.lang.Runnable runnable, int delay) throws InstanceDisposedException
runnable - repeating task to be rundelay - delay between task invocations, must be more than 0TickTimer object to control this timer.InstanceDisposedExceptionpublic final TickTimer registerNewDelayedTask(java.lang.Runnable runnable, int delay) throws InstanceDisposedException
runnable - task to be rundelay - delay after which task will be runTickTimer object to control this delayed task.InstanceDisposedExceptionpublic final TickTimer[] getRegisteredTimers() throws InstanceDisposedException
CTFBattleClass instance has registered.InstanceDisposedException@Deprecated
public final void registerBukkitHandler()
throws java.lang.UnsupportedOperationException
getPlayer()
is involved in the action! It is recommended to use
EventPriority.MONITOR in read-only events (those that are handled
by CTF Game Handler).java.lang.UnsupportedOperationException - if this CTF Battle class implementation does not
implement Bukkit Listener.@Deprecated
public final void unregisterBukkitHandler()
throws java.lang.UnsupportedOperationException
registerBukkitHandler()java.lang.UnsupportedOperationException - if this CTF Battle class implementation does not
implement Bukkit Listener.public final void modifyBlock(org.bukkit.block.Block block,
org.bukkit.Material material,
byte data,
int repairdelay)
throws InstanceDisposedException
repairdelay ticks elapse. To cancel repair specify
negative repairdelay. To revert block to it's initial state call
resetBlock(Block).block - target blockmaterial - new materialdata - new datarepairdelay - delay after which target block will be repairedInstanceDisposedExceptionresetBlock(Block)public final void resetBlock(org.bukkit.block.Block block)
throws InstanceDisposedException
modifyBlock(Block, Material, byte, int) call.
Otherwise this call will have no effect on target block.block - block to resetInstanceDisposedExceptionpublic final org.bukkit.World getGameWorld()
World is acceptable.public final void setDamager(org.bukkit.entity.Player victim)
victim - player to set damagerpublic final org.bukkit.entity.Player getLastDamager()
throws InstanceDisposedException
InstanceDisposedExceptionpublic final org.bukkit.entity.Player getPlayer()
throws InstanceDisposedException
InstanceDisposedExceptionpublic abstract org.bukkit.inventory.ItemStack[] getArmor()
Null values represent no armor for the slot.public abstract org.bukkit.inventory.ItemStack[] getEquipment()
Null values represent no item for the slot.public abstract void onPlayerKill(org.bukkit.entity.Player victim)
victim - killed playerpublic abstract void onDefeat(org.bukkit.entity.Player successor)
successor - player that killed this playerpublic abstract void onEntityHit(org.bukkit.entity.Entity victim,
DamageState damage,
CancelState cancel,
DamageType damagetype)
victim - entity that was hitdamage - damage done to entitycancel - CancelState object that monitors whether event is canceledpublic abstract void onGetHit(org.bukkit.entity.Entity damager,
double damage,
DamageType damagetype)
damager - another entity that hit this playerdamage - final damage that was donepublic abstract void onEntityRightClick(org.bukkit.entity.Entity victim)
victim - entity that was right-clickedpublic abstract void onBlockRightClick(org.bukkit.block.Block block)
block - block that was right-clickedpublic abstract void onBlockLeftClick(org.bukkit.block.Block block)
block - block that was left-clickedpublic abstract void onAirRightClick()
public abstract void onAirLeftClick()
public abstract void onDropItem(org.bukkit.inventory.ItemStack itemstack)
itemstack - itemstack of an item that would be droppedpublic abstract void onProjectileLaunch(org.bukkit.entity.Projectile p,
CancelState cancel)
public abstract void onInitialization()