diff --git a/CHANGELOG.md b/CHANGELOG.md index 228df86b..7be3d178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Fixed BungeeCord force logins if there is a lobby server * Removed cache expire in BungeeCord +* Applies skin earlier to make it visible for other plugins listening on login events ######1.5.1 diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index 2096d213..90520c39 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -12,6 +12,7 @@ import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin; import com.github.games647.fastlogin.bukkit.listener.BukkitJoinListener; import com.github.games647.fastlogin.bukkit.listener.BungeeCordListener; import com.github.games647.fastlogin.bukkit.listener.ProtocolSupportListener; +import com.github.games647.fastlogin.bukkit.listener.packet.LoginSkinApplyListener; import com.github.games647.fastlogin.bukkit.listener.packet.EncryptionPacketListener; import com.github.games647.fastlogin.bukkit.listener.packet.StartPacketListener; import com.github.games647.fastlogin.core.FastLoginCore; @@ -114,6 +115,7 @@ public class FastLoginBukkit extends JavaPlugin { asynchronousManager.registerAsyncHandler(startPacketListener).start(WORKER_THREADS); asynchronousManager.registerAsyncHandler(encryptionPacketListener).start(WORKER_THREADS); + getServer().getPluginManager().registerEvents(new LoginSkinApplyListener(this), this); } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java index 6c3318ae..8ead5833 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java @@ -1,8 +1,5 @@ package com.github.games647.fastlogin.bukkit.listener; -import com.comphenix.protocol.wrappers.WrappedGameProfile; -import com.comphenix.protocol.wrappers.WrappedSignedProperty; -import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.github.games647.fastlogin.bukkit.tasks.ForceLoginTask; @@ -40,15 +37,6 @@ public class BukkitJoinListener implements Listener { public void onPlayerJoin(PlayerJoinEvent joinEvent) { Player player = joinEvent.getPlayer(); - BukkitLoginSession session = plugin.getSessions().get(player.getAddress().toString()); - if (session != null && plugin.getConfig().getBoolean("forwardSkin")) { - WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player); - WrappedSignedProperty skin = session.getSkin(); - if (skin != null) { - gameProfile.getProperties().put("textures", skin); - } - } - if (!plugin.isBungeeCord()) { //Wait before auth plugin and we received a message from BungeeCord initializes the player Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new ForceLoginTask(plugin, player), DELAY_LOGIN); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/LoginSkinApplyListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/LoginSkinApplyListener.java new file mode 100644 index 00000000..74df184f --- /dev/null +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/LoginSkinApplyListener.java @@ -0,0 +1,35 @@ +package com.github.games647.fastlogin.bukkit.listener.packet; + +import com.comphenix.protocol.wrappers.WrappedGameProfile; +import com.comphenix.protocol.wrappers.WrappedSignedProperty; +import com.github.games647.fastlogin.bukkit.BukkitLoginSession; +import com.github.games647.fastlogin.bukkit.FastLoginBukkit; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLoginEvent; + +public class LoginSkinApplyListener implements Listener { + + private final FastLoginBukkit plugin; + + public LoginSkinApplyListener(FastLoginBukkit plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerLogin(PlayerLoginEvent loginEvent) { + Player player = loginEvent.getPlayer(); + + BukkitLoginSession session = plugin.getSessions().get(player.getAddress().toString()); + if (session != null && plugin.getConfig().getBoolean("forwardSkin")) { + WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player); + WrappedSignedProperty skin = session.getSkin(); + if (skin != null) { + gameProfile.getProperties().put("textures", skin); + } + } + } +} diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java index aed689c5..486aa16e 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java @@ -1,7 +1,7 @@ package com.github.games647.fastlogin.bungee.listener; -import com.github.games647.fastlogin.bungee.tasks.AsyncPremiumCheck; import com.github.games647.fastlogin.bungee.FastLoginBungee; +import com.github.games647.fastlogin.bungee.tasks.AsyncPremiumCheck; import com.github.games647.fastlogin.bungee.tasks.ForceLoginTask; import com.github.games647.fastlogin.core.LoginSession; import com.github.games647.fastlogin.core.PlayerProfile;