-
-
Save anonymous/cf0f73bd4ac3b2c411f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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