13
0
geforkt von Mirrors/Paper

Added PlayerToggleSprint event and sprinting related API.

By: Rigby <rigby@onarandombox.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-09-21 11:46:33 +01:00
Ursprung ff51e5c299
Commit a3e8ec7d78
5 geänderte Dateien mit 76 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -98,6 +98,20 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer {
*/
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
*/
@ -298,6 +312,7 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer {
*
* @return Current experience points
*/
public int getExperience();
/**

Datei anzeigen

@ -216,6 +216,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.player.PlayerToggleSneakEvent
*/
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
*

Datei anzeigen

@ -150,6 +150,13 @@ public class PlayerListener implements Listener {
*/
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
*

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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:
return new EventExecutor() {
public void execute(Listener listener, Event event) {