From 2a3a80d5438a10a0bb510a246dfaf180ba5d29be Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 30 Sep 2011 20:29:24 +0200 Subject: [PATCH] Added PlayerChangedWorldEvent. By: sunkid --- .../src/main/java/org/bukkit/event/Event.java | 7 +++++++ .../event/player/PlayerChangedWorldEvent.java | 18 ++++++++++++++++++ .../bukkit/event/player/PlayerListener.java | 7 +++++++ .../bukkit/plugin/java/JavaPluginLoader.java | 7 +++++++ 4 files changed, 39 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index 3bbd7ab806..25271f73eb 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -312,6 +312,13 @@ public abstract class Event implements Serializable { */ PLAYER_GAME_MODE_CHANGE(Category.PLAYER), + /** + * Called after a player has changed to a new world + * + * @see org.bukkit.event.player.PlayerChangedWorldEvent + */ + PLAYER_CHANGED_WORLD(Category.PLAYER), + /** * BLOCK EVENTS */ diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java new file mode 100644 index 0000000000..badbc13f62 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java @@ -0,0 +1,18 @@ +package org.bukkit.event.player; + +import org.bukkit.World; +import org.bukkit.entity.Player; + +public class PlayerChangedWorldEvent extends PlayerEvent { + + private final World from; + + public PlayerChangedWorldEvent(Player player, World from) { + super(Type.PLAYER_CHANGED_WORLD, player); + this.from = from; + } + + public World getFrom() { + return from; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java index 423caebb4c..f108a32fbb 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java @@ -205,4 +205,11 @@ public class PlayerListener implements Listener { * @param event Relevant event details */ public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {} + + /** + * Called after a player changes to a new world + * + * @param event Relevant event details + */ + public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {} } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 7b61a26605..ad69872e06 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -434,6 +434,13 @@ public class JavaPluginLoader implements PluginLoader { } }; + case PLAYER_CHANGED_WORLD: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((PlayerListener) listener).onPlayerChangedWorld((PlayerChangedWorldEvent) event); + } + }; + // Block Events case BLOCK_PHYSICS: return new EventExecutor() {