Added support to the ActivityPlugin system to set a safe respawn location

Fixed pest control deaths sometimes respawning in Lumbridge
Admins can now kill themselves with ::killme
This commit is contained in:
Ceikry
2022-03-08 02:24:34 +00:00
committed by Ryan
parent 9d41d998d0
commit 4ca143129a
5 changed files with 19 additions and 1 deletions
@@ -44,6 +44,12 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
*/
protected Location base;
/**
* A location which the player is teleported to in the case of death, if this activity is safe.
* Defaults to the home location of the server.
*/
protected Location safeRespawn = ServerConstants.HOME_LOCATION;
/**
* The player.
*/
@@ -134,6 +140,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
e.getProperties().setSpawnLocation(l);
}
e.getProperties().setSafeZone(safe);
e.getProperties().safeRespawn = this.safeRespawn;
e.setAttribute("activity", this);
return super.enter(e);
}
@@ -148,6 +155,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
e.setLocation(l);
}
e.getProperties().setSafeZone(false);
e.getProperties().safeRespawn = ServerConstants.HOME_LOCATION;
e.removeAttribute("activity");
return super.leave(e, logout);
}
@@ -193,6 +193,7 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
*/
public PestControlActivityPlugin(BoatType type) {
super("pest control " + type.name().toLowerCase(), false, true, true, ZoneRestriction.CANNON);
this.safeRespawn = Location.create(2657, 2646, 0);
this.type = type;
}
@@ -86,7 +86,7 @@ public final class DeathTask extends NodeTask {
Entity killer = n.length > 0 ? (Entity) n[0] : e;
e.removeAttribute("state:death");
e.removeAttribute("tick:death");
Location spawn = e.getProperties().getSpawnLocation();
Location spawn = e.getProperties().isSafeZone() ? e.getProperties().safeRespawn : e.getProperties().getSpawnLocation();
e.getAnimator().forceAnimation(Animator.RESET_A);
e.getProperties().setTeleportLocation(spawn);
e.unlock();
@@ -130,6 +130,11 @@ public final class Properties {
*/
private boolean safeZone;
/**
* The location which the player respawns at the event of death while safeZone = true
*/
public Location safeRespawn;
/**
* The combat time out ticks.
*/