diff options
author | stevenh <steven.hartland@multiplay.co.uk> | 2011-01-29 21:17:36 +0000 |
---|---|---|
committer | stevenh <steven.hartland@multiplay.co.uk> | 2011-01-29 21:17:36 +0000 |
commit | 47af4404bf38be0e9e5b4344d6f54505e01a55dd (patch) | |
tree | ff94cda134552121e66537b8e759ba2bb6be6f79 /src | |
parent | a984e73ac1daeedd9fc200d181dc1904fd12d96f (diff) | |
download | bukkit-47af4404bf38be0e9e5b4344d6f54505e01a55dd.tar bukkit-47af4404bf38be0e9e5b4344d6f54505e01a55dd.tar.gz bukkit-47af4404bf38be0e9e5b4344d6f54505e01a55dd.tar.lz bukkit-47af4404bf38be0e9e5b4344d6f54505e01a55dd.tar.xz bukkit-47af4404bf38be0e9e5b4344d6f54505e01a55dd.zip |
Renamed IExecutor -> CommandExecutor and fixed SERVER_COMMAND doc
Diffstat (limited to 'src')
10 files changed, 65 insertions, 70 deletions
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java index 13ed3548..64a4e988 100644 --- a/src/main/java/org/bukkit/command/CommandSender.java +++ b/src/main/java/org/bukkit/command/CommandSender.java @@ -10,10 +10,16 @@ public interface CommandSender { public void sendMessage(String message); /** - * Checks if this player is currently op + * Checks if this sender is currently op * * @return true if they are */ public boolean isOp(); + /** + * Checks if this sender is a player + * + * @return true if they are + */ + public boolean isPlayer(); }
\ No newline at end of file diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java index 73198f8f..e047009e 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -196,12 +196,12 @@ public final class SimpleCommandMap implements CommandMap { } @Override - public boolean execute(Player player, String currentAlias, String[] args) { - if (player.isOp()) { + public boolean execute(CommandSender sender, String currentAlias, String[] args) { + if (sender.isOp()) { server.reload(); - player.sendMessage(ChatColor.GREEN + "Reload complete."); + sender.sendMessage(ChatColor.GREEN + "Reload complete."); } else { - player.sendMessage(ChatColor.RED + "You do not have sufficient access" + " to reload this server."); + sender.sendMessage(ChatColor.RED + "You do not have sufficient access" + " to reload this server."); } return true; } diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index df7e6ad5..3bb78acd 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -363,7 +363,7 @@ public abstract class Event { PLUGIN_DISABLE (Category.SERVER), /** - * Called when a plugin is disabled + * Called when a server command is called * * @see org.bukkit.event.server.PluginEvent */ diff --git a/src/main/java/org/bukkit/event/server/ServerListener.java b/src/main/java/org/bukkit/event/server/ServerListener.java index 7853d367..0ee604e2 100644 --- a/src/main/java/org/bukkit/event/server/ServerListener.java +++ b/src/main/java/org/bukkit/event/server/ServerListener.java @@ -28,6 +28,6 @@ public class ServerListener implements Listener { * * @param event Relevant event details */ - public void onServerCommand(PluginEvent event) { + public void onServerCommand(ServerCommandEvent event) { } } diff --git a/src/main/java/org/bukkit/plugin/IExecutor.java b/src/main/java/org/bukkit/plugin/IExecutor.java deleted file mode 100644 index e16c3fa7..00000000 --- a/src/main/java/org/bukkit/plugin/IExecutor.java +++ /dev/null @@ -1,12 +0,0 @@ - -package org.bukkit.plugin; - -import org.bukkit.event.Event; -import org.bukkit.event.Listener; - -/** - * Interface which defines the class for event call backs to plugins - */ -public interface IExecutor { - public void execute( Listener listener, Event event ); -}
\ No newline at end of file diff --git a/src/main/java/org/bukkit/plugin/PluginLoader.java b/src/main/java/org/bukkit/plugin/PluginLoader.java index cc19455e..eaf6c066 100644 --- a/src/main/java/org/bukkit/plugin/PluginLoader.java +++ b/src/main/java/org/bukkit/plugin/PluginLoader.java @@ -33,7 +33,7 @@ public interface PluginLoader { * @param type Type of the event executor to create * @param listener the object that will handle the eventual call back */ - public IExecutor createExecutor(Event.Type type, Listener listener); + public EventExecutor createExecutor(Event.Type type, Listener listener); /** * Enables the specified plugin diff --git a/src/main/java/org/bukkit/plugin/PluginManager.java b/src/main/java/org/bukkit/plugin/PluginManager.java index c978e1e1..ed79abc5 100644 --- a/src/main/java/org/bukkit/plugin/PluginManager.java +++ b/src/main/java/org/bukkit/plugin/PluginManager.java @@ -108,11 +108,11 @@ public interface PluginManager { * * @param type EventType to register * @param listener Listener to register - * @param executor IExecutor to register + * @param executor EventExecutor to register * @param priority Priority of this event * @param plugin Plugin to register */ - public void registerEvent(Event.Type type, Listener listener, IExecutor executor, Priority priority, Plugin plugin); + public void registerEvent(Event.Type type, Listener listener, EventExecutor executor, Priority priority, Plugin plugin); /** * Enables the specified plugin diff --git a/src/main/java/org/bukkit/plugin/RegisteredListener.java b/src/main/java/org/bukkit/plugin/RegisteredListener.java index 06de0d57..fc2f53bb 100644 --- a/src/main/java/org/bukkit/plugin/RegisteredListener.java +++ b/src/main/java/org/bukkit/plugin/RegisteredListener.java @@ -3,7 +3,7 @@ package org.bukkit.plugin; import org.bukkit.event.Event; import org.bukkit.event.Listener; -import org.bukkit.plugin.IExecutor; +import org.bukkit.plugin.EventExecutor; /** * Stores relevant information for plugin listeners @@ -12,9 +12,9 @@ public class RegisteredListener { private final Listener listener; private final Event.Priority priority; private final Plugin plugin; - private final IExecutor executor; + private final EventExecutor executor; - public RegisteredListener(final Listener pluginListener, final IExecutor eventExecutor, final Event.Priority eventPriority, final Plugin registeredPlugin ) { + public RegisteredListener(final Listener pluginListener, final EventExecutor eventExecutor, final Event.Priority eventPriority, final Plugin registeredPlugin ) { listener = pluginListener; priority = eventPriority; plugin = registeredPlugin; diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 877b3548..5da87a6f 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -231,14 +231,15 @@ public final class SimplePluginManager implements PluginManager { } /** - * Registers the given event to the specified listener + * Registers the given event to the specified listener using a directly passed EventExecutor * * @param type EventType to register * @param listener PlayerListener to register + * @param executor EventExecutor to register * @param priority Priority of this event * @param plugin Plugin to register */ - public void registerEvent(Event.Type type, Listener listener, IExecutor executor, Priority priority, Plugin plugin) { + public void registerEvent(Event.Type type, Listener listener, EventExecutor executor, Priority priority, Plugin plugin) { getEventListeners( type ).offer(new RegisteredListener(listener, executor, priority, plugin)); } diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 77ae3191..0650584b 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -112,232 +112,232 @@ public final class JavaPluginLoader implements PluginLoader { classes.put(name, clazz); } - public IExecutor createExecutor( Event.Type type, Listener listener ) { + public EventExecutor createExecutor( Event.Type type, Listener listener ) { // TODO: remove multiple Listener type and hence casts switch (type) { // Player Events case PLAYER_JOIN: - return new IExecutor() { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerJoin( (PlayerEvent)event ); } }; case PLAYER_QUIT: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerQuit( (PlayerEvent)event ); } }; case PLAYER_COMMAND: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerCommand( (PlayerChatEvent)event ); } }; case PLAYER_CHAT: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerChat( (PlayerChatEvent)event ); } }; case PLAYER_MOVE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerMove( (PlayerMoveEvent)event ); } }; case PLAYER_TELEPORT: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerTeleport( (PlayerMoveEvent)event ); } }; case PLAYER_ITEM: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerItem( (PlayerItemEvent)event ); } }; case PLAYER_LOGIN: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerLogin( (PlayerLoginEvent)event ); } }; case PLAYER_EGG_THROW: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerEggThrow( (PlayerEggThrowEvent)event ); } }; case PLAYER_ANIMATION: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerAnimation( (PlayerAnimationEvent)event ); } }; // Block Events case BLOCK_PHYSICS: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockPhysics( (BlockPhysicsEvent)event ); } }; case BLOCK_CANBUILD: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockCanBuild( (BlockCanBuildEvent)event ); } }; case BLOCK_RIGHTCLICKED: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockRightClick( (BlockRightClickEvent)event ); } }; case BLOCK_PLACED: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockPlace( (BlockPlaceEvent)event ); } }; case BLOCK_DAMAGED: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockDamage( (BlockDamageEvent)event ); } }; case BLOCK_INTERACT: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockInteract( (BlockInteractEvent)event ); } }; case BLOCK_FLOW: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockFlow( (BlockFromToEvent)event ); } }; case LEAVES_DECAY: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onLeavesDecay( (LeavesDecayEvent)event ); } }; case BLOCK_IGNITE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockIgnite( (BlockIgniteEvent)event ); } }; case REDSTONE_CHANGE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockRedstoneChange( (BlockFromToEvent)event ); } }; case BLOCK_BURN: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockBurn( (BlockBurnEvent)event ); } }; // Server Events case PLUGIN_ENABLE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((ServerListener)listener).onPluginEnabled( (PluginEvent)event ); } }; case PLUGIN_DISABLE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((ServerListener)listener).onPluginDisabled( (PluginEvent)event ); } }; case SERVER_COMMAND: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((ServerListener)listener).onServerCommand( (ServerCommandEvent)event ); } }; // World Events case CHUNK_LOADED: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((WorldListener)listener).onChunkLoaded( (ChunkLoadEvent)event ); } }; case CHUNK_UNLOADED: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((WorldListener)listener).onChunkUnloaded( (ChunkUnloadEvent)event ); } }; // Entity Events case ENTITY_DAMAGEDBY_BLOCK: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityDamageByBlock( (EntityDamageByBlockEvent)event ); } }; case ENTITY_DAMAGEDBY_ENTITY: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityDamageByEntity( (EntityDamageByEntityEvent)event ); } }; case ENTITY_DAMAGEDBY_PROJECTILE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityDamageByProjectile( (EntityDamageByProjectileEvent)event ); } }; case ENTITY_DAMAGED: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityDamage( (EntityDamageEvent)event ); } }; case ENTITY_DEATH: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityDeath( (EntityDeathEvent)event ); } }; case ENTITY_COMBUST: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityCombust( (EntityCombustEvent)event ); } }; case ENTITY_EXPLODE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityExplode( (EntityExplodeEvent)event ); } }; case ENTITY_TARGET: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((EntityListener)listener).onEntityTarget( (EntityTargetEvent)event ); } }; // Vehicle Events case VEHICLE_CREATE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleCreate( (VehicleCreateEvent)event ); } }; case VEHICLE_DAMAGE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleDamage( (VehicleDamageEvent)event ); } }; case VEHICLE_COLLISION_BLOCK: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleBlockCollision( (VehicleBlockCollisionEvent)event ); } }; case VEHICLE_COLLISION_ENTITY: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleEntityCollision( (VehicleEntityCollisionEvent)event ); } }; case VEHICLE_ENTER: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleEnter( (VehicleEnterEvent)event ); } }; case VEHICLE_EXIT: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleExit( (VehicleExitEvent)event ); } }; case VEHICLE_MOVE: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((VehicleListener)listener).onVehicleMove( (VehicleMoveEvent)event ); } }; // Custom Events case CUSTOM_EVENT: - return new IExecutor() { public void execute( Listener listener, Event event ) { + return new EventExecutor() { public void execute( Listener listener, Event event ) { ((CustomEventListener)listener).onCustomEvent( event ); } }; |