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)) {
|
if (plugin.getIWM().isEndGenerate(overWorld) && plugin.getIWM().isEndIslands(overWorld)) {
|
||||||
World endWorld = plugin.getIWM().getEndWorld(overWorld);
|
World endWorld = plugin.getIWM().getEndWorld(overWorld);
|
||||||
// End exists and end islands are being used
|
// 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);
|
e.setCancelled(true);
|
||||||
new SafeTeleportBuilder(plugin)
|
new SafeTeleportBuilder(plugin)
|
||||||
.entity(e.getPlayer())
|
.entity(e.getPlayer())
|
||||||
.location(e.getFrom().toVector().toLocation(endWorld))
|
.location(to)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,30 +177,31 @@ public class NetherPortals implements Listener {
|
|||||||
if (e.getFrom().getWorld().getEnvironment().equals(Environment.NETHER)) {
|
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
|
// If this is from the island nether, then go to the same vector, otherwise try island home location
|
||||||
Location to = plugin.getIWM().isNetherIslands(overWorld)
|
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());
|
: plugin.getIslands().getIslandLocation(overWorld, e.getPlayer().getUniqueId());
|
||||||
e.setCancelled(true);
|
|
||||||
// Else other worlds teleport to the nether
|
e.setCancelled(true);
|
||||||
new SafeTeleportBuilder(plugin)
|
// Else other worlds teleport to the nether
|
||||||
.entity(e.getPlayer())
|
new SafeTeleportBuilder(plugin)
|
||||||
.location(to)
|
.entity(e.getPlayer())
|
||||||
.portal()
|
.location(to)
|
||||||
.build();
|
.portal()
|
||||||
return true;
|
.build();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
World nether = plugin.getIWM().getNetherWorld(overWorld);
|
World nether = plugin.getIWM().getNetherWorld(overWorld);
|
||||||
// If this is to island nether, then go to the same vector, otherwise try spawn
|
// 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))
|
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();
|
: nether.getSpawnLocation();
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
// Else other worlds teleport to the nether
|
// Else other worlds teleport to the nether
|
||||||
new SafeTeleportBuilder(plugin)
|
new SafeTeleportBuilder(plugin)
|
||||||
.entity(e.getPlayer())
|
.entity(e.getPlayer())
|
||||||
.location(to)
|
.location(to)
|
||||||
.portal()
|
.portal()
|
||||||
.build();
|
.build();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,6 +69,19 @@ public class SafeSpotTeleport {
|
|||||||
((Player)entity).setGameMode(GameMode.SPECTATOR);
|
((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
|
// Get chunks to scan
|
||||||
chunksToScan = getChunksToScan();
|
chunksToScan = getChunksToScan();
|
||||||
|
|
||||||
@ -213,8 +226,8 @@ public class SafeSpotTeleport {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
// Return to main thread and teleport the player
|
// Return to main thread and teleport the player
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
if (!portal && entity instanceof Player) {
|
if (!portal && entity instanceof Player && homeNumber > 0) {
|
||||||
// Set home
|
// Set home if so marked
|
||||||
plugin.getPlayers().setHomeLocation(User.getInstance(entity), loc, homeNumber);
|
plugin.getPlayers().setHomeLocation(User.getInstance(entity), loc, homeNumber);
|
||||||
}
|
}
|
||||||
Vector velocity = entity.getVelocity();
|
Vector velocity = entity.getVelocity();
|
||||||
|
Loading…
Reference in New Issue
Block a user