it's better not to bother with tickets to avoid tickets not being removed all the time

This commit is contained in:
dordsor21 2021-01-01 19:49:11 +00:00
parent 580cb4a91e
commit efcca5b66f
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
8 changed files with 16 additions and 57 deletions

View File

@ -9,7 +9,6 @@ import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -155,33 +154,25 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
}
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
Chunk nmsChunk = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
if (nmsChunk != null) {
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunk;
}
if (Fawe.isMainThread()) {
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunkMain;
return nmsWorld.getChunkAt(chunkX, chunkZ);
}
if (PaperLib.isPaper()) {
CraftWorld craftWorld = nmsWorld.getWorld();
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
try {
final CraftChunk chunk = (CraftChunk) future.get();
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
CraftChunk chunk = (CraftChunk) future.get();
return chunk.getHandle();
} catch (Throwable e) {
e.printStackTrace();
}
}
// TODO optimize
return TaskManager.IMP.sync(() -> {
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
return chunk;
});
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
}
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {

View File

@ -607,7 +607,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
task.run();
}
}
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
if (callback == null) {
if (finalizer != null) {
finalizer.run();

View File

@ -9,7 +9,6 @@ import com.boydti.fawe.object.collection.BitArrayUnstretched;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -152,33 +151,25 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
}
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
if (nmsChunk != null) {
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunk;
}
if (Fawe.isMainThread()) {
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunkMain;
return nmsWorld.getChunkAt(chunkX, chunkZ);
}
if (PaperLib.isPaper()) {
CraftWorld craftWorld = nmsWorld.getWorld();
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
try {
final CraftChunk chunk = (CraftChunk) future.get();
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
CraftChunk chunk = (CraftChunk) future.get();
return chunk.getHandle();
} catch (Throwable e) {
e.printStackTrace();
}
}
// TODO optimize
return TaskManager.IMP.sync(() -> {
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
return chunk;
});
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
}
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {

View File

@ -609,7 +609,6 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
task.run();
}
}
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
if (callback == null) {
if (finalizer != null) {
finalizer.run();

View File

@ -11,7 +11,6 @@ import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
import com.mojang.datafixers.util.Either;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -164,33 +163,25 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
}
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
if (nmsChunk != null) {
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunk;
}
if (Fawe.isMainThread()) {
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunkMain;
return nmsWorld.getChunkAt(chunkX, chunkZ);
}
if (PaperLib.isPaper()) {
CraftWorld craftWorld = nmsWorld.getWorld();
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
try {
final CraftChunk chunk = (CraftChunk) future.get();
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
CraftChunk chunk = (CraftChunk) future.get();
return chunk.getHandle();
} catch (Throwable e) {
e.printStackTrace();
}
}
// TODO optimize
return TaskManager.IMP.sync(() -> {
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
return chunk;
});
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
}
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {

View File

@ -612,7 +612,6 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
task.run();
}
}
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
if (callback == null) {
if (finalizer != null) {
finalizer.run();

View File

@ -5,14 +5,12 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.NMSAdapter;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.collection.BitArrayUnstretched;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
import com.mojang.datafixers.util.Either;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -165,33 +163,25 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
}
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
if (nmsChunk != null) {
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunk;
}
if (Fawe.isMainThread()) {
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
return nmsChunkMain;
return nmsWorld.getChunkAt(chunkX, chunkZ);
}
if (PaperLib.isPaper()) {
CraftWorld craftWorld = nmsWorld.getWorld();
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
try {
final CraftChunk chunk = (CraftChunk) future.get();
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
CraftChunk chunk = (CraftChunk) future.get();
return chunk.getHandle();
} catch (Throwable e) {
e.printStackTrace();
}
}
// TODO optimize
return TaskManager.IMP.sync(() -> {
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
return chunk;
});
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
}
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {

View File

@ -612,7 +612,6 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
task.run();
}
}
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
if (callback == null) {
if (finalizer != null) {
finalizer.run();