2023-05-11 07:10:33 +10:00
|
|
|
From 5f11690d01d5c9edcb1ce23d539ea6cbe9e61328 Mon Sep 17 00:00:00 2001
|
2014-03-25 16:11:22 +11:00
|
|
|
From: md_5 <git@md-5.net>
|
|
|
|
Date: Tue, 25 Mar 2014 16:10:01 +1100
|
2013-03-23 18:05:22 +11:00
|
|
|
Subject: [PATCH] Async Operation Catching
|
2013-03-07 20:12:53 +11:00
|
|
|
|
2013-03-23 18:05:22 +11:00
|
|
|
Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread.
|
2013-03-07 20:12:53 +11:00
|
|
|
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index fe8992bb48..e1353632bf 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
2023-03-15 03:30:00 +11:00
|
|
|
@@ -1292,6 +1292,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
|
2013-03-23 18:27:02 +11:00
|
|
|
}
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
protected void addEntity(Entity entity) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot
|
2019-04-23 12:00:00 +10:00
|
|
|
if (!(entity instanceof EntityComplexPart)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
EntityTypes<?> entitytypes = entity.getType();
|
|
|
|
int i = entitytypes.clientTrackingRange() * 16;
|
2023-03-15 03:30:00 +11:00
|
|
|
@@ -1327,6 +1328,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
|
2013-03-23 18:27:02 +11:00
|
|
|
}
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
protected void removeEntity(Entity entity) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("entity untrack"); // Spigot
|
2013-03-23 18:27:02 +11:00
|
|
|
if (entity instanceof EntityPlayer) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
|
|
|
|
2023-03-15 03:30:00 +11:00
|
|
|
@@ -1579,6 +1581,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
|
2019-04-23 12:00:00 +10:00
|
|
|
}
|
2013-03-23 18:27:02 +11:00
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
public void removePlayer(EntityPlayer entityplayer) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("player tracker clear"); // Spigot
|
2021-06-11 15:00:00 +10:00
|
|
|
if (this.seenBy.remove(entityplayer.connection)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
this.serverEntity.removePairing(entityplayer);
|
2019-04-23 12:00:00 +10:00
|
|
|
}
|
2023-03-15 03:30:00 +11:00
|
|
|
@@ -1586,6 +1589,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
|
2019-04-23 12:00:00 +10:00
|
|
|
}
|
2013-03-23 18:27:02 +11:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
public void updatePlayer(EntityPlayer entityplayer) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
|
2021-06-11 15:00:00 +10:00
|
|
|
if (entityplayer != this.entity) {
|
2022-06-08 02:00:00 +10:00
|
|
|
Vec3D vec3d = entityplayer.position().subtract(this.entity.position());
|
2021-11-22 09:00:00 +11:00
|
|
|
double d0 = (double) Math.min(this.getEffectiveRange(), (PlayerChunkMap.this.viewDistance - 1) * 16);
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index db82616d9c..6e38b63bf9 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -1034,6 +1034,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2019-04-23 12:00:00 +10:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2021-11-22 09:00:00 +11:00
|
|
|
private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot
|
2021-06-11 15:00:00 +10:00
|
|
|
if (entity.isRemoved()) {
|
2021-11-22 09:00:00 +11:00
|
|
|
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
2018-12-17 12:35:20 +11:00
|
|
|
return false;
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -1841,6 +1842,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2013-03-23 18:27:02 +11:00
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
@Override
|
|
|
|
public LevelEntityGetter<Entity> getEntities() {
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot
|
2021-11-22 09:00:00 +11:00
|
|
|
return this.entityManager.getEntityGetter();
|
2019-07-23 09:48:32 +10:00
|
|
|
}
|
|
|
|
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -1919,6 +1921,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2021-06-11 15:00:00 +10:00
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
public void onTrackingStart(Entity entity) {
|
2021-06-11 15:00:00 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot
|
2021-11-22 09:00:00 +11:00
|
|
|
WorldServer.this.getChunkSource().addEntity(entity);
|
2021-06-11 15:00:00 +10:00
|
|
|
if (entity instanceof EntityPlayer) {
|
2021-12-11 00:00:00 +11:00
|
|
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -1956,6 +1959,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2021-06-11 15:00:00 +10:00
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
public void onTrackingEnd(Entity entity) {
|
2021-06-11 15:00:00 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot
|
2021-11-22 09:00:00 +11:00
|
|
|
WorldServer.this.getChunkSource().removeEntity(entity);
|
2021-06-11 15:00:00 +10:00
|
|
|
if (entity instanceof EntityPlayer) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index c07d54bd72..2a733f8eb9 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
2023-03-15 03:30:00 +11:00
|
|
|
@@ -1084,6 +1084,7 @@ public abstract class EntityLiving extends Entity implements Attackable {
|
2021-03-16 09:00:00 +11:00
|
|
|
}
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
public boolean addEffect(MobEffect mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) {
|
2021-03-16 09:00:00 +11:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot
|
|
|
|
if (isTickingEffects) {
|
|
|
|
effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
|
|
|
|
return true;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java b/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index c7912e8ec5..6751a30592 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java
|
2022-06-08 02:00:00 +10:00
|
|
|
@@ -86,6 +86,7 @@ public class CraftingManager extends ResourceDataJson {
|
2021-03-16 09:00:00 +11:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
public void addRecipe(IRecipe<?> irecipe) {
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot
|
2021-11-22 09:00:00 +11:00
|
|
|
Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.getType()); // CraftBukkit
|
2021-03-16 09:00:00 +11:00
|
|
|
|
2021-11-25 08:00:00 +11:00
|
|
|
if (byName.containsKey(irecipe.getId()) || map.containsKey(irecipe.getId())) {
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index 39a88e44fa..39b18e2f73 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
|
2023-03-15 03:30:00 +11:00
|
|
|
@@ -145,11 +145,14 @@ public abstract class BlockBase implements FeatureElement {
|
2021-03-16 09:00:00 +11:00
|
|
|
|
2021-11-25 08:00:00 +11:00
|
|
|
/** @deprecated */
|
2021-03-16 09:00:00 +11:00
|
|
|
@Deprecated
|
|
|
|
- public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {}
|
|
|
|
+ public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot
|
|
|
|
+ }
|
|
|
|
|
2021-11-25 08:00:00 +11:00
|
|
|
/** @deprecated */
|
2021-03-16 09:00:00 +11:00
|
|
|
@Deprecated
|
2021-11-22 09:00:00 +11:00
|
|
|
public void onRemove(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
|
2021-03-16 09:00:00 +11:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("block remove"); // Spigot
|
2021-11-22 09:00:00 +11:00
|
|
|
if (iblockdata.hasBlockEntity() && !iblockdata.is(iblockdata1.getBlock())) {
|
|
|
|
world.removeBlockEntity(blockposition);
|
2021-03-16 09:00:00 +11:00
|
|
|
}
|
2018-07-18 12:36:24 +10:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index a6401095e2..ad925597db 100644
|
2018-07-18 12:36:24 +10:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2023-04-19 20:03:29 +10:00
|
|
|
@@ -817,6 +817,7 @@ public final class CraftServer implements Server {
|
2018-07-18 12:36:24 +10:00
|
|
|
public boolean dispatchCommand(CommandSender sender, String commandLine) {
|
|
|
|
Validate.notNull(sender, "Sender cannot be null");
|
|
|
|
Validate.notNull(commandLine, "CommandLine cannot be null");
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("command dispatch"); // Spigot
|
2018-07-18 12:36:24 +10:00
|
|
|
|
|
|
|
if (commandMap.dispatch(sender, commandLine)) {
|
|
|
|
return true;
|
2013-03-07 20:12:53 +11:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index ef20f970cb..6153d1ee9b 100644
|
2013-03-07 20:12:53 +11:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -272,6 +272,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2013-03-07 20:12:53 +11:00
|
|
|
|
2019-04-28 11:41:06 +10:00
|
|
|
@Override
|
2019-04-23 12:00:00 +10:00
|
|
|
public boolean unloadChunkRequest(int x, int z) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
|
2020-06-06 19:28:03 +10:00
|
|
|
if (isChunkLoaded(x, z)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
|
2020-06-06 19:28:03 +10:00
|
|
|
}
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -280,6 +281,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2013-03-07 20:12:53 +11:00
|
|
|
}
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
private boolean unloadChunk0(int x, int z, boolean save) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
|
2020-06-06 19:28:03 +10:00
|
|
|
if (!isChunkLoaded(x, z)) {
|
2019-04-23 12:00:00 +10:00
|
|
|
return true;
|
2020-06-06 19:28:03 +10:00
|
|
|
}
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -294,6 +296,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2018-11-03 20:28:44 +11:00
|
|
|
|
2019-04-28 11:41:06 +10:00
|
|
|
@Override
|
2018-11-03 20:28:44 +11:00
|
|
|
public boolean regenerateChunk(int x, int z) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("chunk regenerate"); // Spigot
|
2019-04-23 12:00:00 +10:00
|
|
|
throw new UnsupportedOperationException("Not supported in this Minecraft version! Unless you can fix it, this is not a bug :)");
|
|
|
|
/*
|
2018-11-03 20:28:44 +11:00
|
|
|
if (!unloadChunk0(x, z, false)) {
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -346,6 +349,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2013-03-07 20:12:53 +11:00
|
|
|
|
2019-04-28 11:41:06 +10:00
|
|
|
@Override
|
2013-03-07 20:12:53 +11:00
|
|
|
public boolean loadChunk(int x, int z, boolean generate) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
2021-11-22 09:00:00 +11:00
|
|
|
IChunkAccess chunk = world.getChunkSource().getChunk(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
|
2019-04-23 12:00:00 +10:00
|
|
|
|
|
|
|
// If generate = false, but the chunk already exists, we will get this back.
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -834,6 +838,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2019-09-11 18:20:14 +10:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<Entity> filter) {
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("getNearbyEntities"); // Spigot
|
|
|
|
Validate.notNull(boundingBox, "Bounding box is null!");
|
|
|
|
|
|
|
|
AxisAlignedBB bb = new AxisAlignedBB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -988,6 +993,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2019-08-13 20:38:28 +10:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void save() {
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("world save"); // Spigot
|
|
|
|
this.server.checkSaveState();
|
2021-06-11 15:00:00 +10:00
|
|
|
boolean oldSave = world.noSave;
|
2020-06-25 10:00:00 +10:00
|
|
|
|
2019-09-11 18:20:14 +10:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index 49f6038f5a..e90064b5e7 100644
|
2019-09-11 18:20:14 +10:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2023-04-19 20:03:29 +10:00
|
|
|
@@ -563,6 +563,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
2019-09-11 18:20:14 +10:00
|
|
|
@Override
|
|
|
|
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
|
2021-08-15 08:08:25 +10:00
|
|
|
Preconditions.checkState(!entity.generation, "Cannot get nearby entities during world generation");
|
2019-09-11 18:20:14 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("getNearbyEntities"); // Spigot
|
2021-08-15 08:08:25 +10:00
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
List<Entity> notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().inflate(x, y, z), Predicates.alwaysTrue());
|
2019-09-11 18:20:14 +10:00
|
|
|
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
|
2013-03-23 18:05:22 +11:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index 18d0a726b0..11c5d2aadf 100644
|
2013-03-23 18:05:22 +11:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-05-11 07:10:33 +10:00
|
|
|
@@ -373,6 +373,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2013-03-23 18:05:22 +11:00
|
|
|
|
2013-12-01 14:40:53 +11:00
|
|
|
@Override
|
2013-03-23 18:05:22 +11:00
|
|
|
public void kickPlayer(String message) {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot
|
2021-06-11 15:00:00 +10:00
|
|
|
if (getHandle().connection == null) return;
|
2013-03-23 18:05:22 +11:00
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
getHandle().connection.disconnect(message == null ? "" : message);
|
2014-01-25 15:23:21 +11:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index 659c1b272a..329b2fbe07 100644
|
2014-01-25 15:23:21 +11:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
|
2019-04-28 11:41:06 +10:00
|
|
|
@@ -41,6 +41,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
|
2014-01-25 15:23:21 +11:00
|
|
|
|
2019-04-28 11:41:06 +10:00
|
|
|
@Override
|
2014-01-25 15:23:21 +11:00
|
|
|
public CraftScoreboard getNewScoreboard() {
|
2019-07-23 09:48:32 +10:00
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("scoreboard creation"); // Spigot
|
2014-01-25 15:23:21 +11:00
|
|
|
CraftScoreboard scoreboard = new CraftScoreboard(new ScoreboardServer(server));
|
|
|
|
scoreboards.add(scoreboard);
|
|
|
|
return scoreboard;
|
2017-06-19 19:56:13 +10:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
2023-05-11 07:10:33 +10:00
|
|
|
index 2e057fd4c0..ddef523ea8 100644
|
2017-06-19 19:56:13 +10:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
2019-04-23 12:00:00 +10:00
|
|
|
@@ -12,6 +12,7 @@ public class ServerShutdownThread extends Thread {
|
2017-06-19 19:56:13 +10:00
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
+ org.spigotmc.AsyncCatcher.enabled = false; // Spigot
|
2019-04-23 12:00:00 +10:00
|
|
|
server.close();
|
|
|
|
} finally {
|
|
|
|
try {
|
2014-03-25 16:11:22 +11:00
|
|
|
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
|
|
new file mode 100644
|
2023-05-11 07:10:33 +10:00
|
|
|
index 0000000000..aeed769725
|
2014-03-25 16:11:22 +11:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
|
|
@@ -0,0 +1,17 @@
|
|
|
|
+package org.spigotmc;
|
|
|
|
+
|
|
|
|
+import net.minecraft.server.MinecraftServer;
|
|
|
|
+
|
|
|
|
+public class AsyncCatcher
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ public static boolean enabled = true;
|
|
|
|
+
|
|
|
|
+ public static void catchOp(String reason)
|
|
|
|
+ {
|
2019-04-23 12:00:00 +10:00
|
|
|
+ if ( enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread )
|
2014-03-25 16:11:22 +11:00
|
|
|
+ {
|
|
|
|
+ throw new IllegalStateException( "Asynchronous " + reason + "!" );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
2013-03-07 20:12:53 +11:00
|
|
|
--
|
2023-05-11 07:10:33 +10:00
|
|
|
2.40.1
|
2013-03-07 20:12:53 +11:00
|
|
|
|