Fix sync tasks not being sync

This commit is contained in:
dordsor21 2021-01-08 12:59:33 +00:00 committed by Alexander Söderberg
parent 0a5c73478d
commit 7ac3f7ca03
6 changed files with 26 additions and 23 deletions

View File

@ -333,7 +333,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// Economy
if (Settings.Enabled_Components.ECONOMY) {
TaskManager.runTask(() -> {
TaskManager.runTaskAsync(() -> {
this.permissionHandler().initialize();
final EconHandler econHandler = injector().getInstance(EconHandler.class);
econHandler.init();

View File

@ -40,9 +40,10 @@ import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.setup.PlotAreaBuilder;
import com.plotsquared.core.util.SetupUtils;
import io.papermc.lib.PaperLib;
import com.plotsquared.core.util.task.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
@ -97,13 +98,14 @@ import java.util.Objects;
}
@Override public void unload(String worldName, boolean save) {
TaskManager.runTask(() -> {
World world = Bukkit.getWorld(worldName);
if (world == null) {
return;
}
World dw = Bukkit.getWorlds().get(0);
Location location = Bukkit.getWorlds().get(0).getSpawnLocation();
for (Player player : world.getPlayers()) {
PaperLib.teleportAsync(player, dw.getSpawnLocation());
player.teleport(location);
}
if (save) {
for (Chunk chunk : world.getLoadedChunks()) {
@ -115,6 +117,7 @@ import java.util.Objects;
}
}
Bukkit.unloadWorld(world, false);
});
}
@Override public String setupWorld(PlotAreaBuilder builder) {

View File

@ -92,7 +92,7 @@ import java.util.concurrent.TimeUnit;
}
@Override public void task(@Nonnull final Runnable runnable) {
new BukkitPlotSquaredTask(runnable).runTaskAsynchronously(this.bukkitMain);
new BukkitPlotSquaredTask(runnable).runTask(this.bukkitMain);
}
@Override public void taskLater(@Nonnull final Runnable runnable,

View File

@ -387,7 +387,7 @@ public class PlotSquared {
if (!file.exists()) {
return;
}
TaskManager.runTask(() -> {
TaskManager.runTaskAsync(() -> {
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
List<Object> list = (List<Object>) ois.readObject();
ArrayList<int[]> regionInts = (ArrayList<int[]>) list.get(0);

View File

@ -47,7 +47,7 @@ public class Confirm extends SubCommand {
player.sendMessage(TranslatableCaption.of("confirm.expired_confirm"));
return false;
}
TaskManager.runTask(command.command);
TaskManager.runTaskAsync(command.command);
return true;
}
}

View File

@ -210,7 +210,7 @@ public abstract class SchematicHandler {
}
this.exportAll = true;
final ArrayList<Plot> plots = new ArrayList<>(collection);
TaskManager.runTask(new Runnable() {
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
if (plots.isEmpty()) {
SchematicHandler.this.exportAll = false;
@ -637,7 +637,7 @@ public abstract class SchematicHandler {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
ByteArrayOutputStream biomeBuffer = new ByteArrayOutputStream(width * length);
// Queue
TaskManager.runTask(() -> {
TaskManager.runTaskAsync(() -> {
final BlockVector3 minimum = aabb.getMinimumPoint();
final BlockVector3 maximum = aabb.getMaximumPoint();