mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
Added Sneaking Event
By: Alexander Hesse <azi@MacBook-Pro.local>
This commit is contained in:
parent
d245d54634
commit
b280199e83
5 changed files with 74 additions and 4 deletions
|
@ -64,4 +64,16 @@ public interface Player extends HumanEntity, CommandSender {
|
|||
* @return true if the command was successful, otherwise false
|
||||
*/
|
||||
public boolean performCommand(String command);
|
||||
|
||||
/**
|
||||
* Returns if the player is in sneak mode
|
||||
* @return true if player is in sneak mode
|
||||
*/
|
||||
public boolean isSneaking();
|
||||
|
||||
/**
|
||||
* Sets the sneak mode the player
|
||||
* @param sneak true if player should appear sneaking
|
||||
*/
|
||||
public void setSneaking(boolean sneak);
|
||||
}
|
||||
|
|
|
@ -195,10 +195,17 @@ public abstract class Event {
|
|||
/**
|
||||
* Called when a player undergoes an animation, such as arm swinging
|
||||
*
|
||||
* @todo: add javadoc see comment
|
||||
* @see org.bukkit.event.player.PlayerAnimationEvent
|
||||
*/
|
||||
PLAYER_ANIMATION (Category.PLAYER),
|
||||
|
||||
/**
|
||||
* Called when a player toggles sneak mode
|
||||
*
|
||||
* @todo: add javadoc see comment
|
||||
*/
|
||||
PLAYER_TOGGLE_SNEAK (Category.PLAYER),
|
||||
|
||||
/**
|
||||
* Called when a player uses an item
|
||||
*
|
||||
|
|
|
@ -32,7 +32,6 @@ public class PlayerListener implements Listener {
|
|||
* @param event Relevant event details
|
||||
*/
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,4 +129,12 @@ public class PlayerListener implements Listener {
|
|||
*/
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player toggles sneak mode
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package org.bukkit.event.player;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author azi
|
||||
*/
|
||||
public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable{
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerToggleSneakEvent(final Type type, final Player player) {
|
||||
super(type, player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -194,6 +194,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||
((PlayerListener)listener).onPlayerDropItem( (PlayerDropItemEvent)event );
|
||||
}
|
||||
};
|
||||
case PLAYER_TOGGLE_SNEAK:
|
||||
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||
((PlayerListener)listener).onPlayerToggleSneak( (PlayerToggleSneakEvent)event );
|
||||
}
|
||||
};
|
||||
|
||||
// Block Events
|
||||
case BLOCK_PHYSICS:
|
||||
|
|
Loading…
Reference in a new issue