mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-10-26 05:50:41 +00:00
legacy version chunk async load fix
This commit is contained in:
1 parent
7f52c5a481
commit
34f616bd99
4 files changed
+17
-8
No files matched your search
@@ -8,6 +8,7 @@ import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
|||||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import org.apache.commons.lang.UnhandledException;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -60,9 +61,24 @@ public class RTPPlayer {
|
|||||||
}
|
}
|
||||||
attempts++; //Add an attempt
|
attempts++; //Add an attempt
|
||||||
//Load chunk and find out if safe location (asynchronously)
|
//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);
|
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(loc);
|
||||||
chunk.thenAccept(result -> {
|
chunk.thenAccept(result -> {
|
||||||
//BetterRTP.debug("Checking location for " + p.getName());
|
//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;
|
Location tpLoc;
|
||||||
tpLoc = getSafeLocation(worldPlayer.getWorldtype(), worldPlayer.getWorld(), loc, worldPlayer.getMinY(), worldPlayer.getMaxY(), worldPlayer.getBiomes());
|
tpLoc = getSafeLocation(worldPlayer.getWorldtype(), worldPlayer.getWorld(), loc, worldPlayer.getMinY(), worldPlayer.getMaxY(), worldPlayer.getBiomes());
|
||||||
attemptedLocations.add(loc);
|
attemptedLocations.add(loc);
|
||||||
@@ -79,9 +95,6 @@ public class RTPPlayer {
|
|||||||
randomlyTeleport(sendi);
|
randomlyTeleport(sendi);
|
||||||
QueueHandler.remove(loc);
|
QueueHandler.remove(loc);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getSafeLocation(WORLD_TYPE type, World world, Location loc, int minY, int maxY, List<String> biomes) {
|
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;
|
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 me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|||||||
-2
@@ -1,7 +1,5 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
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 net.william278.husktowns.api.HuskTownsAPI;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class HelperRTP {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//ignore cooldown or else
|
//ignore cooldown or else
|
||||||
BetterRTP.getInstance().getLogger().info("Center X: " + pWorld.getCenterX());
|
//BetterRTP.getInstance().getLogger().info("Center X: " + pWorld.getCenterX());
|
||||||
getPl().getRTP().start(pWorld);
|
getPl().getRTP().start(pWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user