From d16739f86adf100f9932d868949091cac11eac9e Mon Sep 17 00:00:00 2001 From: Leonid Skorospelov Date: Sun, 31 Oct 2021 13:31:53 +0000 Subject: [PATCH] Add event PlayerConnectionConfirmed (#6274) --- core/src/mindustry/core/NetServer.java | 2 ++ core/src/mindustry/game/EventType.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 39ddb35bb9..9a72f7ad51 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -757,6 +757,8 @@ public class NetServer implements ApplicationListener{ player.add(); + Events.fire(new PlayerConnectionConfirmed(player)); + if(player.con == null || player.con.hasConnected) return; player.con.hasConnected = true; diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 452f07c3e6..26d7dcb740 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -480,7 +480,19 @@ public class EventType{ } } - /** Called after connecting; when a player receives world data and is ready to play.*/ + /** + * Called after player confirmed it has received world data and is ready to play. + * Note that if this is the first world receival, then player.con.hasConnected is false. + */ + public static class PlayerConnectionConfirmed{ + public final Player player; + + public PlayerConnectionConfirmed(Player player){ + this.player = player; + } + } + + /** Called after connecting; when a player receives world data and is ready to play. Fired only once, after initial connection. */ public static class PlayerJoin{ public final Player player;