Class PluginListener

java.lang.Object
  extended by PluginListener

public class PluginListener
extends java.lang.Object

PluginListener.java - Extend this and register it to listen to specific hooks.


Nested Class Summary
Modifier and Type Class and Description
static class PluginListener.Priority
          Priority - Used for priority for plugin listeners
 
Constructor Summary
Constructor and Description
PluginListener()
           
 
Method Summary
Modifier and Type Method and Description
 void onArmSwing(Player player)
          Called when a player swings their arm, aka left clicks (even if no block is in front of them)
 boolean onAttack(LivingEntity attacker, LivingEntity defender, java.lang.Integer amount)
          Called when an entity (attacker) tries to hurt a player (defender).
 void onBan(Player mod, Player player, java.lang.String reason)
          Called when a player is banned
 boolean onBlockBreak(Player player, Block block)
          Called when a person actually breaks the block.
 boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand)
          Deprecated. use onBlockRightClick to get the information
 boolean onBlockDestroy(Player player, Block block)
          Called when a person left clicks a block.
 boolean onBlockPhysics(Block block, boolean placed)
          Called when the game is checking the physics for a certain block.
 boolean onBlockPlace(Player player, Block blockPlaced, Block blockClicked, Item itemInHand)
          Called when someone places a block.
 void onBlockRightClicked(Player player, Block blockClicked, Item item)
          Called when someone presses right click aimed at a block.
 boolean onChat(Player player, java.lang.String message)
          Called when a player talks.
 boolean onCommand(Player player, java.lang.String[] split)
          Called before the command is parsed.
 boolean onConsoleCommand(java.lang.String[] split)
          Called before the console command is parsed.
 boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount)
          Called when a living object is attacked.
 void onDisconnect(Player player)
          Called on player disconnect
 boolean onExplode(Block block)
          Called when a dynamite block or a creeper is triggerd.
 boolean onFlow(Block blockFrom, Block blockTo)
          Called when fluid wants to flow to a certain block.
 boolean onHealthChange(Player player, int oldValue, int newValue)
          Called when a players health changes.
 boolean onIgnite(Block block, Player player)
          Called when either a lava block or a lighter tryes to light something on fire.
 boolean onInventoryCursorSwap(Player player, Inventory inventory, java.lang.Integer slot, Item oldItemInSlot, Item newItemInSlot)
          Called when a slot's contents are swapped with the contents of the cursor.
 boolean onInventoryPlaceItem(Player player, Inventory inventory, Item placedItem, java.lang.Integer slot)
          Called when the player places an inventory item, or adds amount to an existing inventory slot.
 boolean onInventoryTakeItem(Player player, Inventory inventory, Item takenItem, java.lang.Integer slot)
          Called when the player takes an inventory item, whether they selected half or the whole slot.
 void onIpBan(Player mod, Player player, java.lang.String reason)
          Called when a player is IP banned
 boolean onItemDrop(Player player, Item item)
          Called when a player drops an item.
 boolean onItemPickUp(Player player, Item item)
          Called when a player picks up an item.
 boolean onItemUse(Player player, Block blockPlaced, Block blockClicked, Item item)
          Called when a player uses an item (rightclick with item in hand)
 void onKick(Player mod, Player player, java.lang.String reason)
          Called when a player is kicked
 boolean onLeafDecay(Block block)
          Called when a leaf block is about to decay.
 PluginLoader.HookResult onLiquidDestroy(PluginLoader.HookResult currentState, int liquidBlockId, Block targetBlock)
          Called when water or lava tries to populate a block, you can prevent crushing of torches, railways, flowers etc.
 void onLogin(Player player)
          Called during the later login process
 java.lang.String onLoginChecks(java.lang.String user)
          Called during the early login process to check whether or not to kick the player
 boolean onMobSpawn(Mob mob)
           
 boolean onOpenInventory(Player player, Inventory inventory)
          Called when a player attempts to open an inventory; whether it's a workbench, a chest or their own player inventory
 void onPlayerMove(Player player, Location from, Location to)
          Called when a player moves from one block to another
 int onRedstoneChange(Block block, int oldLevel, int newLevel)
          Called whenever a redstone source (wire, switch, torch) changes its current.
 boolean onSignChange(Player player, Sign sign)
          Called when a sign is changed by a player (Usually, when they first place it)
 void onSignShow(Player player, Sign sign)
          Called when a sign is shown to a player, most often when they come into range of a sign.
 boolean onTeleport(Player player, Location from, Location to)
          Called when a player teleports from one location to another
 java.lang.Boolean onVehicleCollision(BaseVehicle vehicle, BaseEntity collisioner)
          Called when a collision occurs with a vehicle and an entity.
 void onVehicleCreate(BaseVehicle vehicle)
          Called when you place a vehicle.
 boolean onVehicleDamage(BaseVehicle vehicle, BaseEntity attacker, int damage)
          Called when vehicle receives damage
 void onVehicleDestroyed(BaseVehicle vehicle)
          Called when a vehicle is destroyed
 void onVehicleEnter(BaseVehicle vehicle, HumanEntity player)
          Called when a player enter or leaves a vehicle
 void onVehiclePositionChange(BaseVehicle vehicle, int x, int y, int z)
          Called when a vehicle changes block
 void onVehicleUpdate(BaseVehicle vehicle)
          Called when a vehicle changes speed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginListener

public PluginListener()
Method Detail

onPlayerMove

public void onPlayerMove(Player player,
                         Location from,
                         Location to)
Called when a player moves from one block to another

Parameters:
player - player moving
from - previous block location
to - current block location

onTeleport

public boolean onTeleport(Player player,
                          Location from,
                          Location to)
Called when a player teleports from one location to another

Parameters:
player - player moving
from - previous block location
to - current block location
Returns:
false if you want the player to teleport.

onLoginChecks

public java.lang.String onLoginChecks(java.lang.String user)
Called during the early login process to check whether or not to kick the player

Parameters:
user -
Returns:
kick reason. null if you don't want to kick the player.

onLogin

public void onLogin(Player player)
Called during the later login process

Parameters:
player -

onDisconnect

public void onDisconnect(Player player)
Called on player disconnect

Parameters:
player -

onChat

public boolean onChat(Player player,
                      java.lang.String message)
Called when a player talks. If you return true the message won't be sent out.

Parameters:
player -
message -
Returns:
false if you want the message to be sent.

onCommand

public boolean onCommand(Player player,
                         java.lang.String[] split)
Called before the command is parsed. Return true if you don't want the command to be parsed.

Parameters:
player -
split -
Returns:
false if you want the command to be parsed.

onConsoleCommand

public boolean onConsoleCommand(java.lang.String[] split)
Called before the console command is parsed. Return true if you don't want the server command to be parsed by the server.

Parameters:
split -
Returns:
false if you want the command to be parsed.

onBan

public void onBan(Player mod,
                  Player player,
                  java.lang.String reason)
Called when a player is banned

Parameters:
mod - moderator that's banning
player - player being banned
reason - reason for ban

onIpBan

public void onIpBan(Player mod,
                    Player player,
                    java.lang.String reason)
Called when a player is IP banned

Parameters:
mod - moderator that's banning
player - player being banning
reason - for IP ban

onKick

public void onKick(Player mod,
                   Player player,
                   java.lang.String reason)
Called when a player is kicked

Parameters:
mod - moderator that's kicking
player - player being kicked
reason - reason for kick

onBlockCreate

@Deprecated
public boolean onBlockCreate(Player player,
                                        Block blockPlaced,
                                        Block blockClicked,
                                        int itemInHand)
Deprecated. use onBlockRightClick to get the information

Called when someone presses right click aimed at a block. You can intercept this to add your own right click actions to different item types (see itemInHand)

Parameters:
player -
blockPlaced -
blockClicked -
itemInHand -
Returns:
false if you want the action to go through
See Also:
onBlockRightClicked(Player, Block, Item), onBlockPlace(Player, Block, Block, Item), onItemUse(Player, Block, Block, Item)

onBlockDestroy

public boolean onBlockDestroy(Player player,
                              Block block)
Called when a person left clicks a block.

Parameters:
player -
block -
Returns:

onBlockBreak

public boolean onBlockBreak(Player player,
                            Block block)
Called when a person actually breaks the block.

Parameters:
player -
block -
Returns:

onArmSwing

public void onArmSwing(Player player)
Called when a player swings their arm, aka left clicks (even if no block is in front of them)

Parameters:
player - player swinging

onItemDrop

public boolean onItemDrop(Player player,
                          Item item)
Called when a player drops an item.

Parameters:
player - player who dropped the item
item - item that was dropped
Returns:
true if you don't want the dropped item to be spawned in the world

onItemPickUp

public boolean onItemPickUp(Player player,
                            Item item)
Called when a player picks up an item.

Parameters:
player - player who picked up the item
item - item that was picked up
Returns:
true if you want to leave the item where it was

onIgnite

public boolean onIgnite(Block block,
                        Player player)
Called when either a lava block or a lighter tryes to light something on fire. block status depends on the light source: 1 = lava. 2 = lighter (flint + steel). 3 = spread (dynamic spreading of fire).

Parameters:
block - block that the fire wants to spawn in.
player - player
Returns:
true if you dont want the fire to ignite.

onExplode

public boolean onExplode(Block block)
Called when a dynamite block or a creeper is triggerd. block status depends on explosive compound: 1 = dynamite. 2 = creeper.

Parameters:
block - dynamite block/creeper location block.
Returns:
true if you dont the block to explode.

onFlow

public boolean onFlow(Block blockFrom,
                      Block blockTo)
Called when fluid wants to flow to a certain block. (10 & 11 for lava and 8 & 9 for water)

Parameters:
blockFrom - the block where the fluid came from. (blocktype = fluid type)
blockTo - the block where fluid wants to flow to.
Returns:
true if you dont want the substance to flow.

onMobSpawn

public boolean onMobSpawn(Mob mob)
Parameters:
mob - Mob attempting to spawn.
Returns:
true if you dont want mob to spawn.

onDamage

public boolean onDamage(PluginLoader.DamageType type,
                        BaseEntity attacker,
                        BaseEntity defender,
                        int amount)
Called when a living object is attacked. tip: Use isMob() and isPlayer() and getPlayer().

Parameters:
type - type of damage dealt.
attacker - object that is attacking.
defender - object that is defending.
amount - amount of damage dealt.
Returns:

onHealthChange

public boolean onHealthChange(Player player,
                              int oldValue,
                              int newValue)
Called when a players health changes.

Parameters:
player - the player which health is changed.
oldValue - old lives value
newValue - new lives value
Returns:
return true to stop the change.

onRedstoneChange

public int onRedstoneChange(Block block,
                            int oldLevel,
                            int newLevel)
Called whenever a redstone source (wire, switch, torch) changes its current. Standard values for wires are 0 for no current, and 14 for a strong current. Default behaviour for redstone wire is to lower the current by one every block. For other blocks which provide a source of redstone current, the current value will be 1 or 0 for on and off respectively.

Parameters:
block -
oldLevel - the old current
newLevel - the new current
Returns:
the new current to use (newLevel to leave as-is)

onBlockPhysics

public boolean onBlockPhysics(Block block,
                              boolean placed)
Called when the game is checking the physics for a certain block. This method is called frequently whenever a nearby block is changed, or if the block has just been placed. Currently the only supported blocks are sand, gravel and portals.

Parameters:
block - Block which requires special physics
placed - True if block was just placed
Returns:
true if you do want to stop the default physics for this block

onVehicleCreate

public void onVehicleCreate(BaseVehicle vehicle)
Called when you place a vehicle.

Parameters:
vehicle - the vehicle placed

onVehicleDamage

public boolean onVehicleDamage(BaseVehicle vehicle,
                               BaseEntity attacker,
                               int damage)
Called when vehicle receives damage

Parameters:
vehicle -
attacker - entity that dealt the damage
damage -
Returns:
false to set damage

onVehicleUpdate

public void onVehicleUpdate(BaseVehicle vehicle)
Called when a vehicle changes speed

Parameters:
vehicle - the vehicle

onVehicleCollision

public java.lang.Boolean onVehicleCollision(BaseVehicle vehicle,
                                            BaseEntity collisioner)
Called when a collision occurs with a vehicle and an entity.

Parameters:
vehicle - the vehicle
collisioner -
Returns:
false to ignore damage

onVehicleDestroyed

public void onVehicleDestroyed(BaseVehicle vehicle)
Called when a vehicle is destroyed

Parameters:
vehicle - the vehicle

onVehicleEnter

public void onVehicleEnter(BaseVehicle vehicle,
                           HumanEntity player)
Called when a player enter or leaves a vehicle

Parameters:
vehicle - the vehicle
player - the player

onVehiclePositionChange

public void onVehiclePositionChange(BaseVehicle vehicle,
                                    int x,
                                    int y,
                                    int z)
Called when a vehicle changes block

Parameters:
vehicle - the vehicle
x - coordinate x
y - coordinate y
z - coordinate z

onItemUse

public boolean onItemUse(Player player,
                         Block blockPlaced,
                         Block blockClicked,
                         Item item)
Called when a player uses an item (rightclick with item in hand)

Parameters:
player - the player
blockPlaced - where a block would end up when the item was a bucket
blockClicked -
item - the item being used (in hand)
Returns:
true to prevent using the item.

onBlockPlace

public boolean onBlockPlace(Player player,
                            Block blockPlaced,
                            Block blockClicked,
                            Item itemInHand)
Called when someone places a block. Return true to prevent the placement.

Parameters:
player -
blockPlaced -
blockClicked -
itemInHand -
Returns:
true if you want to undo the block placement

onBlockRightClicked

public void onBlockRightClicked(Player player,
                                Block blockClicked,
                                Item item)
Called when someone presses right click aimed at a block. You can intercept this to add your own right click actions to different item types (see itemInHand)

Parameters:
player -
blockClicked -
itemInHand -

onLiquidDestroy

public PluginLoader.HookResult onLiquidDestroy(PluginLoader.HookResult currentState,
                                               int liquidBlockId,
                                               Block targetBlock)
Called when water or lava tries to populate a block, you can prevent crushing of torches, railways, flowers etc. You can alternatively allow to let normally solid blocks be crushed.

Parameters:
currentState - the current tristate, once it's set to a non DEFAULT_ACTION it is final.
liquidBlock - the type of the attacking block
targetBlock - the block to be destroyed
Returns:
final after a non DEFAULT_ACTION

onAttack

public boolean onAttack(LivingEntity attacker,
                        LivingEntity defender,
                        java.lang.Integer amount)
Called when an entity (attacker) tries to hurt a player (defender). Returning 'true' prevents all damage, returning 'false' lets the game handle it. Remember that the damage will be lessened by the amount of LivingEntity.getLastDamage() the defender has.

Parameters:
attacker - the giver
defender - the taker
amount - of damage the entity tries to do
Returns:

onOpenInventory

public boolean onOpenInventory(Player player,
                               Inventory inventory)
Called when a player attempts to open an inventory; whether it's a workbench, a chest or their own player inventory

Parameters:
player - user who attempted to open the inventory
inventory - the inventory that they are attempting to open
Returns:

onSignShow

public void onSignShow(Player player,
                       Sign sign)
Called when a sign is shown to a player, most often when they come into range of a sign.

Parameters:
player - Player who this sign is being shown to
sign - Sign which is being shown to the player

onSignChange

public boolean onSignChange(Player player,
                            Sign sign)
Called when a sign is changed by a player (Usually, when they first place it)

Parameters:
player - Player who changed the sign
sign - Sign which had changed
Returns:
true if you wish to cancel this change

onLeafDecay

public boolean onLeafDecay(Block block)
Called when a leaf block is about to decay.

Parameters:
block - The leaf block about to decay
Returns:
true if you wish to stop the block from decaying

onInventoryPlaceItem

public boolean onInventoryPlaceItem(Player player,
                                    Inventory inventory,
                                    Item placedItem,
                                    java.lang.Integer slot)
Called when the player places an inventory item, or adds amount to an existing inventory slot.

Parameters:
player - Player who placed their inventory item
inventory - The inventory that had an item placed
placedItem - The item (and amount) that was placed.
oldSlot - The slot that the item was placed in.
Returns:
true if you want the placement to be undone; false otherwise

onInventoryTakeItem

public boolean onInventoryTakeItem(Player player,
                                   Inventory inventory,
                                   Item takenItem,
                                   java.lang.Integer slot)
Called when the player takes an inventory item, whether they selected half or the whole slot.

Parameters:
player - Player who took their inventory item
inventory - The inventory that had an item taken
takenItem - The item (and amount) that was taken
oldSlot - The slot that the item was taken from.
Returns:
true if you want the taking to be undone; false otherwise

onInventoryCursorSwap

public boolean onInventoryCursorSwap(Player player,
                                     Inventory inventory,
                                     java.lang.Integer slot,
                                     Item oldItemInSlot,
                                     Item newItemInSlot)
Called when a slot's contents are swapped with the contents of the cursor.

Parameters:
player - Player who swapped their inventory item
inventory - The inventory that had an item swapped
slot - The slot that had items swapped
oldItemInSlot - The old item in the slot, which is now on the cursor
newItemInSlot - The new item in the slot, which was on the cursor
Returns:
true if you want the swap to be undone; false otherwise