Skip to content

Commit 1172bc0

Browse files
committed
feat: expose whether the client loaded the world for a backend conn
feat(jd): add note for plugins on how to implement timeout behaviour
1 parent d0715cb commit 1172bc0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

api/src/main/java/com/velocitypowered/api/event/player/PlayerClientLoadedWorldEvent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* <p>This event is fired when the player explicitly notifies the server after loading the world (closing the downloading terrain screen)
1818
*
1919
* @implNote Unlike Paper this event will <u>not</u> fire due to a timeout.
20+
* Though plugins can implement a timeout by scheduling a task in {@link ServerPostConnectEvent}
21+
* and checking {@link com.velocitypowered.api.proxy.ServerConnection#isClientLoaded()}.
2022
* @sinceMinecraft 1.21.4
2123
* @since 3.4.0
2224
*/

api/src/main/java/com/velocitypowered/api/proxy/ServerConnection.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public interface ServerConnection extends ChannelMessageSource, ChannelMessageSi
4040
*/
4141
ServerInfo getServerInfo();
4242

43+
/**
44+
* Returns whether the client notified this connection of having loaded the world.
45+
*
46+
* @return true if the client has loaded the world
47+
* @implNote This is purely client-dependent; see {@link com.velocitypowered.api.event.player.PlayerClientLoadedWorldEvent}.
48+
* @sinceMinecraft 1.21.4
49+
* @since 3.4.0
50+
*/
51+
boolean isClientLoaded();
52+
4353
/**
4454
* Returns the player that this connection is associated with.
4555
*

proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
6868
private final VelocityServer server;
6969
private @Nullable MinecraftConnection connection;
7070
private boolean hasCompletedJoin = false;
71-
private boolean clientLoaded = false; // 1.21.4+ - does not time out
71+
private boolean clientLoaded = false; // 1.21.4+
7272
private boolean gracefulDisconnect = false;
7373
private BackendConnectionPhase connectionPhase = BackendConnectionPhases.UNKNOWN;
7474
private final Map<Long, Long> pendingPings = new HashMap<>();
@@ -323,6 +323,7 @@ public void setClientLoaded(boolean clientLoaded) {
323323
this.clientLoaded = clientLoaded;
324324
}
325325

326+
@Override
326327
public boolean isClientLoaded() {
327328
return clientLoaded;
328329
}

0 commit comments

Comments
 (0)