Add TURN_IN_RADIUS config and spawn particles at turn in point as well
Introduced a new TURN_IN_RADIUS configuration parameter to manage flag turn-in distance. Refactored particle spawning logic to use configurable radii and adjusted related methods accordingly for better flexibility and maintainability.
This commit is contained in:
parent
5f2fb8fe0a
commit
6f99402d16
|
|
@ -87,6 +87,7 @@ public class GameConfig extends AbstractConfig {
|
|||
public static double z = 0;
|
||||
public static double CAPTURE_RADIUS = 5;
|
||||
public static int CAPTURE_SCORE = 50;
|
||||
public static double TURN_IN_RADIUS = 3;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void load() {
|
||||
|
|
@ -96,6 +97,7 @@ public class GameConfig extends AbstractConfig {
|
|||
z = config.getDouble(prefix, "z", z);
|
||||
CAPTURE_RADIUS = config.getDouble(prefix, "capture-radius", CAPTURE_RADIUS);
|
||||
CAPTURE_SCORE = config.getInt(prefix, "capture-score", CAPTURE_SCORE);
|
||||
TURN_IN_RADIUS = config.getDouble(prefix, "turn-in-radius", TURN_IN_RADIUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class Flag implements Runnable {
|
|||
log.warn("Tried to run Flag without a flag location, spawn it first");
|
||||
return;
|
||||
}
|
||||
spawnParticlesOnSquareBorder(flagLocation.getWorld(), flagLocation);
|
||||
spawnParticlesOnSquareBorder(flagLocation, GameConfig.FLAG.CAPTURE_RADIUS);
|
||||
if (!updateScoreBasedOnNearbyPlayers().join()) {
|
||||
return; //Score didn't change
|
||||
}
|
||||
|
|
@ -121,9 +121,9 @@ public class Flag implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
private void spawnParticlesOnSquareBorder(World world, Location center) {
|
||||
double size = GameConfig.FLAG.CAPTURE_RADIUS;
|
||||
private void spawnParticlesOnSquareBorder(Location center, double size) {
|
||||
double step = 0.2;
|
||||
World world = center.getWorld();
|
||||
Location finalCenter = center.clone().add(0, 0.5, 0);
|
||||
Bukkit.getScheduler().runTask(main, () -> {
|
||||
// Top and Bottom (Z varies, X constant)
|
||||
|
|
@ -159,11 +159,12 @@ public class Flag implements Runnable {
|
|||
return;
|
||||
}
|
||||
double distance = winningTeam.getFlagTurnInLocation().distance(flagCarrier.getLocation());
|
||||
if (distance > 2) {
|
||||
if (distance > GameConfig.FLAG.TURN_IN_RADIUS) {
|
||||
Location location = flagCarrier.getLocation();
|
||||
location.setY(location.getY() + 1);
|
||||
particleTrail.add(location);
|
||||
spawnTrail();
|
||||
spawnParticlesOnSquareBorder(winningTeam.getWorldBorderCenter(), GameConfig.FLAG.TURN_IN_RADIUS);
|
||||
return;
|
||||
}
|
||||
//TODO better message? mayb with a text thing on the screen?
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user