diff --git a/src/main/java/com/tocard/cam/ClearPoints.java b/src/main/java/com/tocard/cam/ClearPoints.java index d5b59ff..98e33d7 100644 --- a/src/main/java/com/tocard/cam/ClearPoints.java +++ b/src/main/java/com/tocard/cam/ClearPoints.java @@ -24,19 +24,11 @@ public class ClearPoints implements CommandExecutor { Camera.broadlog("Clearing points and path:"); ListPoints.listPoints(); - Camera.controlPoints = new ArrayList<>(); - Camera.compute(); - - ClosePath.closed = false; - - for (World world : Bukkit.getWorlds()) { - for (Entity e : world.getEntities()) { - if (e.getScoreboardTags().contains("controlPoint")) { - e.remove(); - } - } + while (Camera.controlPoints.size() > 0) { + NewPoint.rm(new String[] { "", "0" }, null, null); } - ShowCurve.controlPointsArmorStands = new ArrayList<>(); + ClosePath.closed = false; + Camera.compute(); Camera.broadlog("All cleared !"); } diff --git a/src/main/java/com/tocard/cam/ExecuteTraveling.java b/src/main/java/com/tocard/cam/ExecuteTraveling.java index 196f78c..6c132e2 100644 --- a/src/main/java/com/tocard/cam/ExecuteTraveling.java +++ b/src/main/java/com/tocard/cam/ExecuteTraveling.java @@ -37,14 +37,17 @@ public class ExecuteTraveling implements CommandExecutor { return; } - // No more point, end traveling - if (!ClosePath.closed) { - Thread.currentThread().interrupt(); + // Regenerate traveling and begin + if (ClosePath.closed) { + curveIterator = Camera.curve.iterator(); + player.teleport(curveIterator.next()); + return; } - // Regenerate traveling and begin - curveIterator = Camera.curve.iterator(); - player.teleport(curveIterator.next()); + // Teleport to next point + int taskToKill = taskID; + taskID = -1; + Bukkit.getScheduler().cancelTask(taskToKill); } }, 0, 0); Bukkit.broadcastMessage("Traveling : " + taskID);