Skip to content

Instantly share code, notes, and snippets.

Created June 10, 2014 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/cf0f73bd4ac3b2c411f1 to your computer and use it in GitHub Desktop.
Save anonymous/cf0f73bd4ac3b2c411f1 to your computer and use it in GitHub Desktop.
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class PlayerAbilityEvent extends Event {
private static final HandlerList handler = new HandlerList();
@Override
public HandlerList getHandlers() {
return handler;
}
public static HandlerList getHandlerList () {
return handler;
}
private final Event event;
private final int type;
public PlayerAbilityEvent (Event event) {
if(event instanceof PlayerInteractEvent)
type = 1;
else if(event instanceof EntityShootBowEvent)
type = 2;
else if(event instanceof ProjectileLaunchEvent)
type = 3;
else type = 0;
if(type == 0)
throw new IllegalArgumentException("The tst event can only accept PlayerInteractEvent, EntityShootBowEvent, and ProjectileLaunchEvent events.");
this.event = event;
}
public boolean isInteractEvent () {
return type == 1;
}
public boolean isEntityShootBowEvent () {
return type == 2;
}
public boolean isProjectileLaunchEvent () {
return type == 3;
}
public int getType () {
return type;
}
public PlayerInteractEvent getPlayerInteractEvent () {
if(isInteractEvent())
return (PlayerInteractEvent) event;
else
return null;
}
public EntityShootBowEvent getEntityShootBowEvent () {
if(isEntityShootBowEvent())
return (EntityShootBowEvent) event;
else
return null;
}
public ProjectileLaunchEvent getProjectileLaunchEvent () {
if(isProjectileLaunchEvent())
return (ProjectileLaunchEvent) event;
else
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment