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

Dieser Commit ist enthalten in:
dordsor21 2021-01-01 19:49:11 +00:00
Ursprung 580cb4a91e
Commit efcca5b66f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
8 geänderte Dateien mit 16 neuen und 57 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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