mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 21:37:39 +01:00
Renamed IExecutor -> CommandExecutor and fixed SERVER_COMMAND doc
By: stevenh <steven.hartland@multiplay.co.uk>
This commit is contained in:
parent
e56db60b83
commit
6f4cf0388b
@ -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();
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -28,6 +28,6 @@ public class ServerListener implements Listener {
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onServerCommand(PluginEvent event) {
|
||||
public void onServerCommand(ServerCommandEvent event) {
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user