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() {
Camera.broadlog("Clearing points and path:");
ListPoints.listPoints();
while (Camera.controlPoints.size() > 0) {
NewPoint.rm(new String[] { "", "0" }, null, null);
}
ClosePath.closed = false;
Camera.compute();
Camera.broadlog("All cleared !");

View file

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