split ClosePath

This commit is contained in:
Laureηt 2022-05-16 21:10:58 +02:00
parent 53f5408d91
commit f808f34330
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
2 changed files with 22 additions and 15 deletions

View file

@ -17,12 +17,15 @@ public class ClearPoints implements CommandExecutor {
public static void clear() { public static void clear() {
Camera.broadlog("Clearing points and path:"); Camera.broadlog("Clearing points and path:");
ListPoints.listPoints(); ListPoints.listPoints();
while (Camera.controlPoints.size() > 0) { while (Camera.controlPoints.size() > 0) {
NewPoint.rm(new String[] { "", "0" }, null, null); NewPoint.rm(new String[] { "", "0" }, null, null);
} }
ClosePath.closed = false; ClosePath.closed = false;
Camera.compute(); Camera.compute();
Camera.broadlog("All cleared !"); Camera.broadlog("All cleared !");

View file

@ -12,24 +12,28 @@ public class ClosePath implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) { if (sender instanceof Player) {
Player player = (Player) sender; close();
}
return true;
}
public void close() {
if (!closed && Camera.controlPoints.size() >= 4) { if (!closed && Camera.controlPoints.size() >= 4) {
closed = true; closed = true;
NewPoint.add(null, Camera.controlPoints.get(0), player.getWorld());
NewPoint.add(null, Camera.controlPoints.get(0), Camera.controlPoints.get(0).getWorld());
NewPoint.set(new String[] { "", "" + (Camera.controlPoints.size() - 2) }, NewPoint.set(new String[] { "", "" + (Camera.controlPoints.size() - 2) },
Camera.controlPoints.get(0).clone().multiply(2) Camera.controlPoints.get(0).clone().multiply(2).subtract(Camera.controlPoints.get(1)),
.subtract(Camera.controlPoints.get(1)), Camera.controlPoints.get(0).getWorld());
player.getWorld());
} else if (closed) { } else if (closed) {
closed = false; closed = false;
NewPoint.rm(new String[] { "", "" + (Camera.controlPoints.size() - 1) }, null, null); NewPoint.rm(new String[] { "", "" + (Camera.controlPoints.size() - 1) }, null, null);
} }
Camera.compute(); Camera.compute();
} }
return true;
}
} }