geforkt von Mirrors/Paper
Added PlayerToggleSprint event and sprinting related API.
By: Rigby <rigby@onarandombox.com>
Dieser Commit ist enthalten in:
Ursprung
ff51e5c299
Commit
a3e8ec7d78
@ -98,6 +98,20 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer {
|
|||||||
*/
|
*/
|
||||||
public void setSneaking(boolean sneak);
|
public void setSneaking(boolean sneak);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the player is sprinting or not.
|
||||||
|
*
|
||||||
|
* @return true if player is sprinting.
|
||||||
|
*/
|
||||||
|
public boolean isSprinting();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the player is sprinting or not.
|
||||||
|
*
|
||||||
|
* @param sprinting true if the player should be sprinting
|
||||||
|
*/
|
||||||
|
public void setSprinting(boolean sprinting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the players current location, health, inventory, motion, and other information into the username.dat file, in the world/player folder
|
* Saves the players current location, health, inventory, motion, and other information into the username.dat file, in the world/player folder
|
||||||
*/
|
*/
|
||||||
@ -298,6 +312,7 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer {
|
|||||||
*
|
*
|
||||||
* @return Current experience points
|
* @return Current experience points
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int getExperience();
|
public int getExperience();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,6 +216,12 @@ public abstract class Event implements Serializable {
|
|||||||
* @see org.bukkit.event.player.PlayerToggleSneakEvent
|
* @see org.bukkit.event.player.PlayerToggleSneakEvent
|
||||||
*/
|
*/
|
||||||
PLAYER_TOGGLE_SNEAK (Category.PLAYER),
|
PLAYER_TOGGLE_SNEAK (Category.PLAYER),
|
||||||
|
/**
|
||||||
|
* Called when a player toggles sprint mode
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.player.PlayerToggleSprintEvent
|
||||||
|
*/
|
||||||
|
PLAYER_TOGGLE_SPRINT (Category.PLAYER),
|
||||||
/**
|
/**
|
||||||
* Called when a player interacts with an object or air
|
* Called when a player interacts with an object or air
|
||||||
*
|
*
|
||||||
|
@ -150,6 +150,13 @@ public class PlayerListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {}
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player toggles sprint mode
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player fills a bucket
|
* Called when a player fills a bucket
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player toggles their sprinting state
|
||||||
|
*/
|
||||||
|
public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private boolean isSprinting;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public PlayerToggleSprintEvent(final Player player, boolean isSprinting) {
|
||||||
|
super(Type.PLAYER_TOGGLE_SPRINT, player);
|
||||||
|
this.isSprinting = isSprinting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the player is now sprinting or not.
|
||||||
|
*
|
||||||
|
* @return sprinting state
|
||||||
|
*/
|
||||||
|
public boolean isSprinting() {
|
||||||
|
return isSprinting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
}
|
@ -385,6 +385,13 @@ public class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case PLAYER_TOGGLE_SPRINT:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((PlayerListener) listener).onPlayerToggleSprint((PlayerToggleSprintEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
case PLAYER_BUCKET_EMPTY:
|
case PLAYER_BUCKET_EMPTY:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren