Commits
md_5 authored e65d67a7a97
1 - | From d7386ad104c37103e09df6ef685ba15803c57b54 Mon Sep 17 00:00:00 2001 |
1 + | From 3a74f6c100d03a14c698ae26e71dff33327d70dd Mon Sep 17 00:00:00 2001 |
2 2 | From: md_5 <git@md-5.net> |
3 3 | Date: Tue, 25 Mar 2014 16:10:01 +1100 |
4 4 | Subject: [PATCH] Async Operation Catching |
5 5 | |
6 6 | Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread. |
7 7 | |
8 8 | diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java |
9 9 | index 4d8aa931fb..5043631d14 100644 |
10 10 | --- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java |
11 11 | +++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java |
71 71 | WorldServer.this.players.add(entityplayer); |
72 72 | |
73 73 | } |
74 74 | |
75 75 | public void onTrackingEnd(Entity entity) { |
76 76 | + org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot |
77 77 | WorldServer.this.getChunkSource().removeEntity(entity); |
78 78 | if (entity instanceof EntityPlayer entityplayer) { |
79 79 | WorldServer.this.players.remove(entityplayer); |
80 80 | diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java |
81 - | index 0ee571c05f..b17621a29f 100644 |
81 + | index 02f729d695..7fe581b308 100644 |
82 82 | --- a/src/main/java/net/minecraft/world/entity/EntityLiving.java |
83 83 | +++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java |
84 84 | |
85 85 | } |
86 86 | |
87 87 | public boolean addEffect(MobEffect mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) { |
88 88 | + org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot |
89 89 | if (isTickingEffects) { |
90 90 | effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); |
91 91 | return true; |
92 92 | diff --git a/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java b/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java |
93 - | index a927c8756a..65a1fa3b61 100644 |
93 + | index dd28f90d90..7f58791c8a 100644 |
94 94 | --- a/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java |
95 95 | +++ b/src/main/java/net/minecraft/world/item/crafting/CraftingManager.java |
96 - | |
96 + | |
97 97 | |
98 98 | // CraftBukkit start |
99 99 | public void addRecipe(RecipeHolder<?> irecipe) { |
100 100 | + org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot |
101 101 | this.recipes.addRecipe(irecipe); |
102 102 | finalizeRecipeLoading(); |
103 103 | } |
104 104 | 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 |
105 105 | index 3a143fffa3..8d15390052 100644 |
106 106 | --- a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java |
118 118 | protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag, @Nullable ItemActionContext context) { |
119 119 | |
120 120 | // CraftBukkit end |
121 121 | |
122 122 | protected void onRemove(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { |
123 123 | + org.spigotmc.AsyncCatcher.catchOp("block remove"); // Spigot |
124 124 | if (iblockdata.hasBlockEntity() && !iblockdata.is(iblockdata1.getBlock())) { |
125 125 | world.removeBlockEntity(blockposition); |
126 126 | } |
127 127 | diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java |
128 - | index 7b8e1bb014..9dcdbb1cba 100644 |
128 + | index 7a5f99dc86..10c80d8563 100644 |
129 129 | --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java |
130 130 | +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java |
131 131 | |
132 132 | public boolean dispatchCommand(CommandSender sender, String commandLine) { |
133 133 | Preconditions.checkArgument(sender != null, "sender cannot be null"); |
134 134 | Preconditions.checkArgument(commandLine != null, "commandLine cannot be null"); |
135 135 | + org.spigotmc.AsyncCatcher.catchOp("command dispatch"); // Spigot |
136 136 | |
137 137 | if (commandMap.dispatch(sender, commandLine)) { |
138 138 | return true; |