Refactored event calling so its front loading avoiding the lookup for each event call.

This now uses an annoymous class implementing IExecutor that facilitates direct event method handler calling

Changed commands from being executed exclusively by a player to by a CommandSender to facilitate external command callers such as rcon

Fixed CustomEventListener

Merged in additional events

Added getFullName to PluginDescriptionFile which returns the combination of Name and Version

There's also a few bits of reformatting as it seems someones been editing with either tabs or dos eol :(

By: stevenh <steven.hartland@multiplay.co.uk>
This commit is contained in:
Bukkit/Spigot
2011-01-29 16:23:56 +00:00
parent 9755073204
commit df05c36540
18 changed files with 534 additions and 361 deletions

View File

@@ -1,5 +1,19 @@
package org.bukkit.event;
public interface CustomEventListener {
public void onCustomEvent(Event event);
}
import org.bukkit.event.Listener;
/**
* Handles all custom events
*/
public class CustomEventListener implements Listener {
public CustomEventListener() {
}
/**
* Called when a player joins a server
*
* @param event Relevant event details
*/
public void onCustomEvent(Event event) {
}
}

View File

@@ -38,8 +38,7 @@ public abstract class Event {
* @return Name of this event
*/
public final String getEventName() {
if(type!=Type.CUSTOM_EVENT) return type.toString();
else return name;
return ( type != Type.CUSTOM_EVENT) ? type.toString() : name;
}
/**
@@ -275,6 +274,13 @@ public abstract class Event {
*/
BLOCK_INTERACT (Category.BLOCK),
/**
* Called when a block is destroyed from being burnt by fire
*
* @see org.bukkit.event.block.BlockBurnEvent
*/
BLOCK_BURN (Category.BLOCK),
/**
* Called when leaves are decaying naturally
*
@@ -356,6 +362,13 @@ public abstract class Event {
*/
PLUGIN_DISABLE (Category.SERVER),
/**
* Called when a plugin is disabled
*
* @see org.bukkit.event.server.PluginEvent
*/
SERVER_COMMAND (Category.SERVER),
/**
* WORLD EVENTS
*/
@@ -417,7 +430,7 @@ public abstract class Event {
* @see org.bukkit.event.entity.EntityDamageByEntityEvent
*/
ENTITY_DAMAGEDBY_ENTITY (Category.LIVING_ENTITY),
/**
* Called when a LivingEntity is damaged by a projectile Entity
*
@@ -445,7 +458,7 @@ public abstract class Event {
* @todo: add javadoc see comment
*/
ENTITY_COMBUST (Category.LIVING_ENTITY),
/**
* Called when an entity explodes, either TNT, Creeper, or Ghast Fireball
*
@@ -453,6 +466,13 @@ public abstract class Event {
*/
ENTITY_EXPLODE (Category.LIVING_ENTITY),
/**
* Called when an entity targets another entity
*
* @see org.bukkit.event.entity.EntityTargetEvent
*/
ENTITY_TARGET (Category.LIVING_ENTITY),
/**
* VEHICLE EVENTS
*/

View File

@@ -1,97 +1,104 @@
package org.bukkit.event.block;
import org.bukkit.event.Listener;
/**
* Handles all events thrown in relation to Blocks
*
* @author durron597
*/
public class BlockListener implements Listener {
/**
* Default Constructor
*/
public BlockListener() {
}
/**
* Called when a block is damaged (or broken)
*
* @param event Relevant event details
*/
public void onBlockDamage(BlockDamageEvent event) {
}
/**
* Called when we try to place a block, to see if we can build it
*/
public void onBlockCanBuild(BlockCanBuildEvent event) {
}
/**
* Called when a block flows (water/lava)
*
* @param event Relevant event details
*/
public void onBlockFlow(BlockFromToEvent event) {
}
/**
* Called when a block gets ignited
*
* @param event Relevant event details
*/
public void onBlockIgnite(BlockIgniteEvent event) {
}
/**
* Called when block physics occurs
*
* @param event Relevant event details
*/
public void onBlockPhysics(BlockPhysicsEvent event) {
}
/**
* Called when a player places a block
*
* @param event Relevant event details
*/
public void onBlockPlace(BlockPlaceEvent event) {
}
/**
* Called when a block is interacted with
*
* @param event Relevant event details
*/
public void onBlockInteract(BlockInteractEvent event) {
}
/**
* Called when a player right clicks a block
*
* @param event Relevant event details
*/
public void onBlockRightClick(BlockRightClickEvent event) {
}
/**
* Called when redstone changes
* From: the source of the redstone change
* To: The redstone dust that changed
*
* @param event Relevant event details
*/
public void onBlockRedstoneChange(BlockFromToEvent event) {
}
/**
* Called when leaves are decaying naturally
*
* @param event Relevant event details
*/
public void onLeavesDecay(LeavesDecayEvent event) {
}
}
package org.bukkit.event.block;
import org.bukkit.event.Listener;
/**
* Handles all events thrown in relation to Blocks
*
* @author durron597
*/
public class BlockListener implements Listener {
/**
* Default Constructor
*/
public BlockListener() {
}
/**
* Called when a block is damaged (or broken)
*
* @param event Relevant event details
*/
public void onBlockDamage(BlockDamageEvent event) {
}
/**
* Called when we try to place a block, to see if we can build it
*/
public void onBlockCanBuild(BlockCanBuildEvent event) {
}
/**
* Called when a block flows (water/lava)
*
* @param event Relevant event details
*/
public void onBlockFlow(BlockFromToEvent event) {
}
/**
* Called when a block gets ignited
*
* @param event Relevant event details
*/
public void onBlockIgnite(BlockIgniteEvent event) {
}
/**
* Called when block physics occurs
*
* @param event Relevant event details
*/
public void onBlockPhysics(BlockPhysicsEvent event) {
}
/**
* Called when a player places a block
*
* @param event Relevant event details
*/
public void onBlockPlace(BlockPlaceEvent event) {
}
/**
* Called when a block is interacted with
*
* @param event Relevant event details
*/
public void onBlockInteract(BlockInteractEvent event) {
}
/**
* Called when a player right clicks a block
*
* @param event Relevant event details
*/
public void onBlockRightClick(BlockRightClickEvent event) {
}
/**
* Called when redstone changes
* From: the source of the redstone change
* To: The redstone dust that changed
*
* @param event Relevant event details
*/
public void onBlockRedstoneChange(BlockFromToEvent event) {
}
/**
* Called when leaves are decaying naturally
*
* @param event Relevant event details
*/
public void onLeavesDecay(LeavesDecayEvent event) {
}
/**
* Called when a block is destroyed from burning
*
* @param event Relevant event details
*/
public void onBlockBurn(BlockBurnEvent event) {
}
}

View File

@@ -14,10 +14,10 @@ public class EntityListener implements Listener {
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
}
public void onEntityCombust(EntityCombustEvent event) {
}
@@ -26,4 +26,10 @@ public class EntityListener implements Listener {
public void onEntityExplode(EntityExplodeEvent event) {
}
public void onEntityDeath(EntityDeathEvent event) {
}
public void onEntityTarget(EntityTargetEvent event) {
}
}

View File

@@ -22,4 +22,12 @@ public class ServerListener implements Listener {
*/
public void onPluginDisabled(PluginEvent event) {
}
/**
* Called when a server command is used
*
* @param event Relevant event details
*/
public void onServerCommand(PluginEvent event) {
}
}