Update from Git Manager GUI
This commit is contained in:
@@ -13,6 +13,8 @@ public class Arena implements ConfigurationSerializable {
|
||||
private Location center, redSpawn, blueSpawn, ballSpawn;
|
||||
private Location redGoalMin, redGoalMax, blueGoalMin, blueGoalMax, lobby;
|
||||
private Location fieldMin, fieldMax;
|
||||
// Strafräume – optional manuell gesetzt; sonst auto-berechnet aus Tor + config
|
||||
private Location redPenaltyMin, redPenaltyMax, bluePenaltyMin, bluePenaltyMax;
|
||||
private int minPlayers, maxPlayers, gameDuration;
|
||||
|
||||
/**
|
||||
@@ -43,6 +45,82 @@ public class Arena implements ConfigurationSerializable {
|
||||
public boolean isInRedGoal(Location loc) { return isInRegion(loc, redGoalMin, redGoalMax); }
|
||||
public boolean isInBlueGoal(Location loc) { return isInRegion(loc, blueGoalMin, blueGoalMax); }
|
||||
|
||||
// ── Strafraum ────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Prüft ob eine Position im roten Strafraum liegt.
|
||||
* Wenn manuell gesetzte Punkte vorhanden sind, werden diese verwendet.
|
||||
* Sonst wird der Strafraum automatisch aus den Tor-Koordinaten + config berechnet.
|
||||
*/
|
||||
public boolean isInRedPenaltyArea(Location loc) {
|
||||
if (redPenaltyMin != null && redPenaltyMax != null) {
|
||||
return isInRegion2D(loc, redPenaltyMin, redPenaltyMax);
|
||||
}
|
||||
return isAutoCalculatedPenaltyArea(loc, redGoalMin, redGoalMax, true);
|
||||
}
|
||||
|
||||
public boolean isInBluePenaltyArea(Location loc) {
|
||||
if (bluePenaltyMin != null && bluePenaltyMax != null) {
|
||||
return isInRegion2D(loc, bluePenaltyMin, bluePenaltyMax);
|
||||
}
|
||||
return isAutoCalculatedPenaltyArea(loc, blueGoalMin, blueGoalMax, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatisch berechneter Strafraum.
|
||||
* Erweitert das Tor um 'penalty-area-margin' seitwärts und 'penalty-area-depth'
|
||||
* in Richtung Spielfeldmitte.
|
||||
*/
|
||||
private boolean isAutoCalculatedPenaltyArea(Location loc, Location gMin, Location gMax, boolean isRedGoal) {
|
||||
if (gMin == null || gMax == null || loc == null) return false;
|
||||
Fussball plugin = Fussball.getInstance();
|
||||
double depth = plugin != null ? plugin.getConfig().getDouble("gameplay.penalty-area-depth", 16) : 16;
|
||||
double margin = plugin != null ? plugin.getConfig().getDouble("gameplay.penalty-area-margin", 6) : 6;
|
||||
|
||||
double minX = Math.min(gMin.getX(), gMax.getX()) - margin;
|
||||
double maxX = Math.max(gMin.getX(), gMax.getX()) + margin;
|
||||
double minZ = Math.min(gMin.getZ(), gMax.getZ()) - margin;
|
||||
double maxZ = Math.max(gMin.getZ(), gMax.getZ()) + margin;
|
||||
|
||||
org.bukkit.util.Vector dir = getFieldDirection();
|
||||
if (dir != null) {
|
||||
double redAxis = getRedGoalAxisValue();
|
||||
double blueAxis = getBlueGoalAxisValue();
|
||||
// Strafraum erstreckt sich VOM Tor in Richtung Feldmitte
|
||||
if (Math.abs(dir.getZ()) > Math.abs(dir.getX())) {
|
||||
// Feld läuft entlang Z-Achse
|
||||
if (isRedGoal) {
|
||||
if (redAxis < blueAxis) maxZ = Math.max(maxZ, maxZ + depth);
|
||||
else minZ = Math.min(minZ, minZ - depth);
|
||||
} else {
|
||||
if (blueAxis > redAxis) minZ = Math.min(minZ, minZ - depth);
|
||||
else maxZ = Math.max(maxZ, maxZ + depth);
|
||||
}
|
||||
} else {
|
||||
// Feld läuft entlang X-Achse
|
||||
if (isRedGoal) {
|
||||
if (redAxis < blueAxis) maxX = Math.max(maxX, maxX + depth);
|
||||
else minX = Math.min(minX, minX - depth);
|
||||
} else {
|
||||
if (blueAxis > redAxis) minX = Math.min(minX, minX - depth);
|
||||
else maxX = Math.max(maxX, maxX + depth);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Keine Richtungsinformation → gleichmäßig ausdehnen
|
||||
minX -= depth / 2; maxX += depth / 2;
|
||||
minZ -= depth / 2; maxZ += depth / 2;
|
||||
}
|
||||
|
||||
return loc.getX() >= minX && loc.getX() <= maxX && loc.getZ() >= minZ && loc.getZ() <= maxZ;
|
||||
}
|
||||
|
||||
private boolean isInRegion2D(Location loc, Location min, Location max) {
|
||||
if (min == null || max == null || loc == null) return false;
|
||||
return loc.getX() >= Math.min(min.getX(), max.getX()) && loc.getX() <= Math.max(min.getX(), max.getX())
|
||||
&& loc.getZ() >= Math.min(min.getZ(), max.getZ()) && loc.getZ() <= Math.max(min.getZ(), max.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* BUG FIX: Nur X und Z prüfen (Y ignorieren).
|
||||
* Vorher führte die Y-Prüfung dazu, dass der Ball beim Anstoß sofort
|
||||
@@ -173,6 +251,10 @@ public class Arena implements ConfigurationSerializable {
|
||||
if (blueGoalMax != null) map.put("blueGoalMax", serLoc(blueGoalMax));
|
||||
if (fieldMin != null) map.put("fieldMin", serLoc(fieldMin));
|
||||
if (fieldMax != null) map.put("fieldMax", serLoc(fieldMax));
|
||||
if (redPenaltyMin != null) map.put("redPenaltyMin", serLoc(redPenaltyMin));
|
||||
if (redPenaltyMax != null) map.put("redPenaltyMax", serLoc(redPenaltyMax));
|
||||
if (bluePenaltyMin != null) map.put("bluePenaltyMin", serLoc(bluePenaltyMin));
|
||||
if (bluePenaltyMax != null) map.put("bluePenaltyMax", serLoc(bluePenaltyMax));
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -197,6 +279,10 @@ public class Arena implements ConfigurationSerializable {
|
||||
if (map.containsKey("blueGoalMax")) a.blueGoalMax = desLoc(map.get("blueGoalMax"));
|
||||
if (map.containsKey("fieldMin")) a.fieldMin = desLoc(map.get("fieldMin"));
|
||||
if (map.containsKey("fieldMax")) a.fieldMax = desLoc(map.get("fieldMax"));
|
||||
if (map.containsKey("redPenaltyMin")) a.redPenaltyMin = desLoc(map.get("redPenaltyMin"));
|
||||
if (map.containsKey("redPenaltyMax")) a.redPenaltyMax = desLoc(map.get("redPenaltyMax"));
|
||||
if (map.containsKey("bluePenaltyMin")) a.bluePenaltyMin = desLoc(map.get("bluePenaltyMin"));
|
||||
if (map.containsKey("bluePenaltyMax")) a.bluePenaltyMax = desLoc(map.get("bluePenaltyMax"));
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -244,6 +330,16 @@ public class Arena implements ConfigurationSerializable {
|
||||
public void setFieldMin(Location l) { this.fieldMin = l; }
|
||||
public Location getFieldMax() { return fieldMax; }
|
||||
public void setFieldMax(Location l) { this.fieldMax = l; }
|
||||
public Location getRedPenaltyMin() { return redPenaltyMin; }
|
||||
public void setRedPenaltyMin(Location l) { this.redPenaltyMin = l; }
|
||||
public Location getRedPenaltyMax() { return redPenaltyMax; }
|
||||
public void setRedPenaltyMax(Location l) { this.redPenaltyMax = l; }
|
||||
public Location getBluePenaltyMin() { return bluePenaltyMin; }
|
||||
public void setBluePenaltyMin(Location l) { this.bluePenaltyMin = l; }
|
||||
public Location getBluePenaltyMax() { return bluePenaltyMax; }
|
||||
public void setBluePenaltyMax(Location l) { this.bluePenaltyMax = l; }
|
||||
public boolean hasManualpPenaltyAreas() { return redPenaltyMin != null && redPenaltyMax != null
|
||||
&& bluePenaltyMin != null && bluePenaltyMax != null; }
|
||||
public int getMinPlayers() { return minPlayers; }
|
||||
public void setMinPlayers(int n) { this.minPlayers = n; }
|
||||
public int getMaxPlayers() { return maxPlayers; }
|
||||
|
||||
Reference in New Issue
Block a user