|
3 | 3 | import com.earth2me.essentials.EssentialsLogger; |
4 | 4 | import com.earth2me.essentials.metrics.MetricsWrapper; |
5 | 5 | import net.ess3.api.IEssentials; |
| 6 | +import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent; |
6 | 7 | import org.bukkit.Location; |
7 | 8 | import org.bukkit.command.Command; |
8 | 9 | import org.bukkit.command.CommandSender; |
9 | 10 | import org.bukkit.event.EventPriority; |
10 | | -import org.bukkit.event.player.PlayerJoinEvent; |
11 | 11 | import org.bukkit.event.player.PlayerRespawnEvent; |
12 | 12 | import org.bukkit.plugin.PluginManager; |
13 | 13 | import org.bukkit.plugin.java.JavaPlugin; |
@@ -48,8 +48,11 @@ public void onEnable() { |
48 | 48 |
|
49 | 49 | final EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority(); |
50 | 50 | if (joinPriority != null) { |
51 | | - pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, (ll, event) -> |
52 | | - ((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event), this); |
| 51 | + // Listen on AsyncUserDataLoadEvent (fired after the core join flow) so we can reliably tell whether this is |
| 52 | + // a player's first join, instead of using Player#hasPlayedBefore() which doesn't since data is persisted during the configuration phase. |
| 53 | + // See https://github.com/EssentialsX/Essentials/issues/6466 |
| 54 | + pluginManager.registerEvent(AsyncUserDataLoadEvent.class, playerListener, joinPriority, (ll, event) -> |
| 55 | + ((EssentialsSpawnPlayerListener) ll).onUserDataLoad((AsyncUserDataLoadEvent) event), this); |
53 | 56 | } |
54 | 57 |
|
55 | 58 | if (metrics == null) { |
|
0 commit comments