From fa489f60145b780c3d87d54644f8f9e1fb53193b Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sat, 14 Dec 2019 17:43:42 -0500 Subject: [PATCH 1/3] Rename mystery field in JoinGame --- .../com/velocitypowered/proxy/protocol/packet/JoinGame.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java index 634fd1c4c..0ab784173 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java @@ -18,7 +18,7 @@ public class JoinGame implements MinecraftPacket { private @Nullable String levelType; private int viewDistance; //1.14+ private boolean reducedDebugInfo; - private boolean mystery; + private boolean showRespawnScreen; public int getEntityId() { return entityId; @@ -130,7 +130,7 @@ public class JoinGame implements MinecraftPacket { this.reducedDebugInfo = buf.readBoolean(); } if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) { - this.mystery = buf.readBoolean(); + this.showRespawnScreen = buf.readBoolean(); } } @@ -161,7 +161,7 @@ public class JoinGame implements MinecraftPacket { buf.writeBoolean(reducedDebugInfo); } if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) { - buf.writeBoolean(mystery); + buf.writeBoolean(showRespawnScreen); } } From 4c090249525a149994cd759fe94c3e7ce8edfa2c Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 17 Dec 2019 13:57:23 -0500 Subject: [PATCH 2/3] Minecraft 1.15.1 --- .../java/com/velocitypowered/api/network/ProtocolVersion.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index af8c4c089..28f729748 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -34,7 +34,8 @@ public enum ProtocolVersion { MINECRAFT_1_14_2(485, "1.14.2"), MINECRAFT_1_14_3(490, "1.14.3"), MINECRAFT_1_14_4(498, "1.14.4"), - MINECRAFT_1_15(573, "1.15"); + MINECRAFT_1_15(573, "1.15"), + MINECRAFT_1_15_1(575, "1.15.1"); private final int protocol; private final String name; From fb0446f4fcf46112c7b7331a3813c791a38a137b Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 24 Dec 2019 23:56:39 -0500 Subject: [PATCH 3/3] Add DisconnectEvent#disconnectedDuringLogin() --- .../api/event/connection/DisconnectEvent.java | 14 +++++++++++++- .../proxy/connection/client/ConnectedPlayer.java | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java index dee4dd7e0..2442077a8 100644 --- a/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java @@ -10,19 +10,31 @@ import com.velocitypowered.api.proxy.Player; public final class DisconnectEvent { private final Player player; + private final boolean disconnectedDuringLogin; public DisconnectEvent(Player player) { + this(player, false); + } + + public DisconnectEvent(Player player, + boolean disconnectedDuringLogin) { this.player = Preconditions.checkNotNull(player, "player"); + this.disconnectedDuringLogin = disconnectedDuringLogin; } public Player getPlayer() { return player; } + public boolean disconnectedDuringLogin() { + return this.disconnectedDuringLogin; + } + @Override public String toString() { return "DisconnectEvent{" - + "player=" + player + + "player=" + player + ", " + + "disconnectedDuringLogin=" + disconnectedDuringLogin + '}'; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index d90fc2054..fd6b9d71c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -571,8 +571,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { if (connectedServer != null) { connectedServer.disconnect(); } + boolean isConnected = server.getPlayer(this.getUniqueId()).isPresent(); + server.unregisterConnection(this); - server.getEventManager().fire(new DisconnectEvent(this)) + server.getEventManager().fire(new DisconnectEvent(this, !isConnected)) .thenRun(() -> this.teardownFuture.complete(null)); }