diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 712b8abb64..64b6831c16 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -112,10 +112,11 @@ @Nullable private Vec3 startingToFallPosition; @Nullable -@@ -259,6 +292,22 @@ +@@ -258,6 +291,22 @@ + private final CommandSource commandSource; private int containerCounter; public boolean wonGame; - ++ + // CraftBukkit start + public CraftPlayer.TransferCookieConnection transferCookieConnection; + public String displayName; @@ -131,10 +132,9 @@ + public boolean sentListPacket = false; + public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent + // CraftBukkit end -+ + public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); - this.chatVisibility = ChatVisiblity.FULL; @@ -340,6 +389,13 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); @@ -158,8 +158,8 @@ + this.displayName = this.getScoreboardName(); + this.bukkitPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); - } - ++ } ++ + // Use method to resend items in hands in case of client desync, because the item use got cancelled. + // For example, when cancelling the leash event + public void resendItemInHands() { @@ -205,9 +205,9 @@ + } + + return blockposition; -+ } + } + // CraftBukkit end -+ + @Override public BlockPos adjustSpawnLocation(ServerLevel world, BlockPos basePos) { AABB axisalignedbb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO); @@ -588,7 +588,7 @@ if (!this.canHarmPlayer(entityhuman1)) { return false; -@@ -1088,33 +1322,58 @@ +@@ -1088,33 +1322,63 @@ } @Override @@ -646,6 +646,11 @@ + + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn, isAnchorSpawn, reason); + this.level().getCraftServer().getPluginManager().callEvent(respawnEvent); ++ // Spigot Start ++ if (this.connection.isDisconnected()) { ++ return null; ++ } ++ // Spigot End + + location = respawnEvent.getRespawnLocation(); + @@ -654,7 +659,7 @@ } public static Optional findRespawnAndUseSpawnBlock(ServerLevel world, BlockPos pos, float spawnAngle, boolean spawnForced, boolean alive) { -@@ -1129,11 +1388,11 @@ +@@ -1129,11 +1393,11 @@ } return optional.map((vec3d) -> { @@ -668,7 +673,7 @@ }); } else if (!spawnForced) { return Optional.empty(); -@@ -1142,7 +1401,7 @@ +@@ -1142,7 +1406,7 @@ BlockState iblockdata1 = world.getBlockState(pos.above()); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); @@ -677,7 +682,7 @@ } } -@@ -1160,6 +1419,7 @@ +@@ -1160,6 +1424,7 @@ @Nullable @Override public ServerPlayer teleport(TeleportTransition teleportTarget) { @@ -685,7 +690,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1169,39 +1429,73 @@ +@@ -1169,39 +1434,73 @@ ServerLevel worldserver = teleportTarget.newLevel(); ServerLevel worldserver1 = this.serverLevel(); @@ -767,7 +772,7 @@ this.connection.resetPosition(); worldserver.addDuringTeleport(this); gameprofilerfiller.pop(); -@@ -1215,12 +1509,30 @@ +@@ -1215,12 +1514,30 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -798,7 +803,7 @@ public void forceSetRotation(float yaw, float pitch) { this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch)); } -@@ -1228,13 +1540,21 @@ +@@ -1228,13 +1545,21 @@ public void triggerDimensionChangeTriggers(ServerLevel origin) { ResourceKey resourcekey = origin.dimension(); ResourceKey resourcekey1 = this.level().dimension(); @@ -823,7 +828,7 @@ this.enteredNetherPosition = null; } -@@ -1251,36 +1571,63 @@ +@@ -1251,36 +1576,63 @@ this.containerMenu.broadcastChanges(); } @@ -902,7 +907,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1293,9 +1640,8 @@ +@@ -1293,9 +1645,8 @@ return either; } } @@ -913,7 +918,7 @@ } @Override -@@ -1322,13 +1668,31 @@ +@@ -1322,13 +1673,31 @@ @Override public void stopSleepInBed(boolean skipSleepTimer, boolean updateSleepingPlayers) { @@ -946,7 +951,7 @@ } } -@@ -1387,8 +1751,9 @@ +@@ -1387,8 +1756,9 @@ this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front)); } @@ -957,7 +962,7 @@ } @Override -@@ -1396,13 +1761,35 @@ +@@ -1396,13 +1766,35 @@ if (factory == null) { return OptionalInt.empty(); } else { @@ -993,7 +998,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1410,9 +1797,11 @@ +@@ -1410,9 +1802,11 @@ return OptionalInt.empty(); } else { @@ -1007,7 +1012,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1425,15 +1814,26 @@ +@@ -1425,15 +1819,26 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1036,7 +1041,7 @@ this.initMenu(this.containerMenu); } -@@ -1456,6 +1856,7 @@ +@@ -1456,6 +1861,7 @@ @Override public void closeContainer() { @@ -1044,7 +1049,7 @@ this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1485,19 +1886,19 @@ +@@ -1485,19 +1891,19 @@ i = Math.round((float) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) * 100.0F); if (i > 0) { this.awardStat(Stats.SWIM_ONE_CM, i); @@ -1067,7 +1072,7 @@ } } else if (this.onClimbable()) { if (deltaY > 0.0D) { -@@ -1508,13 +1909,13 @@ +@@ -1508,13 +1914,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, i); @@ -1084,7 +1089,7 @@ } } } else if (this.isFallFlying()) { -@@ -1557,7 +1958,7 @@ +@@ -1557,7 +1963,7 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1093,7 +1098,7 @@ scoreaccess.add(amount); }); } -@@ -1565,7 +1966,7 @@ +@@ -1565,7 +1971,7 @@ @Override public void resetStat(Stat stat) { this.stats.setValue(this, stat, 0); @@ -1102,7 +1107,7 @@ } @Override -@@ -1597,9 +1998,9 @@ +@@ -1597,9 +2003,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1114,7 +1119,7 @@ } } -@@ -1625,6 +2026,7 @@ +@@ -1625,6 +2031,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1122,7 +1127,7 @@ } @Override -@@ -1661,7 +2063,7 @@ +@@ -1661,7 +2068,7 @@ this.onUpdateAbilities(); if (alive) { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1131,7 +1136,7 @@ this.setHealth(oldPlayer.getHealth()); this.foodData = oldPlayer.foodData; Iterator iterator = oldPlayer.getActiveEffects().iterator(); -@@ -1669,7 +2071,7 @@ +@@ -1669,7 +2076,7 @@ while (iterator.hasNext()) { MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); @@ -1140,7 +1145,7 @@ } this.getInventory().replaceWith(oldPlayer.getInventory()); -@@ -1680,7 +2082,7 @@ +@@ -1680,7 +2087,7 @@ this.portalProcess = oldPlayer.portalProcess; } else { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1149,7 +1154,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) { this.getInventory().replaceWith(oldPlayer.getInventory()); this.experienceLevel = oldPlayer.experienceLevel; -@@ -1696,7 +2098,7 @@ +@@ -1696,7 +2103,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1158,7 +1163,7 @@ this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1752,19 +2154,19 @@ +@@ -1752,19 +2159,19 @@ } @Override @@ -1182,7 +1187,7 @@ } return flag1; -@@ -1878,6 +2280,16 @@ +@@ -1878,6 +2285,16 @@ } public void updateOptions(ClientInformation clientOptions) { @@ -1199,7 +1204,7 @@ this.language = clientOptions.language(); this.requestedViewDistance = clientOptions.viewDistance(); this.chatVisibility = clientOptions.chatVisibility(); -@@ -1962,7 +2374,7 @@ +@@ -1962,7 +2379,7 @@ if (world instanceof ServerLevel) { ServerLevel worldserver = (ServerLevel) world; @@ -1208,7 +1213,7 @@ } if (entity != null) { -@@ -1999,11 +2411,11 @@ +@@ -1999,11 +2416,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1222,7 +1227,7 @@ } @Override -@@ -2046,17 +2458,43 @@ +@@ -2046,17 +2463,43 @@ } public void setRespawnPosition(ResourceKey dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) { @@ -1273,7 +1278,7 @@ } else { this.respawnPosition = null; this.respawnDimension = Level.OVERWORLD; -@@ -2088,18 +2526,44 @@ +@@ -2088,18 +2531,44 @@ } @Override @@ -1322,7 +1327,7 @@ } this.awardStat(Stats.DROP); -@@ -2375,16 +2839,160 @@ +@@ -2375,16 +2844,160 @@ return TicketType.ENDER_PEARL.timeout(); } @@ -1355,8 +1360,8 @@ + } else { + // Adds timeOffset to the beginning of this day. + return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset; -+ } -+ } + } + } + + public WeatherType weather = null; + @@ -1394,7 +1399,7 @@ + if (this.pluginRainPositionPrevious != this.pluginRainPosition) { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.pluginRainPosition)); + } - } ++ } + + if (oldThunder != newThunder) { + if (this.weather == WeatherType.DOWNFALL || this.weather == null) { @@ -1403,7 +1408,7 @@ + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, 0)); + } + } - } ++ } + + public void tickWeather() { + if (this.weather == null) return; diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 9f09135530..5e6ac65602 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -460,11 +460,10 @@ } - return ichatmutablecomponent; -- } else { -- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(profile) ? Component.translatable("multiplayer.disconnect.server_full") : null; + // return chatmessage; + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent)); -+ } else { + } else { +- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(profile) ? Component.translatable("multiplayer.disconnect.server_full") : null; + // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; + if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot @@ -574,7 +573,7 @@ while (iterator.hasNext()) { String s = (String) iterator.next(); -@@ -462,41 +662,81 @@ +@@ -462,41 +662,86 @@ entityplayer1.addTag(s); } @@ -587,6 +586,11 @@ + } else { + teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); + } ++ // Spigot Start ++ if (teleporttransition == null) { ++ return entityplayer; ++ } ++ // Spigot End + ServerLevel worldserver = teleporttransition.newLevel(); + entityplayer1.spawnIn(worldserver); + entityplayer1.unsetRemoved(); @@ -664,7 +668,7 @@ return entityplayer1; } -@@ -524,7 +764,18 @@ +@@ -524,7 +769,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { @@ -684,7 +688,7 @@ this.sendAllPlayerInfoIn = 0; } -@@ -541,6 +792,25 @@ +@@ -541,6 +797,25 @@ } @@ -710,7 +714,7 @@ public void broadcastAll(Packet packet, ResourceKey dimension) { Iterator iterator = this.players.iterator(); -@@ -554,7 +824,7 @@ +@@ -554,7 +829,7 @@ } @@ -719,7 +723,7 @@ PlayerTeam scoreboardteam = source.getTeam(); if (scoreboardteam != null) { -@@ -573,7 +843,7 @@ +@@ -573,7 +848,7 @@ } } @@ -728,7 +732,7 @@ PlayerTeam scoreboardteam = source.getTeam(); if (scoreboardteam == null) { -@@ -619,7 +889,7 @@ +@@ -619,7 +894,7 @@ } public void deop(GameProfile profile) { @@ -737,7 +741,7 @@ ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { -@@ -643,6 +913,7 @@ +@@ -643,6 +918,7 @@ player.connection.send(new ClientboundEntityEventPacket(player, b0)); } @@ -745,7 +749,7 @@ this.server.getCommands().sendCommands(player); } -@@ -669,10 +940,16 @@ +@@ -669,10 +945,16 @@ return null; } @@ -763,7 +767,7 @@ if (entityplayer != player && entityplayer.level().dimension() == worldKey) { double d4 = x - entityplayer.getX(); double d5 = y - entityplayer.getY(); -@@ -712,15 +989,19 @@ +@@ -712,15 +994,19 @@ public void reloadWhiteList() {} public void sendLevelInfo(ServerPlayer player, ServerLevel world) { @@ -787,7 +791,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -729,8 +1010,16 @@ +@@ -729,8 +1015,16 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -805,7 +809,7 @@ } public int getPlayerCount() { -@@ -786,12 +1075,22 @@ +@@ -786,12 +1080,22 @@ } public void removeAll() { @@ -830,7 +834,7 @@ public void broadcastSystemMessage(Component message, boolean overlay) { this.broadcastSystemMessage(message, (entityplayer) -> { return message; -@@ -849,16 +1148,23 @@ +@@ -849,16 +1153,23 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -858,7 +862,7 @@ Path path = file2.toPath(); if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -867,7 +1173,7 @@ +@@ -867,7 +1178,7 @@ } serverstatisticmanager = new ServerStatsCounter(this.server, file1); @@ -867,7 +871,7 @@ } return serverstatisticmanager; -@@ -875,13 +1181,13 @@ +@@ -875,13 +1186,13 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -883,7 +887,7 @@ } advancementdataplayer.setPlayer(player); -@@ -932,15 +1238,28 @@ +@@ -932,15 +1243,28 @@ } public void reloadResources() {