From 98f95a577b07a91bc7c4a15c0bf41a521f45357c Mon Sep 17 00:00:00 2001 From: RoboMWM Date: Mon, 9 Oct 2017 08:48:05 -0700 Subject: [PATCH] allow movement prevention to be toggled --- .../us/tf/DeathSpectating/tasks/SpectateTask.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/to/us/tf/DeathSpectating/tasks/SpectateTask.java b/src/main/java/to/us/tf/DeathSpectating/tasks/SpectateTask.java index 82ded42..9d62cc6 100644 --- a/src/main/java/to/us/tf/DeathSpectating/tasks/SpectateTask.java +++ b/src/main/java/to/us/tf/DeathSpectating/tasks/SpectateTask.java @@ -23,6 +23,7 @@ public class SpectateTask extends BukkitRunnable private String unformattedTitle; private String unformattedSubTitle; private int score; + private boolean preventMovement = true; public SpectateTask(Player player, long ticks, @Nullable Entity killer, DeathSpectating deathSpectating) { @@ -88,6 +89,16 @@ public void setUnformattedSubTitle(String unformattedSubTitle) this.unformattedSubTitle = unformattedSubTitle; } + public boolean hasPreventMovement() + { + return preventMovement; + } + + public void setPreventMovement(boolean preventMovement) + { + this.preventMovement = preventMovement; + } + public void run() { if (player.isDead() && instance.isSpectating(player)) //A plugin (e.g. Essentials) did Player#setHealth(0) @@ -124,7 +135,8 @@ public void run() } //player.setSpectatorTarget(player); - player.setFlySpeed(0f); //does this even work for spectators? + if (preventMovement) + player.setFlySpeed(0f); ticks--; }