fix: try fixes #63
This commit is contained in:
@@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc1
|
|||||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
index c39a114c2f5dfef15e18478281106e6abc4fef42..71a26b3a47a7c5798bf2d2902313b74fefa1cfb8 100644
|
index 8405157ec35a443e238fa6866772c839621d73d7..a261f66c29412039bbbaed4758bcade2e076da56 100644
|
||||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
@@ -333,6 +333,8 @@ public final class RegionizedServer {
|
@@ -334,6 +334,8 @@ public final class RegionizedServer {
|
||||||
}
|
}
|
||||||
// Luminol end - Add a config to enable tick command
|
// Luminol end - Add a config to enable tick command
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ index 66ec0424a46dcd49cf44467357d80b1a2d84d3b2..04ae8de63af0a8abe578f14c8ef85fd4
|
|||||||
private DisconnectionDetails disconnectionDetails;
|
private DisconnectionDetails disconnectionDetails;
|
||||||
private boolean encrypted;
|
private boolean encrypted;
|
||||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index ef0b401affa58077e8dd32b52063202a1c7e0bb6..ffbbbe5752a0aa0228c1f74f5ac147578805fafa 100644
|
index ef0b401affa58077e8dd32b52063202a1c7e0bb6..c461ab6c6ab21008be893f84913f0e6f9cf6d336 100644
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -349,6 +349,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -349,6 +349,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
@@ -45,15 +45,19 @@ index ef0b401affa58077e8dd32b52063202a1c7e0bb6..ffbbbe5752a0aa0228c1f74f5ac14757
|
|||||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||||
AtomicReference<S> atomicReference = new AtomicReference<>();
|
AtomicReference<S> atomicReference = new AtomicReference<>();
|
||||||
@@ -1040,6 +1042,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1040,6 +1042,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
// Folia end - region threading
|
// Folia end - region threading
|
||||||
|
|
||||||
public void stopServer() {
|
public void stopServer() {
|
||||||
+ this.getBotList().removeAll(); // Leaves - save or remove bot
|
+ // Leaves end - save or remove bot
|
||||||
|
+ if (!this.getBotList().forceShutdown && !this.getBotList().removeAll()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Leaves end - save or remove bot
|
||||||
// Folia start - region threading
|
// Folia start - region threading
|
||||||
// halt scheduler
|
// halt scheduler
|
||||||
// don't wait, we may be on a scheduler thread
|
// don't wait, we may be on a scheduler thread
|
||||||
@@ -1590,7 +1593,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1590,7 +1597,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
int i = this.pauseWhileEmptySeconds() * 20;
|
int i = this.pauseWhileEmptySeconds() * 20;
|
||||||
this.removeDisabledPluginsBlockingSleep(); // Paper - API to allow/disallow tick sleeping
|
this.removeDisabledPluginsBlockingSleep(); // Paper - API to allow/disallow tick sleeping
|
||||||
if (false && i > 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy
|
if (false && i > 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy
|
||||||
@@ -62,7 +66,7 @@ index ef0b401affa58077e8dd32b52063202a1c7e0bb6..ffbbbe5752a0aa0228c1f74f5ac14757
|
|||||||
this.emptyTicks++;
|
this.emptyTicks++;
|
||||||
} else {
|
} else {
|
||||||
this.emptyTicks = 0;
|
this.emptyTicks = 0;
|
||||||
@@ -1914,6 +1917,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1914,6 +1921,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|
||||||
public void tickConnection() {
|
public void tickConnection() {
|
||||||
this.getConnection().tick();
|
this.getConnection().tick();
|
||||||
@@ -70,7 +74,7 @@ index ef0b401affa58077e8dd32b52063202a1c7e0bb6..ffbbbe5752a0aa0228c1f74f5ac14757
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void synchronizeTime(ServerLevel level) {
|
private void synchronizeTime(ServerLevel level) {
|
||||||
@@ -3001,6 +3005,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -3001,6 +3009,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.leavesmc.leaves.bot;
|
package org.leavesmc.leaves.bot;
|
||||||
|
|
||||||
|
import ca.spottedleaf.moonrise.common.util.TickThread;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
@@ -41,6 +42,7 @@ import net.minecraft.world.level.Level;
|
|||||||
import net.minecraft.world.level.storage.ValueInput;
|
import net.minecraft.world.level.storage.ValueInput;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.event.entity.EntityRemoveEvent;
|
import org.bukkit.event.entity.EntityRemoveEvent;
|
||||||
@@ -51,6 +53,7 @@ import org.slf4j.Logger;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class BotList {
|
public class BotList {
|
||||||
|
|
||||||
@@ -67,6 +70,8 @@ public class BotList {
|
|||||||
private final Map<String, ServerBot> botsByName = Maps.newHashMap();
|
private final Map<String, ServerBot> botsByName = Maps.newHashMap();
|
||||||
private final Map<String, Set<String>> botsNameByWorldUuid = Maps.newHashMap();
|
private final Map<String, Set<String>> botsNameByWorldUuid = Maps.newHashMap();
|
||||||
|
|
||||||
|
public boolean forceShutdown = false;
|
||||||
|
|
||||||
public BotList(MinecraftServer server) {
|
public BotList(MinecraftServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.dataStorage = new BotDataStorage(server.storageSource);
|
this.dataStorage = new BotDataStorage(server.storageSource);
|
||||||
@@ -129,7 +134,7 @@ public class BotList {
|
|||||||
|
|
||||||
ResourceKey<Level> resourcekey = null;
|
ResourceKey<Level> resourcekey = null;
|
||||||
if (nbt.getLong("WorldUUIDMost").isPresent() && nbt.getLong("WorldUUIDLeast").isPresent()) {
|
if (nbt.getLong("WorldUUIDMost").isPresent() && nbt.getLong("WorldUUIDLeast").isPresent()) {
|
||||||
org.bukkit.World bWorld = Bukkit.getServer().getWorld(new UUID(nbt.getLong("WorldUUIDMost").orElseThrow(), nbt.getLong("WorldUUIDLeast").orElseThrow()));
|
World bWorld = Bukkit.getServer().getWorld(new UUID(nbt.getLong("WorldUUIDMost").orElseThrow(), nbt.getLong("WorldUUIDLeast").orElseThrow()));
|
||||||
if (bWorld != null) {
|
if (bWorld != null) {
|
||||||
resourcekey = ((CraftWorld) bWorld).getHandle().dimension();
|
resourcekey = ((CraftWorld) bWorld).getHandle().dimension();
|
||||||
}
|
}
|
||||||
@@ -225,7 +230,7 @@ public class BotList {
|
|||||||
if (entity.hasExactlyOnePlayerPassenger()) {
|
if (entity.hasExactlyOnePlayerPassenger()) {
|
||||||
bot.stopRiding();
|
bot.stopRiding();
|
||||||
entity.getPassengersAndSelf().forEach((entity1) -> {
|
entity.getPassengersAndSelf().forEach((entity1) -> {
|
||||||
if (!false && entity1 instanceof AbstractVillager villager) {
|
if (entity1 instanceof AbstractVillager villager) {
|
||||||
final Player human = villager.getTradingPlayer();
|
final Player human = villager.getTradingPlayer();
|
||||||
if (human != null) {
|
if (human != null) {
|
||||||
villager.setTradingPlayer(null);
|
villager.setTradingPlayer(null);
|
||||||
@@ -279,11 +284,28 @@ public class BotList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAll() {
|
public boolean removeAll() {
|
||||||
|
boolean finished = true;
|
||||||
|
AtomicInteger check = new AtomicInteger();
|
||||||
|
AtomicInteger received = new AtomicInteger();
|
||||||
for (ServerBot bot : this.bots) {
|
for (ServerBot bot : this.bots) {
|
||||||
bot.resume = FakeplayerConfig.canResident;
|
bot.resume = FakeplayerConfig.canResident;
|
||||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakeplayerConfig.canResident);
|
if (TickThread.isTickThreadFor(bot)) {
|
||||||
|
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakeplayerConfig.canResident);
|
||||||
|
} else {
|
||||||
|
finished = false;
|
||||||
|
check.getAndIncrement();
|
||||||
|
bot.getBukkitEntity().taskScheduler.schedule((Entity unused) -> {
|
||||||
|
BotList.this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakeplayerConfig.canResident);
|
||||||
|
received.getAndIncrement();
|
||||||
|
if (received.get() >= check.get()) {
|
||||||
|
this.forceShutdown = true;
|
||||||
|
MinecraftServer.getServer().stopServer();
|
||||||
|
}
|
||||||
|
}, null, 1L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadBotInfo() {
|
public void loadBotInfo() {
|
||||||
|
|||||||
Reference in New Issue
Block a user