mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-18 16:55:13 +01:00
Players will teleport faster
Players will teleport to a spawn point if it is safe and marked. https://github.com/tastybento/bskyblock/projects/3#card-11060603
This commit is contained in:
parent
9021df099a
commit
a663395a13
@ -117,10 +117,11 @@ public class NetherPortals implements Listener {
|
||||
if (plugin.getIWM().isEndGenerate(overWorld) && plugin.getIWM().isEndIslands(overWorld)) {
|
||||
World endWorld = plugin.getIWM().getEndWorld(overWorld);
|
||||
// End exists and end islands are being used
|
||||
Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.THE_END)).orElse(e.getFrom().toVector().toLocation(endWorld));
|
||||
e.setCancelled(true);
|
||||
new SafeTeleportBuilder(plugin)
|
||||
.entity(e.getPlayer())
|
||||
.location(e.getFrom().toVector().toLocation(endWorld))
|
||||
.location(to)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -176,30 +177,31 @@ public class NetherPortals implements Listener {
|
||||
if (e.getFrom().getWorld().getEnvironment().equals(Environment.NETHER)) {
|
||||
// If this is from the island nether, then go to the same vector, otherwise try island home location
|
||||
Location to = plugin.getIWM().isNetherIslands(overWorld)
|
||||
? e.getFrom().toVector().toLocation(overWorld)
|
||||
? plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.NORMAL)).orElse(e.getFrom().toVector().toLocation(overWorld))
|
||||
: plugin.getIslands().getIslandLocation(overWorld, e.getPlayer().getUniqueId());
|
||||
e.setCancelled(true);
|
||||
// Else other worlds teleport to the nether
|
||||
new SafeTeleportBuilder(plugin)
|
||||
.entity(e.getPlayer())
|
||||
.location(to)
|
||||
.portal()
|
||||
.build();
|
||||
return true;
|
||||
|
||||
e.setCancelled(true);
|
||||
// Else other worlds teleport to the nether
|
||||
new SafeTeleportBuilder(plugin)
|
||||
.entity(e.getPlayer())
|
||||
.location(to)
|
||||
.portal()
|
||||
.build();
|
||||
return true;
|
||||
}
|
||||
World nether = plugin.getIWM().getNetherWorld(overWorld);
|
||||
// If this is to island nether, then go to the same vector, otherwise try spawn
|
||||
Location to = (plugin.getIWM().isNetherIslands(overWorld) && plugin.getIWM().isNetherGenerate(overWorld))
|
||||
? e.getFrom().toVector().toLocation(nether)
|
||||
? plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.NETHER)).orElse(e.getFrom().toVector().toLocation(nether))
|
||||
: nether.getSpawnLocation();
|
||||
e.setCancelled(true);
|
||||
// Else other worlds teleport to the nether
|
||||
new SafeTeleportBuilder(plugin)
|
||||
.entity(e.getPlayer())
|
||||
.location(to)
|
||||
.portal()
|
||||
.build();
|
||||
return true;
|
||||
e.setCancelled(true);
|
||||
// Else other worlds teleport to the nether
|
||||
new SafeTeleportBuilder(plugin)
|
||||
.entity(e.getPlayer())
|
||||
.location(to)
|
||||
.portal()
|
||||
.build();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,6 +69,19 @@ public class SafeSpotTeleport {
|
||||
((Player)entity).setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
|
||||
// If there is no portal scan required, try the desired location immediately
|
||||
if (plugin.getIslands().isSafeLocation(location)) {
|
||||
if (portal) {
|
||||
// If the desired location is safe, then that's where you'll go if there's no portal
|
||||
bestSpot = location;
|
||||
} else {
|
||||
// If this is not a portal teleport, then go to the safe location immediately
|
||||
entity.teleport(location);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get chunks to scan
|
||||
chunksToScan = getChunksToScan();
|
||||
|
||||
@ -213,8 +226,8 @@ public class SafeSpotTeleport {
|
||||
task.cancel();
|
||||
// Return to main thread and teleport the player
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (!portal && entity instanceof Player) {
|
||||
// Set home
|
||||
if (!portal && entity instanceof Player && homeNumber > 0) {
|
||||
// Set home if so marked
|
||||
plugin.getPlayers().setHomeLocation(User.getInstance(entity), loc, homeNumber);
|
||||
}
|
||||
Vector velocity = entity.getVelocity();
|
||||
|
Loading…
Reference in New Issue
Block a user