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();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +198,7 @@ public abstract class Event implements Serializable {
|
|||||||
*/
|
*/
|
||||||
PLAYER_MOVE (Category.PLAYER),
|
PLAYER_MOVE (Category.PLAYER),
|
||||||
/**
|
/**
|
||||||
* Called before a player gets a velocity vector sent, which will instruct him to
|
* Called before a player gets a velocity vector sent, which will instruct him to
|
||||||
* get "pushed" into a specific direction, e.g. after an explosion
|
* get "pushed" into a specific direction, e.g. after an explosion
|
||||||
*
|
*
|
||||||
* @see org.bukkit.event.player.PlayerVelocityEvent
|
* @see org.bukkit.event.player.PlayerVelocityEvent
|
||||||
@ -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
|
||||||
*
|
*
|
||||||
@ -303,7 +309,7 @@ public abstract class Event implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the game mode of a player is changed
|
* Called when the game mode of a player is changed
|
||||||
*
|
*
|
||||||
* @see org.bukkit.event.player.PlayerGameModeChangeEvent
|
* @see org.bukkit.event.player.PlayerGameModeChangeEvent
|
||||||
*/
|
*/
|
||||||
PLAYER_GAME_MODE_CHANGE(Category.PLAYER),
|
PLAYER_GAME_MODE_CHANGE(Category.PLAYER),
|
||||||
@ -496,7 +502,7 @@ public abstract class Event implements Serializable {
|
|||||||
SERVER_COMMAND (Category.SERVER),
|
SERVER_COMMAND (Category.SERVER),
|
||||||
/**
|
/**
|
||||||
* Called when a map is initialized (created or loaded into memory)
|
* Called when a map is initialized (created or loaded into memory)
|
||||||
*
|
*
|
||||||
* @see org.bukkit.event.server.MapInitializeEvent
|
* @see org.bukkit.event.server.MapInitializeEvent
|
||||||
*/
|
*/
|
||||||
MAP_INITIALIZE (Category.SERVER),
|
MAP_INITIALIZE (Category.SERVER),
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
@ -191,10 +198,10 @@ public class PlayerListener implements Listener {
|
|||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onPlayerFish(PlayerFishEvent event) {}
|
public void onPlayerFish(PlayerFishEvent event) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player's game mode is changed
|
* Called when a player's game mode is changed
|
||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {}
|
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {}
|
||||||
|
@ -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) {
|
||||||
@ -419,7 +426,7 @@ public class JavaPluginLoader implements PluginLoader {
|
|||||||
((PlayerListener) listener).onPlayerFish((PlayerFishEvent) event);
|
((PlayerListener) listener).onPlayerFish((PlayerFishEvent) event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
case PLAYER_GAME_MODE_CHANGE:
|
case PLAYER_GAME_MODE_CHANGE:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
@ -569,7 +576,7 @@ public class JavaPluginLoader implements PluginLoader {
|
|||||||
((ServerListener) listener).onServerCommand((ServerCommandEvent) event);
|
((ServerListener) listener).onServerCommand((ServerCommandEvent) event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
case MAP_INITIALIZE:
|
case MAP_INITIALIZE:
|
||||||
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