diff --git a/patches/server/0010-Fakeplayer-support.patch b/patches/server/0010-Fakeplayer-support.patch index 855c7336..1b0c3789 100644 --- a/patches/server/0010-Fakeplayer-support.patch +++ b/patches/server/0010-Fakeplayer-support.patch @@ -4,6 +4,25 @@ Date: Thu, 3 Feb 2022 12:28:15 +0800 Subject: [PATCH] Fakeplayer support +diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java +index c0ea20dcee8bb293df96bc6ee019e50ad6b383fd..f265b3b3736de5ff3bc1b52146d11f92033730a5 100644 +--- a/src/main/java/net/minecraft/network/Connection.java ++++ b/src/main/java/net/minecraft/network/Connection.java +@@ -339,6 +339,14 @@ public class Connection extends SimpleChannelInboundHandler> { + } + } + ++ // Leaves start - fakeplayer ++ public void setListenerForce(PacketListener packetListener) { ++ Validate.notNull(packetListener, "packetListener"); ++ this.packetListener = packetListener; ++ this.disconnectListener = null; ++ } ++ // Leaves end - fakeplayer ++ + public void setListenerForServerboundHandshake(PacketListener packetListener) { + if (this.packetListener != null) { + throw new IllegalStateException("Listener already set"); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 68a242f6aaa4aeebff5c2c566ac2aab538eccc87..8e9f72fe364bc4ad51d7a235531af09df5cdcfa9 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java @@ -147,6 +166,25 @@ index d4aec99cac3f83d764e21946cc904c00e084704e..ae6fe20cac39766bd1cde1adfd93072c // CraftBukkit start PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); this.level().getCraftServer().getPluginManager().callEvent(changeEvent); +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 6c704b32091b2d7db742e1a68404ba6db1f9154f..72cfca4a310f7714c7e22be312175e7435051397 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -298,7 +298,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + this.lastSeenMessages = new LastSeenMessagesValidator(20); + this.messageSignatureCache = MessageSignatureCache.createDefault(); + this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection()); +- connection.setListener(this); ++ // Leaves start - fakeplayer ++ if (player instanceof top.leavesmc.leaves.bot.ServerBot) { ++ connection.setListenerForce(this); ++ } else { ++ connection.setListener(this); ++ } ++ // Leaves end - fakeplayer + this.player = player; + player.connection = this; + player.getTextFilter().join(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java index b58dea1fd418fa3199b403df079f87990ffdd6a8..cc610748dd0ae033c8e48d30f1077c1f9697dac3 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java @@ -384,6 +422,19 @@ index e932cfac619c30b8c7444a9fa41e0403a6eadf6a..8818daa3e89fd5a5b0a0ea4069ccbf0f else { return new CraftHumanEntity(server, (net.minecraft.world.entity.player.Player) entity); } } // Water Animals +diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +index c993fde1c026a270f370c437edba9e679aefb44f..342fd19005b8cfd8e9ca0d5bbbf2b07048703c86 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java ++++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +@@ -44,7 +44,7 @@ import org.bukkit.scheduler.BukkitWorker; + */ + public class CraftScheduler implements BukkitScheduler { + +- static Plugin MINECRAFT = new MinecraftInternalPlugin(); ++ public static Plugin MINECRAFT = new MinecraftInternalPlugin(); // Leaves - package -> public + /** + * The start ID for the counter. + */ diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java index ce9855b560ee6602983b2d05c9f80902674f248f..7963e2233d3ff3a511927109b5a35f511dcca2a6 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java @@ -1158,7 +1209,7 @@ index 0000000000000000000000000000000000000000..daaece30b2a3983f1cc9ee9a851e8f37 +} diff --git a/src/main/java/top/leavesmc/leaves/bot/ServerBot.java b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java new file mode 100644 -index 0000000000000000000000000000000000000000..ad84c8195ae21d1faf85a7bf7e97b8a6f6b02151 +index 0000000000000000000000000000000000000000..00de26efb99e8dbe163625d29e65a126073f0116 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java @@ -0,0 +1,710 @@ @@ -1213,6 +1264,7 @@ index 0000000000000000000000000000000000000000..ad84c8195ae21d1faf85a7bf7e97b8a6 +import org.bukkit.Material; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftPlayer; ++import org.bukkit.craftbukkit.scheduler.CraftScheduler; +import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.plugin.Plugin; @@ -1264,7 +1316,6 @@ index 0000000000000000000000000000000000000000..ad84c8195ae21d1faf85a7bf7e97b8a6 + private final BotInventoryContainer container; + + private static final List bots = new CopyOnWriteArrayList<>(); -+ private static final Plugin MINECRAFT_PLUGIN = new MinecraftInternalPlugin(); + + private ServerBot(MinecraftServer server, ServerLevel world, GameProfile profile) { + super(server, world, profile, ClientInformation.createDefault()); @@ -1305,7 +1356,7 @@ index 0000000000000000000000000000000000000000..ad84c8195ae21d1faf85a7bf7e97b8a6 + + ServerBot bot = new ServerBot(server, world, profile); + -+ bot.connection = new ServerGamePacketListenerImpl(server, new Connection(PacketFlow.CLIENTBOUND) { ++ bot.connection = new ServerGamePacketListenerImpl(server, new Connection(PacketFlow.SERVERBOUND) { + @Override + public void send(@NotNull Packet packet, @Nullable PacketSendListener packetsendlistener) { + } @@ -1374,7 +1425,7 @@ index 0000000000000000000000000000000000000000..ad84c8195ae21d1faf85a7bf7e97b8a6 + public void sendFakeData(ServerPlayerConnection playerConnection, boolean login) { + playerConnection.send(new ClientboundAddEntityPacket(this)); + if (login) { -+ Bukkit.getScheduler().runTaskLater(MINECRAFT_PLUGIN, () -> { ++ Bukkit.getScheduler().runTaskLater(CraftScheduler.MINECRAFT, () -> { + connection.send(new ClientboundRotateHeadPacket(this, (byte) ((getYRot() * 256f) / 360f))); + }, 10); + } else { @@ -1840,12 +1891,12 @@ index 0000000000000000000000000000000000000000..ad84c8195ae21d1faf85a7bf7e97b8a6 + } + + public void createAsync(Consumer consumer) { -+ Bukkit.getScheduler().runTaskAsynchronously(MINECRAFT_PLUGIN, () -> { ++ Bukkit.getScheduler().runTaskAsynchronously(CraftScheduler.MINECRAFT, () -> { + if (skinName != null) { + this.skin = MojangAPI.getSkin(skinName); + } + -+ Bukkit.getScheduler().runTask(MINECRAFT_PLUGIN, () -> { ++ Bukkit.getScheduler().runTask(CraftScheduler.MINECRAFT, () -> { + ServerBot bot = createBot(this); + if (bot != null && consumer != null) { + consumer.accept(bot); diff --git a/patches/server/0060-Disable-distance-check-for-UseItemOnPacket.patch b/patches/server/0060-Disable-distance-check-for-UseItemOnPacket.patch index 41def222..1a84dc11 100644 --- a/patches/server/0060-Disable-distance-check-for-UseItemOnPacket.patch +++ b/patches/server/0060-Disable-distance-check-for-UseItemOnPacket.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable distance check for UseItemOnPacket diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 6c704b32091b2d7db742e1a68404ba6db1f9154f..bc7f38c4bd20d6f77b2decee73965a9cf5c1f89d 100644 +index 72cfca4a310f7714c7e22be312175e7435051397..209511eb52fe815e7387bd2bf37497748af00119 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1895,7 +1895,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1901,7 +1901,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl Vec3 vec3d2 = vec3d.subtract(vec3d1); double d0 = 1.0000001D; diff --git a/patches/server/0064-Disable-check-out-of-order-command.patch b/patches/server/0064-Disable-check-out-of-order-command.patch index e1753ca1..5701a104 100644 --- a/patches/server/0064-Disable-check-out-of-order-command.patch +++ b/patches/server/0064-Disable-check-out-of-order-command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable check out-of-order command diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index bc7f38c4bd20d6f77b2decee73965a9cf5c1f89d..f5f80646848c47d047e97d1ef2a8000d0eaa4fc0 100644 +index 209511eb52fe815e7387bd2bf37497748af00119..8b072958aca8215e58e54fb2e64855b7632fbbf6 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2238,7 +2238,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2244,7 +2244,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } private Optional tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) { diff --git a/patches/server/0072-Elytra-aeronautics-no-chunk-load.patch b/patches/server/0072-Elytra-aeronautics-no-chunk-load.patch index e8438bca..7649082d 100644 --- a/patches/server/0072-Elytra-aeronautics-no-chunk-load.patch +++ b/patches/server/0072-Elytra-aeronautics-no-chunk-load.patch @@ -45,10 +45,10 @@ index ed2e0774d5b14d4926b3214ebf3795d7555327e3..0434bf9b8d3b064c8426d51f9969686a while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index f5f80646848c47d047e97d1ef2a8000d0eaa4fc0..c4eb2ae57967f0a16ef215c43255c8f8e13424eb 100644 +index 8b072958aca8215e58e54fb2e64855b7632fbbf6..84c481fe696b4d1da2ef01692e9347d0a9a8ecae 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -531,7 +531,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -537,7 +537,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl speed *= 2f; // TODO: Get the speed of the vehicle instead of the player // Paper start - Prevent moving into unloaded chunks diff --git a/patches/server/0092-Reduce-array-allocations.patch b/patches/server/0092-Reduce-array-allocations.patch index 81da26aa..b1adea9e 100644 --- a/patches/server/0092-Reduce-array-allocations.patch +++ b/patches/server/0092-Reduce-array-allocations.patch @@ -202,7 +202,7 @@ index ff13d67151c50ea11a45117e524c7524e2b1a202..c25d23c9c2ed887ce9ae7f07cd8aa0d1 @Override diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index c0ea20dcee8bb293df96bc6ee019e50ad6b383fd..4fe8b0341a5e4b243c3f11fa84dc37baf1a916cd 100644 +index f265b3b3736de5ff3bc1b52146d11f92033730a5..50c73aaf95df8cb993994c59d1d4ecdd97951772 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -57,6 +57,7 @@ import org.apache.commons.lang3.Validate; @@ -257,7 +257,7 @@ index 66b95197df737fac490a1b22949ab3855a7fce59..6e30d82b3216f8b7303b4c76d76f57a7 return ret; } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c4eb2ae57967f0a16ef215c43255c8f8e13424eb..b71e01ed840fafcace0a457fa098a482004b1aeb 100644 +index 84c481fe696b4d1da2ef01692e9347d0a9a8ecae..5753f163a46ae86a45cc363d7656841f552e49b9 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -239,6 +239,7 @@ import org.bukkit.inventory.EquipmentSlot; @@ -268,7 +268,7 @@ index c4eb2ae57967f0a16ef215c43255c8f8e13424eb..b71e01ed840fafcace0a457fa098a482 public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener { -@@ -770,13 +771,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -776,13 +777,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // Paper - run this async // CraftBukkit start if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable @@ -284,7 +284,7 @@ index c4eb2ae57967f0a16ef215c43255c8f8e13424eb..b71e01ed840fafcace0a457fa098a482 return; } // Paper end -@@ -3185,7 +3186,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3191,7 +3192,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Paper start if (!org.bukkit.Bukkit.isPrimaryThread()) { if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { diff --git a/patches/server/0124-Disable-moved-wrongly-threshold.patch b/patches/server/0124-Disable-moved-wrongly-threshold.patch index 2ade4aa2..c16ac698 100644 --- a/patches/server/0124-Disable-moved-wrongly-threshold.patch +++ b/patches/server/0124-Disable-moved-wrongly-threshold.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable moved wrongly threshold diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b71e01ed840fafcace0a457fa098a482004b1aeb..bdbce918c11fe2d912e246de331f6ca3e407bf5b 100644 +index 5753f163a46ae86a45cc363d7656841f552e49b9..a844eb5169d012fc6fe9e9adb1f60ee4846024a3 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -577,7 +577,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -583,7 +583,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl d10 = d6 * d6 + d7 * d7 + d8 * d8; boolean flag2 = false; @@ -17,7 +17,7 @@ index b71e01ed840fafcace0a457fa098a482004b1aeb..bdbce918c11fe2d912e246de331f6ca3 flag2 = true; // Paper - diff on change, this should be moved wrongly ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", new Object[]{entity.getName().getString(), this.player.getName().getString(), Math.sqrt(d10)}); } -@@ -1460,7 +1460,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1466,7 +1466,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl d10 = d6 * d6 + d7 * d7 + d8 * d8; boolean flag2 = false;