mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-27 17:09:43 +00:00
Add force-disable-teleport-safety option (default false). This option is useful for preventing "teleport-glitching" in Factions servers.
This commit is contained in:
parent
ea4c966003
commit
f995676fad
5 changed files with 29 additions and 3 deletions
|
@ -92,6 +92,8 @@ public interface ISettings extends IConf {
|
||||||
|
|
||||||
boolean isTeleportSafetyEnabled();
|
boolean isTeleportSafetyEnabled();
|
||||||
|
|
||||||
|
boolean isForceDisableTeleportSafety();
|
||||||
|
|
||||||
double getTeleportCooldown();
|
double getTeleportCooldown();
|
||||||
|
|
||||||
double getTeleportDelay();
|
double getTeleportDelay();
|
||||||
|
|
|
@ -125,6 +125,17 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return teleportSafety;
|
return teleportSafety;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean forceDisableTeleportSafety;
|
||||||
|
|
||||||
|
private boolean _isForceDisableTeleportSafety() {
|
||||||
|
return config.getBoolean("force-disable-teleport-safety");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isForceDisableTeleportSafety() {
|
||||||
|
return forceDisableTeleportSafety;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getTeleportDelay() {
|
public double getTeleportDelay() {
|
||||||
return config.getDouble("teleport-delay", 0);
|
return config.getDouble("teleport-delay", 0);
|
||||||
|
@ -471,6 +482,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
|
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
|
||||||
enabledSigns = _getEnabledSigns();
|
enabledSigns = _getEnabledSigns();
|
||||||
teleportSafety = _isTeleportSafetyEnabled();
|
teleportSafety = _isTeleportSafetyEnabled();
|
||||||
|
forceDisableTeleportSafety = _isForceDisableTeleportSafety();
|
||||||
teleportInvulnerabilityTime = _getTeleportInvulnerability();
|
teleportInvulnerabilityTime = _getTeleportInvulnerability();
|
||||||
teleportInvulnerability = _isTeleportInvulnerability();
|
teleportInvulnerability = _isTeleportInvulnerability();
|
||||||
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
||||||
|
|
|
@ -95,7 +95,11 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||||
if (teleportee.getBase().isInsideVehicle()) {
|
if (teleportee.getBase().isInsideVehicle()) {
|
||||||
teleportee.getBase().leaveVehicle();
|
teleportee.getBase().leaveVehicle();
|
||||||
}
|
}
|
||||||
|
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||||
|
teleportee.getBase().teleport(loc, cause);
|
||||||
|
} else {
|
||||||
teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, loc), cause);
|
teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, loc), cause);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
@ -103,9 +107,13 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||||
if (teleportee.getBase().isInsideVehicle()) {
|
if (teleportee.getBase().isInsideVehicle()) {
|
||||||
teleportee.getBase().leaveVehicle();
|
teleportee.getBase().leaveVehicle();
|
||||||
}
|
}
|
||||||
|
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||||
|
teleportee.getBase().teleport(loc, cause);
|
||||||
|
} else {
|
||||||
teleportee.getBase().teleport(LocationUtil.getRoundedDestination(loc), cause);
|
teleportee.getBase().teleport(LocationUtil.getRoundedDestination(loc), cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
|
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
|
||||||
//This method is nolonger used internally and will be removed.
|
//This method is nolonger used internally and will be removed.
|
||||||
|
|
|
@ -316,6 +316,6 @@ public class LocationUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return y < 0 ? true : false;
|
return y < 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,10 @@ change-displayname: true
|
||||||
# If this is set to false, attempted teleports to unsafe locations will be cancelled with a warning.
|
# If this is set to false, attempted teleports to unsafe locations will be cancelled with a warning.
|
||||||
teleport-safety: true
|
teleport-safety: true
|
||||||
|
|
||||||
|
# This forcefully disables teleport safety checks without a warning if attempting to teleport to unsafe locations.
|
||||||
|
# teleport-safety and this option need to be set to true to force teleportation to dangerous locations.
|
||||||
|
force-disable-teleport-safety: false
|
||||||
|
|
||||||
# The delay, in seconds, required between /home, /tp, etc.
|
# The delay, in seconds, required between /home, /tp, etc.
|
||||||
teleport-cooldown: 0
|
teleport-cooldown: 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue