mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
Added PlayerFish event.
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
ccbd9a6709
commit
84a45a3927
@ -287,6 +287,12 @@ public abstract class Event implements Serializable {
|
||||
* @see org.bukkit.event.player.PlayerBedLeaveEvent
|
||||
*/
|
||||
PLAYER_BED_LEAVE(Category.PLAYER),
|
||||
/**
|
||||
* Called when a player is fishing
|
||||
*
|
||||
* @see org.bukkit.event.player.PlayerFishEvent
|
||||
*/
|
||||
PLAYER_FISH(Category.PLAYER),
|
||||
|
||||
/**
|
||||
* BLOCK EVENTS
|
||||
|
@ -0,0 +1,85 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
/**
|
||||
* Thrown when a player is fishing
|
||||
*/
|
||||
public class PlayerFishEvent extends PlayerEvent implements Cancellable {
|
||||
private final Entity entity;
|
||||
private boolean cancel = false;
|
||||
private State state;
|
||||
|
||||
public PlayerFishEvent(final Player player, final Entity entity, State state) {
|
||||
super(Type.PLAYER_FISH, player);
|
||||
this.entity = entity;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entity caught by the player
|
||||
*
|
||||
* @return Entity caught by the player, null if fishing, bobber has gotten stuck in the ground or nothing has been caught
|
||||
*/
|
||||
public Entity getCaught() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cancellation state of this event. A cancelled event will not
|
||||
* be executed in the server, but will still pass to other plugins
|
||||
*
|
||||
* @return true if this event is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancellation state of this event. A cancelled event will not
|
||||
* be executed in the server, but will still pass to other plugins
|
||||
*
|
||||
* @param cancel true if you wish to cancel this event
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state of the fishing
|
||||
*
|
||||
* @return A State detailing the state of the fishing
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* An enum to specify the state of the fishing
|
||||
*/
|
||||
public enum State {
|
||||
|
||||
/**
|
||||
* When a player is fishing
|
||||
*/
|
||||
FISHING,
|
||||
/**
|
||||
* When a player has successfully caught a fish
|
||||
*/
|
||||
CAUGHT_FISH,
|
||||
/**
|
||||
* When a player has successfully caught an entity
|
||||
*/
|
||||
CAUGHT_ENTITY,
|
||||
/**
|
||||
* When a bobber is stuck in the grund
|
||||
*/
|
||||
IN_GROUND,
|
||||
/**
|
||||
* When a player fails to catch anything while fishing usually due to poor aiming or timing
|
||||
*/
|
||||
FAILED_ATTEMPT,
|
||||
}
|
||||
}
|
@ -176,4 +176,11 @@ public class PlayerListener implements Listener {
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onPlayerPortal(PlayerPortalEvent event) {}
|
||||
|
||||
/**
|
||||
* Called when a player is fishing
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onPlayerFish(PlayerFishEvent event) {}
|
||||
}
|
||||
|
@ -406,6 +406,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
};
|
||||
|
||||
case PLAYER_FISH:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((PlayerListener) listener).onPlayerFish((PlayerFishEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
// Block Events
|
||||
case BLOCK_PHYSICS:
|
||||
return new EventExecutor() {
|
||||
|
Loading…
Reference in New Issue
Block a user