Fix floating warning log when the kick event is canceled (#12374)

This commit is contained in:
Pedro Aguiar
2025-04-22 06:44:55 -03:00
committed by GitHub
parent d22644aada
commit df429932ca
2 changed files with 16 additions and 5 deletions

View File

@@ -248,7 +248,7 @@
if (packet.isTerminal()) { if (packet.isTerminal()) {
this.close(); this.close();
} }
@@ -165,19 +_,108 @@ @@ -165,19 +_,115 @@
} }
} }
@@ -315,6 +315,13 @@
+ // Do not kick the player + // Do not kick the player
+ return; + return;
+ } + }
+
+ // Log kick to console *after* event was processed.
+ switch (cause) {
+ case FLYING_PLAYER -> LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString());
+ case FLYING_VEHICLE -> LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString());
+ }
+
+ // Send the possibly modified leave message + // Send the possibly modified leave message
+ this.disconnect0(new DisconnectionDetails(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.reason()), disconnectionDetails.report(), disconnectionDetails.bugReportLink()), event.leaveMessage()); // Paper - Adventure & use kick event leave message + this.disconnect0(new DisconnectionDetails(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.reason()), disconnectionDetails.report(), disconnectionDetails.bugReportLink()), event.leaveMessage()); // Paper - Adventure & use kick event leave message
+ } + }

View File

@@ -95,20 +95,24 @@
} }
@Override @Override
@@ -285,7 +_,7 @@ @@ -284,8 +_,8 @@
this.knownMovePacketCount = this.receivedMovePacketCount;
if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) {
if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) {
LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString()); - LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString());
- this.disconnect(Component.translatable("multiplayer.disconnect.flying")); - this.disconnect(Component.translatable("multiplayer.disconnect.flying"));
+ // LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString()); // Paper - Logging moved to net.minecraft.server.network.ServerCommonPacketListenerImpl.disconnect()
+ this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingPlayer, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_PLAYER); // Paper - use configurable kick message & kick event cause + this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingPlayer, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_PLAYER); // Paper - use configurable kick message & kick event cause
return; return;
} }
} else { } else {
@@ -304,7 +_,7 @@ @@ -303,8 +_,8 @@
this.vehicleLastGoodZ = this.lastVehicle.getZ();
if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) {
if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) {
LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString()); - LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString());
- this.disconnect(Component.translatable("multiplayer.disconnect.flying")); - this.disconnect(Component.translatable("multiplayer.disconnect.flying"));
+ // LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString()); // Paper - Logging moved to net.minecraft.server.network.ServerCommonPacketListenerImpl.disconnect()
+ this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingVehicle, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_VEHICLE); // Paper - use configurable kick message & kick event cause + this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingVehicle, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_VEHICLE); // Paper - use configurable kick message & kick event cause
return; return;
} }