From cf74a1cb3c01706f7c5873059185b770fd10ad4b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 9 Jul 2017 21:28:26 +0200 Subject: [PATCH] Added Bukkit Player to join/leave events --- .../java/buttondevteam/lib/player/TBMCPlayerBase.java | 4 ++-- .../buttondevteam/lib/player/TBMCPlayerJoinEvent.java | 9 ++++++++- .../buttondevteam/lib/player/TBMCPlayerQuitEvent.java | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/buttondevteam/lib/player/TBMCPlayerBase.java b/src/main/java/buttondevteam/lib/player/TBMCPlayerBase.java index 55613b8..14d1c0d 100644 --- a/src/main/java/buttondevteam/lib/player/TBMCPlayerBase.java +++ b/src/main/java/buttondevteam/lib/player/TBMCPlayerBase.java @@ -153,7 +153,7 @@ public abstract class TBMCPlayerBase extends ChromaGamerBase { // Load in other plugins Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerLoadEvent(player)); - Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerJoinEvent(player)); + Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerJoinEvent(player, p)); player.save(); } @@ -163,7 +163,7 @@ public abstract class TBMCPlayerBase extends ChromaGamerBase { public static void quitPlayer(Player p) { final TBMCPlayerBase player = playermap.get(p.getUniqueId() + "-" + TBMCPlayer.class.getSimpleName()); player.save(); - Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerQuitEvent(player)); + Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerQuitEvent(player, p)); Iterator> it = playermap.entrySet().iterator(); while (it.hasNext()) { Entry entry = it.next(); diff --git a/src/main/java/buttondevteam/lib/player/TBMCPlayerJoinEvent.java b/src/main/java/buttondevteam/lib/player/TBMCPlayerJoinEvent.java index f63c002..b1c3960 100644 --- a/src/main/java/buttondevteam/lib/player/TBMCPlayerJoinEvent.java +++ b/src/main/java/buttondevteam/lib/player/TBMCPlayerJoinEvent.java @@ -1,5 +1,6 @@ package buttondevteam.lib.player; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -7,15 +8,21 @@ public class TBMCPlayerJoinEvent extends Event { private static final HandlerList handlers = new HandlerList(); private TBMCPlayerBase player; + private Player player_; - public TBMCPlayerJoinEvent(TBMCPlayerBase player) { + public TBMCPlayerJoinEvent(TBMCPlayerBase player, Player player_) { this.player = player; + this.player_ = player_; } public TBMCPlayerBase GetPlayer() { return player; } + public Player getPlayer() { // :P + return player_; + } + @Override public HandlerList getHandlers() { return handlers; diff --git a/src/main/java/buttondevteam/lib/player/TBMCPlayerQuitEvent.java b/src/main/java/buttondevteam/lib/player/TBMCPlayerQuitEvent.java index a228d02..4d0ef4b 100644 --- a/src/main/java/buttondevteam/lib/player/TBMCPlayerQuitEvent.java +++ b/src/main/java/buttondevteam/lib/player/TBMCPlayerQuitEvent.java @@ -1,5 +1,6 @@ package buttondevteam.lib.player; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -7,15 +8,21 @@ public class TBMCPlayerQuitEvent extends Event { private static final HandlerList handlers = new HandlerList(); private TBMCPlayerBase player; + private Player player_; - public TBMCPlayerQuitEvent(TBMCPlayerBase player) { + public TBMCPlayerQuitEvent(TBMCPlayerBase player, Player player_) { this.player = player; + this.player_ = player_; } public TBMCPlayerBase GetPlayer() { return player; } + public Player getPlayer() { + return player_; + } + @Override public HandlerList getHandlers() { return handlers;