Fixed amulet of glory wilderness teleport level

This commit is contained in:
LostMyPhat
2023-11-05 08:42:48 +00:00
committed by Ryan
parent e1b7eeaf22
commit 18fa8357a8
2 changed files with 123 additions and 1 deletions
@@ -203,7 +203,7 @@ public final class ZoneMonitor {
* @return {@code True} if so.
*/
public boolean teleport(int type, Node node) {
if (type != -1 && entity.isTeleBlocked()) {
if (type != -1 && entity.isTeleBlocked() && !canTeleportByGlory(type, node)) {
if (entity.isPlayer()) {
entity.asPlayer().sendMessage("A magical force has stopped you from teleporting.");
}
@@ -217,6 +217,34 @@ public final class ZoneMonitor {
return true;
}
/**
* Checks if a player can teleport with a glory in >= 1 <= 30 wilderness level
* @return {@code True} if so.
*/
private boolean canTeleportByGlory(int type, Node node) {
if (type != 1 || !node.asItem().getName().contains("Amulet of glory")) {
return false;
}
if (entity.timers.getTimer("teleblock") != null)
return false;
if (entity.getZoneMonitor().isRestricted(ZoneRestriction.TELEPORT)) {
return false;
}
if (entity.getLocks().isTeleportLocked()) {
if (entity.isPlayer()) {
Player p = entity.asPlayer();
if (p.getSkullManager().getLevel() >= 1 && p.getSkullManager().getLevel() <= 30) {
return true;
}
}
}
return false;
}
/**
* Checks if the death should start for an entity.
* @param entity the entity.