From 61c064bc680ef91c50130a57f439e22ed4676d3c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 8 Apr 2023 15:46:28 +0200 Subject: [PATCH] Hide Ghost in 5 block radius --- .../steamwar/lobby/jumpandrun/GhostJumpAndRun.java | 7 ++++++- src/de/steamwar/lobby/jumpandrun/JumpAndRun.java | 5 +---- .../lobby/jumpandrun/JumpAndRunCommand.java | 14 -------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/de/steamwar/lobby/jumpandrun/GhostJumpAndRun.java b/src/de/steamwar/lobby/jumpandrun/GhostJumpAndRun.java index b00f7a9..df41a64 100644 --- a/src/de/steamwar/lobby/jumpandrun/GhostJumpAndRun.java +++ b/src/de/steamwar/lobby/jumpandrun/GhostJumpAndRun.java @@ -4,6 +4,7 @@ import de.steamwar.entity.REntityServer; import de.steamwar.entity.RPlayer; import de.steamwar.lobby.LobbySystem; import de.steamwar.sql.UserConfig; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -134,7 +135,11 @@ public class GhostJumpAndRun implements Listener { entityPlayer = null; return; } - entityPlayer.move(iterator.next().toLocation(player.getWorld())); + Location location = iterator.next().toLocation(player.getWorld()); + if (player.getLocation().distanceSquared(location) < 25) { + location.add(0, 1000, 0); + } + entityPlayer.move(location); } }; replayRunnable.runTaskTimer(LobbySystem.getPlugin(), 1, 2); diff --git a/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java b/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java index ac7f5c4..ed16e47 100644 --- a/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java +++ b/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java @@ -27,7 +27,6 @@ public class JumpAndRun extends BasicListener { public static final String JUMP_AND_RUN_CONFIG = "jump_and_run"; public static final String JUMP_AND_RUN_REPLAY_CONFIG = "jump_and_run_replay"; - public static final String JUMP_AND_RUN_REPLAY_DISABLED_CONFIG = "jump_and_run_replay_disabled"; private static final String BAR_EMPTY = "||||||||||||||||||||||||||||||"; @@ -128,9 +127,7 @@ public class JumpAndRun extends BasicListener { FAILS.put(event.getPlayer(), 0); START.put(event.getPlayer(), System.currentTimeMillis()); GHOSTS.get(event.getPlayer()).record(); - if (UserConfig.getConfig(event.getPlayer().getUniqueId(), JUMP_AND_RUN_REPLAY_DISABLED_CONFIG) == null) { - GHOSTS.get(event.getPlayer()).replay(); - } + GHOSTS.get(event.getPlayer()).replay(); } if (index == points.size() - 1) { long time = System.currentTimeMillis() - START.get(event.getPlayer()); diff --git a/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java b/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java index b88f2e2..680f01b 100644 --- a/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java +++ b/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java @@ -9,8 +9,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -import static de.steamwar.lobby.jumpandrun.JumpAndRun.JUMP_AND_RUN_REPLAY_DISABLED_CONFIG; - public class JumpAndRunCommand extends SWCommand { public JumpAndRunCommand() { @@ -29,16 +27,4 @@ public class JumpAndRunCommand extends SWCommand { String parsed = format.format(new Date(timeLong)); LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PERSONAL_BEST_TIME", player, parsed); } - - @Register("togglereplay") - public void toggleReplay(Player player) { - String replay = UserConfig.getConfig(player.getUniqueId(), JUMP_AND_RUN_REPLAY_DISABLED_CONFIG); - if (replay == null) { - UserConfig.updatePlayerConfig(player.getUniqueId(), JUMP_AND_RUN_REPLAY_DISABLED_CONFIG, ""); - LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_REPLAY_ENABLED", player); - } else { - UserConfig.updatePlayerConfig(player.getUniqueId(), JUMP_AND_RUN_REPLAY_DISABLED_CONFIG, null); - LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_REPLAY_DISABLED", player); - } - } }