From 6796896e635055967a1675486cc6bc22718c75e4 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 16 Mar 2022 19:49:07 +1100 Subject: [PATCH] SPIGOT-3034: PlayerKickEvent.setLeaveMessage(String) doesn't actually do anything By: DerFrZocker --- .../minecraft/server/level/EntityPlayer.patch | 85 +++++++++-------- .../server/network/PlayerConnection.patch | 95 ++++++++++--------- .../minecraft/server/players/PlayerList.patch | 2 +- 3 files changed, 92 insertions(+), 90 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch index 40d484c6eb..1c395de475 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -34,7 +34,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -194,6 +221,20 @@ +@@ -194,6 +221,21 @@ public int latency; public boolean wonGame; @@ -50,12 +50,13 @@ + public boolean joining = true; + public boolean sentListPacket = false; + public Integer clientViewDistance; ++ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent + // CraftBukkit end + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) { super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -256,12 +297,56 @@ +@@ -256,12 +298,56 @@ this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this); this.maxUpStep = 1.0F; this.fudgeSpawnLocation(worldserver); @@ -113,7 +114,7 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -319,17 +404,26 @@ +@@ -319,17 +405,26 @@ if (nbttagcompound.contains("recipeBook", 10)) { this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); } @@ -141,7 +142,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -356,7 +450,20 @@ +@@ -356,7 +451,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -163,7 +164,7 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -374,7 +481,7 @@ +@@ -374,7 +482,7 @@ nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ()); nbttagcompound.putBoolean("SpawnForced", this.respawnForced); nbttagcompound.putFloat("SpawnAngle", this.respawnAngle); @@ -172,7 +173,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -382,9 +489,33 @@ +@@ -382,9 +490,33 @@ nbttagcompound.put("SpawnDimension", nbtbase); }); } @@ -206,7 +207,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -443,6 +574,11 @@ +@@ -443,6 +575,11 @@ @Override public void tick() { @@ -218,7 +219,7 @@ this.gameMode.tick(); --this.spawnInvulnerableTime; if (this.invulnerableTime > 0) { -@@ -498,7 +634,7 @@ +@@ -498,7 +635,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -227,7 +228,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -529,6 +665,12 @@ +@@ -529,6 +666,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -240,7 +241,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -543,6 +685,16 @@ +@@ -543,6 +686,16 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -257,7 +258,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -585,7 +737,8 @@ +@@ -585,7 +738,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -267,7 +268,7 @@ scoreboardscore.setScore(i); }); } -@@ -593,9 +746,47 @@ +@@ -593,9 +747,47 @@ @Override public void die(DamageSource damagesource) { boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -317,7 +318,7 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> { if (!future.isSuccess()) { -@@ -629,12 +820,18 @@ +@@ -629,12 +821,18 @@ if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -340,7 +341,7 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -671,10 +868,12 @@ +@@ -671,10 +869,12 @@ String s = this.getScoreboardName(); String s1 = entity.getScoreboardName(); @@ -355,7 +356,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -692,7 +891,8 @@ +@@ -692,7 +892,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -365,7 +366,7 @@ } } -@@ -736,18 +936,20 @@ +@@ -736,18 +937,20 @@ } private boolean isPvpAllowed() { @@ -389,7 +390,7 @@ } else { return shapedetectorshape; } -@@ -756,11 +958,20 @@ +@@ -756,11 +959,20 @@ @Nullable @Override public Entity changeDimension(WorldServer worldserver) { @@ -413,7 +414,7 @@ this.unRide(); this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.wonGame) { -@@ -771,6 +982,8 @@ +@@ -771,6 +983,8 @@ return this; } else { @@ -422,7 +423,7 @@ WorldData worlddata = worldserver.getLevelData(); this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); -@@ -780,22 +993,52 @@ +@@ -780,22 +994,52 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -481,7 +482,7 @@ worldserver1.getProfiler().pop(); this.triggerDimensionChangeTriggers(worldserver1); this.connection.send(new PacketPlayOutAbilities(this.getAbilities())); -@@ -813,12 +1056,31 @@ +@@ -813,12 +1057,31 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -513,7 +514,7 @@ private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) { BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); -@@ -835,17 +1097,17 @@ +@@ -835,17 +1098,17 @@ } @Override @@ -536,7 +537,7 @@ } return optional1; -@@ -855,13 +1117,21 @@ +@@ -855,13 +1118,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level.dimension(); @@ -561,7 +562,7 @@ this.enteredNetherPosition = null; } -@@ -878,12 +1148,10 @@ +@@ -878,12 +1149,10 @@ this.containerMenu.broadcastChanges(); } @@ -577,7 +578,7 @@ return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); } else if (!this.bedInRange(blockposition, enumdirection)) { return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY); -@@ -907,7 +1175,36 @@ +@@ -907,7 +1176,36 @@ } } @@ -615,7 +616,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -920,9 +1217,8 @@ +@@ -920,9 +1218,8 @@ return either; } } @@ -626,7 +627,7 @@ } @Override -@@ -949,6 +1245,24 @@ +@@ -949,6 +1246,24 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -651,7 +652,7 @@ if (this.isSleeping()) { this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2)); } -@@ -1030,8 +1344,9 @@ +@@ -1030,8 +1345,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos())); } @@ -662,7 +663,7 @@ } @Override -@@ -1039,13 +1354,35 @@ +@@ -1039,13 +1355,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -698,7 +699,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage((new ChatMessage("container.spectatorCantOpen")).withStyle(EnumChatFormat.RED), true); -@@ -1053,9 +1390,11 @@ +@@ -1053,9 +1391,11 @@ return OptionalInt.empty(); } else { @@ -712,7 +713,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1068,13 +1407,24 @@ +@@ -1068,13 +1408,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -739,7 +740,7 @@ this.initMenu(this.containerMenu); } -@@ -1097,6 +1447,7 @@ +@@ -1097,6 +1448,7 @@ @Override public void closeContainer() { @@ -747,7 +748,7 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1126,7 +1477,7 @@ +@@ -1126,7 +1478,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -756,7 +757,7 @@ scoreboardscore.add(i); }); } -@@ -1134,7 +1485,7 @@ +@@ -1134,7 +1486,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -765,7 +766,7 @@ } @Override -@@ -1150,7 +1501,7 @@ +@@ -1150,7 +1502,7 @@ for (int j = 0; j < i; ++j) { MinecraftKey minecraftkey = aminecraftkey1[j]; @@ -774,7 +775,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); -@@ -1185,8 +1536,17 @@ +@@ -1185,8 +1537,17 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -792,7 +793,7 @@ @Override public void displayClientMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.sendMessage(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT, SystemUtils.NIL_UUID); -@@ -1240,7 +1600,7 @@ +@@ -1240,7 +1601,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -801,7 +802,7 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); -@@ -1367,7 +1727,20 @@ +@@ -1367,7 +1728,20 @@ return s; } @@ -822,7 +823,7 @@ this.chatVisibility = packetplayinsettings.chatVisibility(); this.canChatColor = packetplayinsettings.chatColors(); this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled(); -@@ -1438,7 +1811,7 @@ +@@ -1438,7 +1812,7 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { this.connection.send(new PacketPlayOutCamera(this.camera)); @@ -831,7 +832,7 @@ } } -@@ -1467,7 +1840,7 @@ +@@ -1467,7 +1841,7 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -840,7 +841,7 @@ } @Override -@@ -1488,9 +1861,16 @@ +@@ -1488,9 +1862,16 @@ return this.advancements; } @@ -857,7 +858,7 @@ if (worldserver == this.level) { this.connection.teleport(d0, d1, d2, f, f1); } else { -@@ -1510,6 +1890,9 @@ +@@ -1510,6 +1891,9 @@ this.server.getPlayerList().sendLevelInfo(this, worldserver); this.server.getPlayerList().sendAllPlayerInfo(this); } @@ -867,7 +868,7 @@ } -@@ -1668,4 +2051,145 @@ +@@ -1668,4 +2052,145 @@ public boolean allowsListing() { return this.allowsListing; } diff --git a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch index 099055718f..2a9927e4d8 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -137,7 +137,7 @@ this.disconnect(new ChatMessage("multiplayer.disconnect.idling")); } -@@ -296,16 +384,46 @@ +@@ -296,16 +384,47 @@ return this.server.isSingleplayerOwner(this.player.getGameProfile()); } @@ -165,6 +165,7 @@ + // Do not kick the player + return; + } ++ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent + // Send the possibly modified leave message + s = event.getReason(); + final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(s, true)[0]; @@ -185,7 +186,7 @@ } private void filterTextPacket(T t0, Consumer consumer, BiFunction> bifunction) { -@@ -376,7 +494,34 @@ +@@ -376,7 +495,34 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -221,7 +222,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.connection.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -408,14 +553,72 @@ +@@ -408,14 +554,72 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -294,7 +295,7 @@ this.player.getLevel().getChunkSource().move(this.player); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); -@@ -434,7 +637,7 @@ +@@ -434,7 +638,7 @@ @Override public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel()); @@ -303,7 +304,7 @@ this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.lastGoodX = this.awaitingPositionFromClient.x; this.lastGoodY = this.awaitingPositionFromClient.y; -@@ -444,6 +647,7 @@ +@@ -444,6 +648,7 @@ } this.awaitingPositionFromClient = null; @@ -311,7 +312,7 @@ } } -@@ -451,7 +655,7 @@ +@@ -451,7 +656,7 @@ @Override public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel()); @@ -320,7 +321,7 @@ RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -481,6 +685,12 @@ +@@ -481,6 +686,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel()); @@ -333,7 +334,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -490,6 +700,7 @@ +@@ -490,6 +701,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -341,7 +342,7 @@ this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); }); } -@@ -722,6 +933,13 @@ +@@ -722,6 +934,13 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -355,7 +356,7 @@ containermerchant.setSelectionHint(i); containermerchant.tryMoveItems(i); -@@ -731,6 +949,13 @@ +@@ -731,6 +950,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -369,7 +370,7 @@ int i = packetplayinbedit.getSlot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -739,7 +964,7 @@ +@@ -739,7 +965,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); @@ -378,7 +379,7 @@ Objects.requireNonNull(list); stream.forEach(list::add); -@@ -755,7 +980,7 @@ +@@ -755,7 +981,7 @@ ItemStack itemstack = this.player.getInventory().getItem(i); if (itemstack.is(Items.WRITABLE_BOOK)) { @@ -387,7 +388,7 @@ } } -@@ -780,16 +1005,16 @@ +@@ -780,16 +1006,16 @@ this.updateBookPages(list, (s) -> { return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s)); @@ -408,7 +409,7 @@ return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered())); }); -@@ -817,6 +1042,7 @@ +@@ -817,6 +1043,7 @@ } itemstack.addTagElement("pages", nbttaglist); @@ -416,7 +417,7 @@ } @Override -@@ -853,7 +1079,7 @@ +@@ -853,7 +1080,7 @@ } else { WorldServer worldserver = this.player.getLevel(); @@ -425,7 +426,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -863,7 +1089,7 @@ +@@ -863,7 +1090,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -434,7 +435,7 @@ } else { this.awaitingTeleportTime = this.tickCount; double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); -@@ -875,7 +1101,15 @@ +@@ -875,7 +1102,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.getLevel().getChunkSource().move(this.player); @@ -450,7 +451,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -895,15 +1129,33 @@ +@@ -895,15 +1130,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -486,7 +487,7 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -924,6 +1176,7 @@ +@@ -924,6 +1177,7 @@ boolean flag1 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); @@ -494,7 +495,7 @@ double d12 = d8; d7 = d0 - this.player.getX(); -@@ -945,6 +1198,69 @@ +@@ -945,6 +1199,69 @@ if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { this.teleport(d3, d4, d5, f, f1); } else { @@ -564,7 +565,7 @@ this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player); this.player.getLevel().getChunkSource().move(this.player); this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); -@@ -983,19 +1299,80 @@ +@@ -983,19 +1300,80 @@ return true; } @@ -649,7 +650,7 @@ double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D; -@@ -1007,6 +1384,14 @@ +@@ -1007,6 +1385,14 @@ this.awaitingTeleport = 0; } @@ -664,7 +665,7 @@ this.awaitingTeleportTime = this.tickCount; this.player.absMoveTo(d0, d1, d2, f, f1); this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); -@@ -1015,6 +1400,7 @@ +@@ -1015,6 +1401,7 @@ @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel()); @@ -672,7 +673,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1025,14 +1411,46 @@ +@@ -1025,14 +1412,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -721,7 +722,7 @@ this.player.drop(false); } -@@ -1069,6 +1487,7 @@ +@@ -1069,6 +1488,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel()); @@ -729,7 +730,7 @@ WorldServer worldserver = this.player.getLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); ItemStack itemstack = this.player.getItemInHand(enumhand); -@@ -1088,6 +1507,7 @@ +@@ -1088,6 +1508,7 @@ if (blockposition.getY() < i) { if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { @@ -737,7 +738,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { -@@ -1117,12 +1537,51 @@ +@@ -1117,12 +1538,51 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel()); @@ -789,7 +790,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.shouldSwing()) { -@@ -1143,7 +1602,7 @@ +@@ -1143,7 +1603,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -798,7 +799,7 @@ return; } } -@@ -1158,6 +1617,7 @@ +@@ -1158,6 +1618,7 @@ PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect")); } @@ -806,7 +807,7 @@ } -@@ -1177,11 +1637,26 @@ +@@ -1177,11 +1638,26 @@ @Override public void onDisconnect(IChatBaseComponent ichatbasecomponent) { @@ -834,7 +835,7 @@ this.player.getTextFilter().leave(); if (this.isSingleplayerOwner()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); -@@ -1196,6 +1671,15 @@ +@@ -1196,6 +1672,15 @@ } public void send(Packet packet, @Nullable GenericFutureListener> genericfuturelistener) { @@ -850,7 +851,7 @@ try { this.connection.send(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -1212,7 +1696,16 @@ +@@ -1212,7 +1697,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel()); @@ -867,7 +868,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1221,11 +1714,18 @@ +@@ -1221,11 +1715,18 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -886,7 +887,7 @@ String s = StringUtils.normalizeSpace(packetplayinchat.getMessage()); for (int i = 0; i < s.length(); ++i) { -@@ -1239,20 +1739,42 @@ +@@ -1239,20 +1740,42 @@ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel()); this.handleChat(ITextFilter.a.passThrough(s)); } else { @@ -933,7 +934,7 @@ } else { String s1 = itextfilter_a.getFiltered(); ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1}); -@@ -1263,28 +1785,198 @@ +@@ -1263,28 +1786,198 @@ }, ChatMessageType.CHAT, this.player.getUUID()); } @@ -1136,7 +1137,7 @@ this.player.resetLastActionTime(); IJumpable ijumpable; -@@ -1342,6 +2034,7 @@ +@@ -1342,6 +2035,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel()); @@ -1144,7 +1145,7 @@ WorldServer worldserver = this.player.getLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1356,10 +2049,44 @@ +@@ -1356,10 +2050,44 @@ if (this.player.distanceToSqr(entity) < 36.0D) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { @@ -1190,7 +1191,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity); if (enuminteractionresult.shouldSwing()) { -@@ -1371,20 +2098,27 @@ +@@ -1371,20 +2099,27 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1221,7 +1222,7 @@ } else { PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString()); -@@ -1429,15 +2163,21 @@ +@@ -1429,15 +2164,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); @@ -1245,7 +1246,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else { int i = packetplayinwindowclick.getSlotNum(); -@@ -1448,7 +2188,284 @@ +@@ -1448,7 +2189,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1531,7 +1532,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1484,6 +2501,7 @@ +@@ -1484,6 +2502,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel()); @@ -1539,7 +1540,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { boolean flag = this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId()); -@@ -1514,6 +2532,43 @@ +@@ -1514,6 +2533,43 @@ boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1583,7 +1584,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack); -@@ -1536,6 +2591,7 @@ +@@ -1536,6 +2592,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1591,7 +1592,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.getLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1552,18 +2608,37 @@ +@@ -1552,18 +2609,37 @@ if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) { PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString()); @@ -1631,7 +1632,7 @@ tileentitysign.setChanged(); worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -1573,6 +2648,7 @@ +@@ -1573,6 +2649,7 @@ @Override public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1639,7 +1640,7 @@ if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) { int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -1587,7 +2663,17 @@ +@@ -1587,7 +2664,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel()); @@ -1658,7 +1659,7 @@ } @Override -@@ -1596,8 +2682,50 @@ +@@ -1596,8 +2683,50 @@ this.player.updateOptions(packetplayinsettings); } diff --git a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch index f8afbdfdaf..641b8f05c5 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -274,7 +274,7 @@ + entityplayer.closeContainer(); + } + -+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); ++ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), entityplayer.kickLeaveMessage != null ? entityplayer.kickLeaveMessage : "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); + cserver.getPluginManager().callEvent(playerQuitEvent); + entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); +