mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-27 14:13:00 +02:00
Allow disabling SafeLocationCheck
This commit is contained in:
parent
72f468d191
commit
d1fdc9217a
@ -1240,7 +1240,7 @@ public class IslandManager {
|
||||
}
|
||||
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor);
|
||||
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
Location safeLoc = LocationUtil.getSafeLocation(loc);
|
||||
Location safeLoc = LocationUtil.getSafeLocation(plugin, loc);
|
||||
if(safeLoc != null){
|
||||
loc = safeLoc;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class Move implements Listener {
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main));
|
||||
Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(world, IslandEnvironment.Main));
|
||||
if(safeLoc != null){
|
||||
loc = safeLoc;
|
||||
}
|
||||
@ -213,7 +213,7 @@ public class Move implements Listener {
|
||||
}
|
||||
} else {
|
||||
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor));
|
||||
Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(world, IslandEnvironment.Visitor));
|
||||
if(safeLoc != null){
|
||||
loc = safeLoc;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public class Portal implements Listener {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
Location loc = island.getLocation(toWorldF, spawnEnvironment);
|
||||
Location tempSafeLoc = LocationUtil.getSafeLocation(loc);
|
||||
Location tempSafeLoc = LocationUtil.getSafeLocation(plugin, loc);
|
||||
Location safeLoc = null;
|
||||
if(tempSafeLoc != null) {
|
||||
safeLoc = tempSafeLoc;
|
||||
|
@ -71,7 +71,7 @@ public class PortalPermission extends ListeningPermission {
|
||||
Island island = islandManager.getIslandAtLocation(from);
|
||||
Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
|
||||
if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){
|
||||
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||
Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||
if(safeLoc != null) {
|
||||
to = safeLoc;
|
||||
}
|
||||
|
@ -45,26 +45,29 @@ public final class LocationUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable Location getSafeLocation(@Nonnull Location loc){
|
||||
boolean found = false;
|
||||
public static @Nullable Location getSafeLocation(SkyBlock plugin, @Nonnull Location loc){
|
||||
Location locChecked = null;
|
||||
if(loc.getWorld() != null){
|
||||
locChecked = loc.clone();
|
||||
loc.getWorld().loadChunk(loc.getWorld().getChunkAt(loc));
|
||||
for(int i=loc.getBlockY(); i>=0 && !found; i--){
|
||||
locChecked = locChecked.subtract(0d, 1d, 0d);
|
||||
found = checkBlock(locChecked);
|
||||
}
|
||||
if(!found){
|
||||
for(int i=loc.getBlockY(); i<256 && !found; i++){
|
||||
locChecked = locChecked.add(0d, 1d, 0d);
|
||||
if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
|
||||
boolean found = false;
|
||||
if(loc.getWorld() != null){
|
||||
locChecked = loc.clone();
|
||||
loc.getWorld().loadChunk(loc.getWorld().getChunkAt(loc));
|
||||
for(int i=loc.getBlockY(); i>=0 && !found; i--){
|
||||
locChecked = locChecked.subtract(0d, 1d, 0d);
|
||||
found = checkBlock(locChecked);
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
locChecked = locChecked.add(0d,1d,0d);
|
||||
} else {
|
||||
locChecked = null;
|
||||
if(!found){
|
||||
for(int i=loc.getBlockY(); i<256 && !found; i++){
|
||||
locChecked = locChecked.add(0d, 1d, 0d);
|
||||
found = checkBlock(locChecked);
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
locChecked = locChecked.add(0d,1d,0d);
|
||||
} else {
|
||||
locChecked = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return locChecked;
|
||||
|
@ -359,6 +359,8 @@ Island:
|
||||
# Enable or disable Fall damage
|
||||
FallDamage: true
|
||||
RemoveWater: true
|
||||
# Check if location is safe before teleporting
|
||||
SafetyCheck: true
|
||||
Limits:
|
||||
# Should slime split bypass limits.yml
|
||||
AllowSlimeSplit: true
|
||||
|
Loading…
Reference in New Issue
Block a user