|
3 | 3 | import org.bukkit.Location; |
4 | 4 | import org.bukkit.entity.Entity; |
5 | 5 | import org.bukkit.entity.Player; |
| 6 | +import org.bukkit.metadata.FixedMetadataValue; |
6 | 7 | import org.bukkit.scheduler.BukkitRunnable; |
7 | 8 | import org.bukkit.util.Vector; |
8 | 9 | import to.us.tf.DeathSpectating.DeathSpectating; |
@@ -40,7 +41,7 @@ public SpectateTask(Player player, long ticks, @Nullable Entity killer, DeathSpe |
40 | 41 | this.unformattedTitle = deathSpectating.getConfigManager().getDeathTitle("titles"); |
41 | 42 | this.unformattedSubTitle = deathSpectating.getConfigManager().getDeathTitle("subtitles"); |
42 | 43 | this.score = player.getTotalExperience(); |
43 | | - this.deathLocation = player.getLocation().clone(); |
| 44 | + this.deathLocation = player.getLocation(); |
44 | 45 | } |
45 | 46 |
|
46 | 47 | public Player getPlayer() |
@@ -134,18 +135,24 @@ public void run() |
134 | 135 | if (preventMovement && killer != null && killer.isValid() && !killer.isDead() && killer.getWorld() == player.getWorld()) |
135 | 136 | { |
136 | 137 | vector = killer.getLocation().toVector().subtract(deathLocation.toVector()); |
137 | | - player.teleport(deathLocation.setDirection(vector)); |
| 138 | + teleportPlayer(deathLocation.setDirection(vector)); |
138 | 139 | player.setFlySpeed(0f); |
139 | 140 | player.setSpectatorTarget(null); |
140 | 141 | } |
141 | 142 | else if (preventMovement) |
142 | 143 | { |
143 | 144 | if (deathLocation.distanceSquared(player.getLocation()) > 1) |
144 | | - player.teleport(deathLocation.setDirection(player.getLocation().getDirection())); |
| 145 | + teleportPlayer(deathLocation.setDirection(player.getLocation().getDirection())); |
145 | 146 | player.setFlySpeed(0f); |
146 | 147 | player.setSpectatorTarget(null); |
147 | 148 | } |
148 | 149 |
|
149 | 150 | ticks--; |
150 | 151 | } |
| 152 | + |
| 153 | + public void teleportPlayer(Location location) |
| 154 | + { |
| 155 | + player.setMetadata("DS_TP", new FixedMetadataValue(instance, true)); |
| 156 | + player.teleport(location); |
| 157 | + } |
151 | 158 | } |
0 commit comments