Compare commits
4 Commits
1.20.2-771
...
1.20.4-773
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0872f03352 | ||
|
|
f5550b8cc1 | ||
|
|
909b208b67 | ||
|
|
b159640ebe |
@@ -4,8 +4,21 @@ Date: Tue, 30 Jan 2024 08:59:03 +0000
|
||||
Subject: [PATCH] Leaves fakeplayer support
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionShutdownThread.java b/src/main/java/io/papermc/paper/threadedregions/RegionShutdownThread.java
|
||||
index 2b48833023771fa965f131890ade98e9da3f5976..75c16116f684d434c1aa554d8ed13a638751772a 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionShutdownThread.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionShutdownThread.java
|
||||
@@ -124,6 +124,8 @@ public final class RegionShutdownThread extends TickThread {
|
||||
|
||||
@Override
|
||||
public final void run() {
|
||||
+ top.leavesmc.leaves.bot.ServerBot.saveOrRemoveAllBot(); // Leaves - save or remove bot
|
||||
+
|
||||
// await scheduler termination
|
||||
LOGGER.info("Awaiting scheduler termination for 60s");
|
||||
if (TickRegions.getScheduler().halt(true, TimeUnit.SECONDS.toNanos(60L))) {
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index e531453e3d25700e38ff41548c7e32e278a6304d..f924a238f211c22a00b8df67a209dcfea751039c 100644
|
||||
index e531453e3d25700e38ff41548c7e32e278a6304d..610642b0a0c3f17c66ec27ed812b97c68cee1be6 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -78,7 +78,17 @@ public class LuminolConfig {
|
||||
@@ -39,7 +52,7 @@ index e531453e3d25700e38ff41548c7e32e278a6304d..f924a238f211c22a00b8df67a209dcfe
|
||||
+ fakeplayerSkipSleep = get("gameplay.fakeplayer.fakeplayer_skip_sleep",fakeplayerSkipSleep);
|
||||
+ fakeplayerResident = get("gameplay.fakeplayer.resident",fakeplayerResident);
|
||||
+ fakeplayerSpawnPhantom = get("gameplay.fakeplayer.spawn_phantom_for_fakeplayer",fakeplayerSpawnPhantom);
|
||||
+ fakeplayerRegenAmount = get("gameplay.fakeplayer.regen_amount",fakeplayerRegenAmount);
|
||||
+ fakeplayerRegenAmount = Double.parseDouble(get("gameplay.fakeplayer.regen_amount",String.valueOf(fakeplayerRegenAmount)));
|
||||
+ unableFakeplayerNames = get("gameplay.fakeplayer.name_black_list",unableFakeplayerNames);
|
||||
+
|
||||
+ if (fakeplayerSupport){
|
||||
@@ -1206,10 +1219,10 @@ 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..dcdc4fac1bf972085ea4cd789efd27370410e5e1
|
||||
index 0000000000000000000000000000000000000000..35eecd67a743643496959d6eaeaf10a485aa651a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
|
||||
@@ -0,0 +1,715 @@
|
||||
@@ -0,0 +1,734 @@
|
||||
+package top.leavesmc.leaves.bot;
|
||||
+
|
||||
+import com.google.common.collect.Lists;
|
||||
@@ -1219,6 +1232,7 @@ index 0000000000000000000000000000000000000000..dcdc4fac1bf972085ea4cd789efd2737
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import com.mojang.authlib.properties.Property;
|
||||
+import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
+import io.papermc.paper.util.TickThread;
|
||||
+import net.minecraft.Util;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.network.Connection;
|
||||
@@ -1291,6 +1305,7 @@ index 0000000000000000000000000000000000000000..dcdc4fac1bf972085ea4cd789efd2737
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.UUID;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.concurrent.CopyOnWriteArrayList;
|
||||
+import java.util.function.Consumer;
|
||||
+
|
||||
@@ -1833,11 +1848,28 @@ index 0000000000000000000000000000000000000000..dcdc4fac1bf972085ea4cd789efd2737
|
||||
+ }
|
||||
+
|
||||
+ public static boolean removeAllBot() {
|
||||
+ Iterator<ServerBot> iterator = bots.iterator();
|
||||
+ while (iterator.hasNext()) {
|
||||
+ ServerBot bot = iterator.next();
|
||||
+ bot.die(bot.damageSources().fellOutOfWorld());
|
||||
+ }
|
||||
+ CompletableFuture.allOf(
|
||||
+ bots.stream()
|
||||
+ .map(bot ->{
|
||||
+ if (TickThread.isTickThreadFor(bot)){
|
||||
+ bot.die(bot.damageSources().fellOutOfWorld());
|
||||
+ return CompletableFuture.completedFuture(null);
|
||||
+ }
|
||||
+
|
||||
+ return CompletableFuture.runAsync(()->{
|
||||
+ bot.die(bot.damageSources().fellOutOfWorld());
|
||||
+ }, task ->
|
||||
+ RegionizedServer.getInstance().taskQueue.queueTickTaskQueue(
|
||||
+ bot.serverLevel(),
|
||||
+ bot.sectionX,
|
||||
+ bot.sectionZ,
|
||||
+ task
|
||||
+ )
|
||||
+ );
|
||||
+ })
|
||||
+ .toArray(CompletableFuture[]::new)
|
||||
+ ).join();
|
||||
+ bots.clear();
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
|
||||
@@ -17,7 +17,7 @@ index 8a926993088d33983f75071b3320dd67c3e857c3..aa1033e0de7d59c32acd2afa58c0b916
|
||||
// Paper end
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index f924a238f211c22a00b8df67a209dcfea751039c..740c1de1d61cb047139cadac041b381cb976de5f 100644
|
||||
index 610642b0a0c3f17c66ec27ed812b97c68cee1be6..87f5c0fc3f92feecb167c3e28d86a67ba848cb61 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -37,6 +37,7 @@ public class LuminolConfig {
|
||||
@@ -37,7 +37,7 @@ index f924a238f211c22a00b8df67a209dcfea751039c..740c1de1d61cb047139cadac041b381c
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
index 81090d1b5d67506268a41c6387a1d45302e88a5c..7bdf3a669c5b7a6b0dd71b94ce56a5beda38d29d 100644
|
||||
index 81090d1b5d67506268a41c6387a1d45302e88a5c..637d321b75dc7b5653ff9aa6134f900c634a19d8 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
@@ -20,9 +20,11 @@ import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
@@ -73,19 +73,29 @@ index 81090d1b5d67506268a41c6387a1d45302e88a5c..7bdf3a669c5b7a6b0dd71b94ce56a5be
|
||||
public ServerConnectionListener(MinecraftServer server) {
|
||||
this.server = server;
|
||||
this.running = true;
|
||||
@@ -100,7 +108,15 @@ public class ServerConnectionListener {
|
||||
@@ -89,8 +97,14 @@ public class ServerConnectionListener {
|
||||
synchronized (this.channels) {
|
||||
Class oclass;
|
||||
EventLoopGroup eventloopgroup;
|
||||
-
|
||||
- if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ //Luminol start - io_uring support
|
||||
+ if (IOUring.isAvailable() && LuminolConfig.enableIoUring){
|
||||
+ eventloopgroup = SERVER_IO_URING_WORKER_GROUP.get();
|
||||
+ oclass = IOUringServerSocketChannel.class;
|
||||
+ ServerConnectionListener.LOGGER.info("Using io_uring channel type");
|
||||
+ }
|
||||
+ else if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ //Luminol end
|
||||
// Paper start
|
||||
if (address instanceof io.netty.channel.unix.DomainSocketAddress) {
|
||||
oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class;
|
||||
@@ -100,7 +114,8 @@ public class ServerConnectionListener {
|
||||
// Paper end
|
||||
eventloopgroup = (EventLoopGroup) ServerConnectionListener.SERVER_EPOLL_EVENT_GROUP.get();
|
||||
ServerConnectionListener.LOGGER.info("Using epoll channel type");
|
||||
- } else {
|
||||
+ }
|
||||
+ //Luminol start - io_uring support
|
||||
+ else if (IOUring.isAvailable() && LuminolConfig.enableIoUring){
|
||||
+ eventloopgroup = SERVER_IO_URING_WORKER_GROUP.get();
|
||||
+ oclass = IOUringServerSocketChannel.class;
|
||||
+ ServerConnectionListener.LOGGER.info("Using io_uring channel type");
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+ else {
|
||||
oclass = NioServerSocketChannel.class;
|
||||
eventloopgroup = (EventLoopGroup) ServerConnectionListener.SERVER_EVENT_GROUP.get();
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Thu, 1 Feb 2024 09:51:45 +0000
|
||||
Subject: [PATCH] Prevent teleportAsync calling during moving event being
|
||||
handled
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 87f5c0fc3f92feecb167c3e28d86a67ba848cb61..0a1a8016f5e51163c2c375a9444d68d3d68544d1 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -46,6 +46,8 @@ public class LuminolConfig {
|
||||
public static boolean useVanillaRandomSource = false;
|
||||
public static boolean fixLargePosMoving = false;
|
||||
public static boolean warnOnLargeMovingDetected = true;
|
||||
+ public static boolean preventTeleportAsyncDuringMovingEvent = false;
|
||||
+ public static boolean throwOnPreventingTeleportAsync = true;
|
||||
|
||||
public static RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||
public static int regionFormatLinearCompressionLevel = 1;
|
||||
@@ -199,6 +201,8 @@ public class LuminolConfig {
|
||||
useVanillaRandomSource = get("fixes.use_vanilla_random_source",useVanillaRandomSource,"RNG feature related");
|
||||
fixLargePosMoving = get("fixes.fix_large_pos_moving", fixLargePosMoving,"Fix an entity moving issue on folia which is not fixed yet");
|
||||
warnOnLargeMovingDetected = get("fixes.warn_on_large_pos_moving",warnOnLargeMovingDetected);
|
||||
+ preventTeleportAsyncDuringMovingEvent = get("fixes.prevent_teleportasync_during_moving_event",preventTeleportAsyncDuringMovingEvent);
|
||||
+ throwOnPreventingTeleportAsync = get("fixes.throw_on_preventing_async_teleport",throwOnPreventingTeleportAsync);
|
||||
|
||||
regionFormatName = RegionFileFormat.fromString(get("save.region-format.format", regionFormatName.name()));
|
||||
if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index ea409d2a03c35990c6857c24305346a6ec7f4bf8..33d2205ba32dd1e11bba92e40d6a4125379b715f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -326,6 +326,10 @@ public class ServerPlayer extends Player {
|
||||
public double lastEntitySpawnRadiusSquared = -1.0;
|
||||
// Paper end - optimise chunk tick iteration
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ public boolean handlingMoveEvent = false;
|
||||
+ //Luminol end
|
||||
+
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
this.chatVisibility = ChatVisiblity.FULL;
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 18745ee33843d668613fd9e7f15d6a79f118280f..9f7eedbac2cbccba4e4cf5e0059cf3a4248438f1 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -688,7 +688,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
if (true) { // Spigot - don't skip any move events
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ this.player.handlingMoveEvent = true; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
+ this.player.handlingMoveEvent = false; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
@@ -1592,7 +1594,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
if (from.getX() != Double.MAX_VALUE) {
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ this.player.handlingMoveEvent = true; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
+ this.player.handlingMoveEvent = false; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index e24b55dc96c2e3904e3c03d6bfa769aedf767b3b..1e5eb1277e1b4f2ba51fadbe2d882198ae940ae0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3950,6 +3950,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
java.util.function.Consumer<Entity> teleportComplete) {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async");
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ if (this instanceof ServerPlayer player && LuminolConfig.preventTeleportAsyncDuringMovingEvent){
|
||||
+ if (player.handlingMoveEvent){
|
||||
+ if (LuminolConfig.throwOnPreventingTeleportAsync){
|
||||
+ throw new IllegalStateException("Player " + player.getScoreboardName() + " is trying to teleport to " + pos + " during move event handling!");
|
||||
+ }
|
||||
+ MinecraftServer.LOGGER.warn("Player {} is trying to teleport to {} during move event handling!",player.getScoreboardName(),pos);
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
if (!ServerLevel.isInSpawnableBounds(new BlockPos(io.papermc.paper.util.CoordinateUtils.getBlockX(pos), io.papermc.paper.util.CoordinateUtils.getBlockY(pos), io.papermc.paper.util.CoordinateUtils.getBlockZ(pos)))) {
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index 44a6118d3bd67a95180f750c17967561946e2e87..509a556baafd46356243cc783cf1edb4e7a61bb6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -426,7 +428,21 @@ public abstract class AbstractMinecart extends Entity {
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (!from.equals(to)) {
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ player.handlingMoveEvent = true;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ player.handlingMoveEvent = false;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index 5c07da62c82bc70138f6cb5007629d6974be69ac..c68c84af56053cbf7f0c7809a16b60749a4fdd05 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.entity.vehicle;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.IntFunction;
|
||||
@@ -16,6 +18,7 @@ import net.minecraft.network.protocol.game.ServerboundPaddleBoatPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
@@ -434,8 +437,22 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (this.lastLocation != null && !this.lastLocation.equals(to)) {
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ player.handlingMoveEvent = true;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
VehicleMoveEvent event = new VehicleMoveEvent(vehicle, this.lastLocation, to);
|
||||
server.getPluginManager().callEvent(event);
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ player.handlingMoveEvent = false;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
this.lastLocation = vehicle.getLocation();
|
||||
// CraftBukkit end
|
||||
Reference in New Issue
Block a user