summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/entity/Player.java15
-rw-r--r--src/main/java/org/bukkit/event/Event.java12
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerListener.java11
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java34
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java11
5 files changed, 76 insertions, 7 deletions
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index dca68f2e..0e219a7c 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -99,6 +99,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
*/
public void saveData();
@@ -298,6 +312,7 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer {
*
* @return Current experience points
*/
+
public int getExperience();
/**
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index 236575fb..efb609be 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -198,7 +198,7 @@ public abstract class Event implements Serializable {
*/
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
*
* @see org.bukkit.event.player.PlayerVelocityEvent
@@ -217,6 +217,12 @@ public abstract class Event implements Serializable {
*/
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
*
* @see org.bukkit.event.player.PlayerInteractEvent
@@ -303,7 +309,7 @@ public abstract class Event implements Serializable {
/**
* Called when the game mode of a player is changed
- *
+ *
* @see org.bukkit.event.player.PlayerGameModeChangeEvent
*/
PLAYER_GAME_MODE_CHANGE(Category.PLAYER),
@@ -496,7 +502,7 @@ public abstract class Event implements Serializable {
SERVER_COMMAND (Category.SERVER),
/**
* Called when a map is initialized (created or loaded into memory)
- *
+ *
* @see org.bukkit.event.server.MapInitializeEvent
*/
MAP_INITIALIZE (Category.SERVER),
diff --git a/src/main/java/org/bukkit/event/player/PlayerListener.java b/src/main/java/org/bukkit/event/player/PlayerListener.java
index 2b634589..423caebb 100644
--- a/src/main/java/org/bukkit/event/player/PlayerListener.java
+++ b/src/main/java/org/bukkit/event/player/PlayerListener.java
@@ -151,6 +151,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
*
* @param event Relevant event details
@@ -191,10 +198,10 @@ public class PlayerListener implements Listener {
* @param event Relevant event details
*/
public void onPlayerFish(PlayerFishEvent event) {}
-
+
/**
* Called when a player's game mode is changed
- *
+ *
* @param event Relevant event details
*/
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {}
diff --git a/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java b/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java
new file mode 100644
index 00000000..ef86ae48
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java
@@ -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;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index d5f7dd0c..0693da62 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -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) {
@@ -419,7 +426,7 @@ public class JavaPluginLoader implements PluginLoader {
((PlayerListener) listener).onPlayerFish((PlayerFishEvent) event);
}
};
-
+
case PLAYER_GAME_MODE_CHANGE:
return new EventExecutor() {
public void execute(Listener listener, Event event) {
@@ -569,7 +576,7 @@ public class JavaPluginLoader implements PluginLoader {
((ServerListener) listener).onServerCommand((ServerCommandEvent) event);
}
};
-
+
case MAP_INITIALIZE:
return new EventExecutor() {
public void execute(Listener listener, Event event) {