@@ -1,8 +1,7 @@
import java.util.HashSet;

/**
* PluginListener.java - Extend this and register it to listen to specific
* hooks.
* PluginListener.java - Extend this and register it to listen to specific hooks.
*
* @author Maine
*/
@@ -14,8 +13,7 @@ public class PluginListener {
public enum Priority {

/**
* Highly critical for hooks that absolutely must occur before any
* others. Use carefully.
* Highly critical for hooks that absolutely must occur before any others. Use carefully.
*/
CRITICAL,
/**
@@ -61,8 +59,7 @@ public boolean onTeleport(Player player, Location from, Location to) {
}

/**
* Called during the early login process to check whether or not to kick the
* player
* Called during the early login process to check whether or not to kick the player
*
* @param user
* @return kick reason. null if you don't want to kick the player.
@@ -88,8 +85,7 @@ public void onDisconnect(Player player) {
}

/**
* Called when a player talks. If you return true the message won't be sent
* out.
* Called when a player talks. If you return true the message won't be sent out.
*
* @param player
* @param message
@@ -102,8 +98,7 @@ public boolean onChat(Player player, String message) {
}

/**
* Called when a player talks. If you return true the message won't be sent
* out.
* Called when a player talks. If you return true the message won't be sent out.
*
* @param player
* @param sbMessage
@@ -116,8 +111,7 @@ public boolean onChat(Player player, StringBuilder sbMessage) {
}

/**
* Called before the command is parsed. Return true if you don't want the
* command to be parsed.
* Called before the command is parsed. Return true if you don't want the command to be parsed.
*
* @param player
* @param split
@@ -128,8 +122,7 @@ public boolean onCommand(Player player, 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.
* Called before the console command is parsed. Return true if you don't want the server command to be parsed by the server.
*
* @param split
* @return false if you want the command to be parsed.
@@ -178,18 +171,15 @@ public void onKick(Player mod, Player player, String reason) {
}

/**
* 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)
* 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)
*
* @param player
* @param blockPlaced
* @param blockClicked
* @param itemInHand
* @return false if you want the action to go through
*
* @deprecated use {@link #onBlockRightClick(Player, Block, Item)} to get
* the information
* @deprecated use {@link #onBlockRightClick(Player, Block, Item)} to get the information
* @see #onBlockRightClick(Player, Block, Item)
* @see #onBlockPlace(Player, Block, Block, Item)
* @see #onItemUse(Player, Block, Block, Item)
@@ -200,8 +190,7 @@ public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicke
}

/**
* Called when a person left clicks a block. Block status: 0 = Started
* Digging, 2 = Stopped digging.
* Called when a person left clicks a block. Block status: 0 = Started Digging, 2 = Stopped digging.
*
* @param player
* @param block
@@ -223,8 +212,7 @@ public boolean onBlockBreak(Player player, Block block) {
}

/**
* Called when a player swings their arm, aka left clicks (even if no block
* is in front of them)
* Called when a player swings their arm, aka left clicks (even if no block is in front of them)
*
* @param player
* player swinging
@@ -239,10 +227,8 @@ public void onArmSwing(Player player) {
* player who dropped the item
* @param item
* item that was dropped
* @deprecated Use onItemDrop(Player, ItemEntity) instead. You can still get
* the Item via ItemEntity.getItem()
* @return true if you don't want the dropped item to be spawned in the
* world
* @deprecated Use onItemDrop(Player, ItemEntity) instead. You can still get the Item via ItemEntity.getItem()
* @return true if you don't want the dropped item to be spawned in the world
*/
@Deprecated
public boolean onItemDrop(Player player, Item item) {
@@ -256,8 +242,7 @@ public boolean onItemDrop(Player player, Item item) {
* player who dropped the item
* @param item
* item that was dropped
* @return true if you don't want the dropped item to be spawned in the
* world
* @return true if you don't want the dropped item to be spawned in the world
*/
public boolean onItemDrop(Player player, ItemEntity item) {
return onItemDrop(player, item.getItem());
@@ -270,8 +255,7 @@ public boolean onItemDrop(Player player, ItemEntity item) {
* player who picked up the item
* @param item
* item that was picked up
* @deprecated Use onItemPickUp(Player, ItemEntity) instead. You can still
* get the Item via ItemEntity.getItem()
* @deprecated Use onItemPickUp(Player, ItemEntity) instead. You can still get the Item via ItemEntity.getItem()
* @return true if you want to leave the item where it was
*/
@Deprecated
@@ -293,10 +277,7 @@ public boolean onItemPickUp(Player player, ItemEntity item) {
}

/**
* 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). 4 = fire
* destroying a block. 5 = lightning
* 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). 4 = fire destroying a block. 5 = lightning
*
* @param block
* block that the fire wants to spawn in.
@@ -309,16 +290,12 @@ public boolean onIgnite(Block block, Player player) {
}

/**
* Called when a dynamite block or a creeper is triggerd. block status
* depends on explosive compound: 1 = dynamite. 2 = creeper. 3 = ghast
* fireball.
* Called when a dynamite block or a creeper is triggerd. block status depends on explosive compound: 1 = dynamite. 2 = creeper. 3 = ghast fireball.
*
* @param block
* Dynamite block/creeper/ghast fireball location block.
*
* @deprecated Use onExplode(Block,OEntity,HashSet) instead. You can still
* use block.getStatus to get what exploded, as well as using
* OEntity.
* @deprecated Use onExplode(Block,OEntity,HashSet) instead. You can still use block.getStatus to get what exploded, as well as using OEntity.
* @return true if you dont the block to explode.
*/
@Deprecated
@@ -327,18 +304,15 @@ public boolean onExplode(Block block) {
}

/**
* Called when a tnt block, creeper, or ghast fireball explodes. Block
* status depends on the entity exploding: 1 = tnt. 2 = creeper. 3 = ghast
* fireball.
* Called when a tnt block, creeper, or ghast fireball explodes. Block status depends on the entity exploding: 1 = tnt. 2 = creeper. 3 = ghast fireball.
*
* You can also get the explosion type from OEntity using instanceof.
*
* @param block
* The block location where the explosion occurred.
*
* @param entity
* The entity that caused the explosion(tnt, creeper, or
* fireball)
* The entity that caused the explosion(tnt, creeper, or fireball)
*
* @param blocksaffected
* The blocks affected by the explosion in a hashset.
@@ -350,8 +324,7 @@ public boolean onExplode(Block block, OEntity entity, HashSet blocksaffected) {
}

/**
* Called when fluid wants to flow to a certain block. (10 & 11 for lava and
* 8 & 9 for water)
* Called when fluid wants to flow to a certain block. (10 & 11 for lava and 8 & 9 for water)
*
* @param blockFrom
* the block where the fluid came from. (blocktype = fluid type)
@@ -375,8 +348,7 @@ public boolean onMobSpawn(Mob mob) {
}

/**
* Called when a living object is attacked. tip: Use isMob() and isPlayer()
* and getPlayer().
* Called when a living object is attacked. tip: Use isMob() and isPlayer() and getPlayer().
*
* @param type
* type of damage dealt.
@@ -409,15 +381,11 @@ public boolean onHealthChange(Player player, int oldValue, int newValue) {
}

/**
* Called whenever a redstone source (wire, switch, torch) changes its
* current.
* 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.
* 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.
* For other blocks which provide a source of redstone current, the current value will be 1 or 0 for on and off respectively.
*
* @param block
* @param oldLevel
@@ -450,18 +418,14 @@ public boolean onPistonExtend(Block block, boolean isSticky) {
* the piston's block
* @param isSticky
* Whether the piston is sticky
* @return false if you want the piston to attempt retracting the attached
* block.
* @return false if you want the piston to attempt retracting the attached block.
*/
public boolean onPistonRetract(Block block, boolean isSticky) {
return false;
}

/**
* 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.
* 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.
*
* @param block
* Block which requires special physics
@@ -581,9 +545,7 @@ public boolean onBlockPlace(Player player, Block blockPlaced, Block blockClicked
}

/**
* 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)
* 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)
*
* @deprecated Use {@link #onBlockRightClick(Player, Block, Item) } instead.
* @param player
@@ -595,9 +557,7 @@ public void onBlockRightClicked(Player player, Block blockClicked, Item itemInHa
}

/**
* 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)
* 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)
*
* @param player
* @param blockClicked
@@ -610,13 +570,10 @@ public boolean onBlockRightClick(Player player, Block blockClicked, Item itemInH
}

/**
* 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.
* 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.
*
* @param currentState
* the current tristate, once it's set to a non DEFAULT_ACTION it
* is final.
* the current tristate, once it's set to a non DEFAULT_ACTION it is final.
* @param liquidBlockId
* the type of the attacking block
* @param targetBlock
@@ -628,10 +585,7 @@ public PluginLoader.HookResult onLiquidDestroy(PluginLoader.HookResult currentSt
}

/**
* 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
* {@link LivingEntity#getLastDamage()} the defender has.
* 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 {@link LivingEntity#getLastDamage()} the defender has.
*
* @param attacker
* the giver
@@ -646,8 +600,7 @@ public boolean onAttack(LivingEntity attacker, LivingEntity defender, Integer am
}

/**
* Called when a player attempts to open an inventory; whether it's a
* workbench, a chest or their own player inventory
* Called when a player attempts to open an inventory; whether it's a workbench, a chest or their own player inventory
*
* @param player
* user who attempted to open the inventory
@@ -660,8 +613,7 @@ public boolean onOpenInventory(Player player, Inventory inventory) {
}

/**
* Called when a sign is shown to a player, most often when they come into
* range of a sign.
* Called when a sign is shown to a player, most often when they come into range of a sign.
*
* @param player
* Player who this sign is being shown to
@@ -672,8 +624,7 @@ public void onSignShow(Player player, Sign sign) {
}

/**
* Called when a sign is changed by a player (Usually, when they first place
* it)
* Called when a sign is changed by a player (Usually, when they first place it)
*
* @param player
* Player who changed the sign
@@ -705,8 +656,7 @@ public boolean onLeafDecay(Block block) {
* Wolf being tamed
* @param shouldSucceed
* True if the taming should have succeeded normally
* @return Whether the taming should succeed (ALLOW_ACTION), fail
* (PREVENT_ACTION), or do random as always (DEFAULT_ACTION)
* @return Whether the taming should succeed (ALLOW_ACTION), fail (PREVENT_ACTION), or do random as always (DEFAULT_ACTION)
*/
public PluginLoader.HookResult onTame(Player player, Mob wolf, boolean shouldSucceed) {
return PluginLoader.HookResult.DEFAULT_ACTION;
@@ -813,9 +763,7 @@ public boolean onTimeChange(World world, long newValue) {
* Player who wants to use the command.
* @param command
* The command itself.
* @return Whether the player is allowed (ALLOW_ACTION), prohibited
* (PREVENT_ACTION), or when another plugin should decide
* (DEFAULT_ACTION)
* @return Whether the player is allowed (ALLOW_ACTION), prohibited (PREVENT_ACTION), or when another plugin should decide (DEFAULT_ACTION)
*/
public PluginLoader.HookResult canPlayerUseCommand(Player player, String command) {
return PluginLoader.HookResult.DEFAULT_ACTION;
@@ -838,10 +786,7 @@ public void onChunkLoaded(Chunk chunk) {
}

/**
* Called when a chunk is generated. Tips: Return a byte[32768] if you want
* to generate a new chunk. The index of the block is: (x * 16 + z) * 128 +
* y where 0<=x<16, 0<=z<16 and 0<=y<128 Use world.getRandomSeed() or (x *
* 0x4f9939f508L + z * 0x1ef1565bd5L) as seed for your Random.
* Called when a chunk is generated. Tips: Return a byte[32768] if you want to generate a new chunk. The index of the block is: (x * 16 + z) * 128 + y where 0<=x<16, 0<=z<16 and 0<=y<128 Use world.getRandomSeed() or (x * 0x4f9939f508L + z * 0x1ef1565bd5L) as seed for your Random.
*
* @param x
* @param z
@@ -853,12 +798,10 @@ public byte[] onChunkCreate(int x, int z, World world) {
}

/**
* Called when a spawnpoint is generated. If you don't implement this when
* overriding onChunkCreate, this could cause an OutOfMemoryError.
* Called when a spawnpoint is generated. If you don't implement this when overriding onChunkCreate, this could cause an OutOfMemoryError.
*
* @param world
* @return The location of the spawnpoint. The values are rounded to
* integers, elevation and pitch are ignored.
* @return The location of the spawnpoint. The values are rounded to integers, elevation and pitch are ignored.
*/
public Location onSpawnpointCreate(World world) {
return null;
@@ -947,8 +890,7 @@ public boolean onEndermanDrop(Enderman entity, Block block) {
* The milking player
* @param cow
* The milked cow
* @deprecated Use {@link #onEntityRightClick(Player, Entity, Item) }
* instead.
* @deprecated Use {@link #onEntityRightClick(Player, Entity, Item) } instead.
* @return true if to prevent the player from milking the cow
*/
@Deprecated
@@ -1088,20 +1030,12 @@ public Object onPlayerDisconnect(Player player, HookParametersDisconnect hookPar
}

/**
* Called when someone presses right click aimed at an entity. You can
* intercept this to add your own right click actions to different item
* types (see itemInHand) Some interactions update the player's item in hand
* (for example shearing a sheep), but some do not (like using an item on a
* player). If you want to update the item stack anyways, you should return
* ALLOW_ACTION.
* Called when someone presses right click aimed at an entity. You can intercept this to add your own right click actions to different item types (see itemInHand) Some interactions update the player's item in hand (for example shearing a sheep), but some do not (like using an item on a player). If you want to update the item stack anyways, you should return ALLOW_ACTION.
*
* @param player
* @param entityClicked
* @param itemInHand
* @return ALLOW_ACTION to allow interaction and always update the item
* stack the player is holding, DEFAULT_ACTION to allow interaction
* and update the item stack if needed by default. PREVENT_ACTION to
* prevent the interaction when right clicking completely.
* @return ALLOW_ACTION to allow interaction and always update the item stack the player is holding, DEFAULT_ACTION to allow interaction and update the item stack if needed by default. PREVENT_ACTION to prevent the interaction when right clicking completely.
*/

public PluginLoader.HookResult onEntityRightClick(Player player, BaseEntity entityClicked, Item itemInHand) {
@@ -1112,8 +1046,7 @@ public PluginLoader.HookResult onEntityRightClick(Player player, BaseEntity enti
}

/**
* Called when a Mob Entity targets a player for following and/or attacking.
* You can interrupt this by returning true.
* Called when a Mob Entity targets a player for following and/or attacking. You can interrupt this by returning true.
*
* @param player
* @param mob