feat: /point rm i
This commit is contained in:
parent
6c7f9f2e94
commit
1aa618865c
|
@ -49,6 +49,10 @@ public class Camera extends JavaPlugin implements Listener {
|
|||
int nControlPoints = controlPoints.size();
|
||||
curve = new ArrayList<>();
|
||||
|
||||
if (nControlPoints == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nControlPoints <= 4) {
|
||||
for (float t = 0; t < 1; t += dt) {
|
||||
ArrayList<Location> P = new ArrayList<>(controlPoints);
|
||||
|
@ -63,7 +67,9 @@ public class Camera extends JavaPlugin implements Listener {
|
|||
|
||||
curve.add(P.get(0));
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
int nBezier = (nControlPoints - 1) / 3;
|
||||
for (int iBezier = 0; iBezier < nBezier; iBezier++) {
|
||||
for (float t = 0; t < 1; t += dt) {
|
||||
|
@ -84,7 +90,6 @@ public class Camera extends JavaPlugin implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void broadlog(String msg) {
|
||||
Camera.logger.log(Level.INFO, msg);
|
||||
|
|
|
@ -25,10 +25,8 @@ public class ClearPoints implements CommandExecutor {
|
|||
ListPoints.listPoints();
|
||||
|
||||
Camera.controlPoints = new ArrayList<>();
|
||||
Camera.broadlog("Points cleared !");
|
||||
|
||||
Camera.curve = new ArrayList<>();
|
||||
Camera.broadlog("Path cleared !");
|
||||
Camera.compute();
|
||||
Camera.broadlog("All cleared !");
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity e : world.getEntities()) {
|
||||
|
|
|
@ -22,9 +22,6 @@ public class NewPoint implements CommandExecutor {
|
|||
case "add":
|
||||
add(args);
|
||||
break;
|
||||
case "ins":
|
||||
ins(args);
|
||||
break;
|
||||
case "rm":
|
||||
rm(args);
|
||||
break;
|
||||
|
@ -40,9 +37,8 @@ public class NewPoint implements CommandExecutor {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (Camera.controlPoints.size() > 0) {
|
||||
Camera.compute(); // update camera path
|
||||
}
|
||||
// Update camera path
|
||||
Camera.compute();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -58,6 +54,12 @@ public class NewPoint implements CommandExecutor {
|
|||
Camera.broadlog("Point n°" + index + " set: " + Camera.prettyLocation(point));
|
||||
}
|
||||
|
||||
public static void rmPoint(int index) {
|
||||
location = Camera.controlPoints.remove(index);
|
||||
ShowCurve.rm(index);
|
||||
Camera.broadlog("Point deleted: " + Camera.prettyLocation(location));
|
||||
}
|
||||
|
||||
public static void add(String[] args) {
|
||||
World world = player.getWorld();
|
||||
location = player.getLocation();
|
||||
|
@ -77,6 +79,7 @@ public class NewPoint implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void ins(String[] args) {
|
||||
index = Integer.parseInt(args[1]);
|
||||
location = player.getLocation();
|
||||
|
@ -87,10 +90,25 @@ public class NewPoint implements CommandExecutor {
|
|||
|
||||
public static void rm(String[] args) {
|
||||
index = Integer.parseInt(args[1]);
|
||||
location = Camera.controlPoints.get(index);
|
||||
Camera.controlPoints.remove(location);
|
||||
Camera.broadlog("Point deleted: " + Camera.prettyLocation(location));
|
||||
ShowCurve.rm(index);
|
||||
int n = Camera.controlPoints.size();
|
||||
|
||||
if (n <= 4) {
|
||||
rmPoint(index);
|
||||
return;
|
||||
}
|
||||
|
||||
int indMin;
|
||||
if (index == 0 || index == 1) {
|
||||
indMin = 0;
|
||||
} else if (index == n - 1 || index == n - 2) {
|
||||
indMin = n - 3;
|
||||
} else {
|
||||
indMin = (index - 2) / 3 * 3 + 2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rmPoint(indMin);
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(String[] args) {
|
||||
|
@ -101,7 +119,9 @@ public class NewPoint implements CommandExecutor {
|
|||
|
||||
if (n <= 4) {
|
||||
setPoint(index, location, world);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (index % 3) {
|
||||
case 0:
|
||||
// Anchor point
|
||||
|
@ -154,6 +174,6 @@ public class NewPoint implements CommandExecutor {
|
|||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue