mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-10-12 03:24:12 +00:00
legacy version chunk async load fix
This commit is contained in:
@@ -8,6 +8,7 @@ import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import org.apache.commons.lang.UnhandledException;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -60,9 +61,24 @@ public class RTPPlayer {
|
||||
}
|
||||
attempts++; //Add an attempt
|
||||
//Load chunk and find out if safe location (asynchronously)
|
||||
Bukkit.getScheduler().runTask(BetterRTP.getInstance(), () -> {
|
||||
try { //Prior to 1.12 this async chunk will NOT work
|
||||
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(loc);
|
||||
chunk.thenAccept(result -> {
|
||||
//BetterRTP.debug("Checking location for " + p.getName());
|
||||
attempt(sendi, loc);
|
||||
});
|
||||
} catch (IllegalStateException e) {
|
||||
attempt(sendi, loc);
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void attempt(CommandSender sendi, Location loc) {
|
||||
Location tpLoc;
|
||||
tpLoc = getSafeLocation(worldPlayer.getWorldtype(), worldPlayer.getWorld(), loc, worldPlayer.getMinY(), worldPlayer.getMaxY(), worldPlayer.getBiomes());
|
||||
attemptedLocations.add(loc);
|
||||
@@ -79,9 +95,6 @@ public class RTPPlayer {
|
||||
randomlyTeleport(sendi);
|
||||
QueueHandler.remove(loc);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static Location getSafeLocation(WORLD_TYPE type, World world, Location loc, int minY, int maxY, List<String> biomes) {
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.settings.SoftDepends;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.settings.SoftDepends;
|
||||
import net.william278.husktowns.api.HuskTownsAPI;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class HelperRTP {
|
||||
return;
|
||||
}
|
||||
//ignore cooldown or else
|
||||
BetterRTP.getInstance().getLogger().info("Center X: " + pWorld.getCenterX());
|
||||
//BetterRTP.getInstance().getLogger().info("Center X: " + pWorld.getCenterX());
|
||||
getPl().getRTP().start(pWorld);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user