diff --git a/src/main/java/com/lielamar/auth/bukkit/events/PlayerStateChangeEvent.java b/src/main/java/com/lielamar/auth/bukkit/events/PlayerStateChangeEvent.java index 0883c15..99dbd58 100644 --- a/src/main/java/com/lielamar/auth/bukkit/events/PlayerStateChangeEvent.java +++ b/src/main/java/com/lielamar/auth/bukkit/events/PlayerStateChangeEvent.java @@ -5,6 +5,8 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class PlayerStateChangeEvent extends Event implements Cancellable { @@ -18,6 +20,12 @@ public class PlayerStateChangeEvent extends Event implements Cancellable { private boolean cancelled = false; private AuthHandler.AuthState oldAuthState, newAuthState; + @Deprecated + public PlayerStateChangeEvent(Player player, AuthHandler.AuthState authState) { + this.player = player; + this.newAuthState = authState; + } + public PlayerStateChangeEvent(Player player, AuthHandler.AuthState oldAuthState, AuthHandler.AuthState newAuthState) { this.player = player; this.oldAuthState = oldAuthState; @@ -47,19 +55,30 @@ public Player getPlayer() { return player; } - public AuthHandler.AuthState getOldAuthState() { + public @Nullable AuthHandler.AuthState getOldAuthState() { return oldAuthState; } - public void setOldAuthState(AuthHandler.AuthState oldAuthState) { + public void setOldAuthState(@NotNull AuthHandler.AuthState oldAuthState) { this.oldAuthState = oldAuthState; } - public AuthHandler.AuthState getNewAuthState() { + public @NotNull AuthHandler.AuthState getNewAuthState() { + return newAuthState; + } + + public void setNewAuthState(@NotNull AuthHandler.AuthState newAuthState) { + this.newAuthState = newAuthState; + } + + + @Deprecated + public @NotNull AuthHandler.AuthState getAuthState() { return newAuthState; } - public void setNewAuthState(AuthHandler.AuthState newAuthState) { + @Deprecated + public void setAuthState(@NotNull AuthHandler.AuthState authState) { this.newAuthState = newAuthState; } } \ No newline at end of file diff --git a/src/test/java/PlayerStateChangeEventExample.java b/src/test/java/PlayerStateChangeEventExample.java index 7e4f7c3..a9714d8 100644 --- a/src/test/java/PlayerStateChangeEventExample.java +++ b/src/test/java/PlayerStateChangeEventExample.java @@ -8,7 +8,7 @@ public class PlayerStateChangeEventExample implements Listener { @EventHandler public void onStateChange(PlayerStateChangeEvent event) { - if(event.getAuthState() == AuthHandler.AuthState.PENDING_LOGIN) { + if(event.getNewAuthState() == AuthHandler.AuthState.PENDING_LOGIN) { event.getPlayer().sendMessage(ChatColor.GREEN + "We are waiting for you to authenticate!"); } }