Added PlayerInteractEntityEvent which fires when a player right clicks an entity. Thanks fullwall!
This commit is contained in:
parent
e969067ce3
commit
7570b5bfaf
@ -232,6 +232,13 @@ public abstract class Event implements Serializable {
|
|||||||
*/
|
*/
|
||||||
PLAYER_INTERACT (Category.PLAYER),
|
PLAYER_INTERACT (Category.PLAYER),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player right clicks an entity
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.player.PlayerInteractEntityEvent
|
||||||
|
*/
|
||||||
|
PLAYER_INTERACT_ENTITY (Category.PLAYER),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player throws an egg and it might hatch
|
* Called when a player throws an egg and it might hatch
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an event that is called when a player right clicks an entity.
|
||||||
|
*/
|
||||||
|
public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellable {
|
||||||
|
protected Entity clickedEntity;
|
||||||
|
boolean cancelled = false;
|
||||||
|
|
||||||
|
public PlayerInteractEntityEvent(Player who, Entity clickedEntity) {
|
||||||
|
super(Type.PLAYER_INTERACT_ENTITY, who);
|
||||||
|
this.clickedEntity = clickedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the entity that was rightclicked by the player.
|
||||||
|
*
|
||||||
|
* @return entity right clicked by player
|
||||||
|
*/
|
||||||
|
public Entity getRightClicked() {
|
||||||
|
return this.clickedEntity;
|
||||||
|
}
|
||||||
|
}
|
@ -92,6 +92,14 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player right clicks an entity.
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player attempts to log in to the server
|
* Called when a player attempts to log in to the server
|
||||||
*
|
*
|
||||||
|
@ -280,6 +280,12 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
((PlayerListener) listener).onPlayerInteract((PlayerInteractEvent) event);
|
((PlayerListener) listener).onPlayerInteract((PlayerInteractEvent) event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
case PLAYER_INTERACT_ENTITY:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((PlayerListener) listener).onPlayerInteractEntity((PlayerInteractEntityEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
case PLAYER_LOGIN:
|
case PLAYER_LOGIN:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user