Delete src/main/java/de/lasertag/arena/Arena.java via Git Manager GUI
This commit is contained in:
@@ -1,153 +0,0 @@
|
||||
package de.lasertag.arena;
|
||||
|
||||
import de.lasertag.game.Team;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Repräsentiert eine konfigurierte Lasertag-Arena.
|
||||
*
|
||||
* Jedes Team braucht:
|
||||
* - mind. 1 Spawn-Punkt
|
||||
* - 1 Basispunkt (Regenerationspunkt + angreifbarer Block)
|
||||
*/
|
||||
public class Arena {
|
||||
|
||||
private final String name;
|
||||
private String displayName;
|
||||
private boolean enabled;
|
||||
|
||||
// Team-Spawns: team -> Liste von Spawn-Locations
|
||||
private final Map<Team, List<Location>> teamSpawns = new HashMap<>();
|
||||
|
||||
// Team-Basis: team -> Location des Basis-Blocks
|
||||
private final Map<Team, Location> teamBases = new HashMap<>();
|
||||
|
||||
// Team-Basis-Gesundheit (wie oft kann Basis angegriffen werden)
|
||||
private final Map<Team, Integer> baseHealth = new HashMap<>();
|
||||
|
||||
// Lobby dieser Arena (optionaler Wartebereich)
|
||||
private Location lobbyLocation;
|
||||
|
||||
// Bounds (optional, für Block-Schutz innerhalb der Arena)
|
||||
private Location corner1;
|
||||
private Location corner2;
|
||||
|
||||
public Arena(String name) {
|
||||
this.name = name;
|
||||
this.displayName = name;
|
||||
this.enabled = false;
|
||||
for (Team t : Team.values()) {
|
||||
teamSpawns.put(t, new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Validation ──────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Arena ist bereit wenn jedes Team mindestens 1 Spawn und 1 Basis hat.
|
||||
*/
|
||||
public boolean isReady() {
|
||||
for (Team t : Team.values()) {
|
||||
if (teamSpawns.get(t).isEmpty()) return false;
|
||||
if (!teamBases.containsKey(t)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getMissingSetup() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Team t : Team.values()) {
|
||||
if (teamSpawns.get(t).isEmpty())
|
||||
sb.append("§c- Kein Spawn für Team ").append(t.colored()).append("§c!\n");
|
||||
if (!teamBases.containsKey(t))
|
||||
sb.append("§c- Keine Basis für Team ").append(t.colored()).append("§c!\n");
|
||||
}
|
||||
return sb.length() == 0 ? "§aArena bereit!" : sb.toString().trim();
|
||||
}
|
||||
|
||||
// ─── Spawns ──────────────────────────────────────────────────────────────
|
||||
|
||||
public void addSpawn(Team team, Location loc) {
|
||||
teamSpawns.get(team).add(loc.clone());
|
||||
}
|
||||
|
||||
public List<Location> getSpawns(Team team) {
|
||||
return teamSpawns.get(team);
|
||||
}
|
||||
|
||||
public Location getRandomSpawn(Team team) {
|
||||
List<Location> spawns = teamSpawns.get(team);
|
||||
if (spawns.isEmpty()) return null;
|
||||
return spawns.get((int)(Math.random() * spawns.size())).clone();
|
||||
}
|
||||
|
||||
// ─── Bases ───────────────────────────────────────────────────────────────
|
||||
|
||||
public void setBase(Team team, Location loc) {
|
||||
teamBases.put(team, loc.clone());
|
||||
}
|
||||
|
||||
public Location getBase(Team team) {
|
||||
return teamBases.get(team);
|
||||
}
|
||||
|
||||
public boolean hasBase(Team team) {
|
||||
return teamBases.containsKey(team);
|
||||
}
|
||||
|
||||
/** Liefert das Team dessen Basis an der gegebenen Location steht, oder null. */
|
||||
public Team getBaseTeam(Location loc) {
|
||||
for (Map.Entry<Team, Location> e : teamBases.entrySet()) {
|
||||
Location base = e.getValue();
|
||||
if (base.getWorld().equals(loc.getWorld())
|
||||
&& base.getBlockX() == loc.getBlockX()
|
||||
&& base.getBlockY() == loc.getBlockY()
|
||||
&& base.getBlockZ() == loc.getBlockZ()) {
|
||||
return e.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ─── Base Health ─────────────────────────────────────────────────────────
|
||||
|
||||
public void initBaseHealth(int maxHealth) {
|
||||
for (Team t : Team.values()) baseHealth.put(t, maxHealth);
|
||||
}
|
||||
|
||||
public int getBaseHealth(Team team) {
|
||||
return baseHealth.getOrDefault(team, 0);
|
||||
}
|
||||
|
||||
public boolean damageBase(Team team) {
|
||||
int hp = baseHealth.getOrDefault(team, 0);
|
||||
if (hp <= 0) return false;
|
||||
baseHealth.put(team, hp - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isBaseDestroyed(Team team) {
|
||||
return baseHealth.getOrDefault(team, 0) <= 0;
|
||||
}
|
||||
|
||||
// ─── Getters / Setters ───────────────────────────────────────────────────
|
||||
|
||||
public String getName() { return name; }
|
||||
public String getDisplayName() { return displayName; }
|
||||
public void setDisplayName(String n) { this.displayName = n; }
|
||||
public boolean isEnabled() { return enabled; }
|
||||
public void setEnabled(boolean e) { this.enabled = e; }
|
||||
public Location getLobbyLocation() { return lobbyLocation; }
|
||||
public void setLobbyLocation(Location l) { this.lobbyLocation = l != null ? l.clone() : null; }
|
||||
public Location getCorner1() { return corner1; }
|
||||
public void setCorner1(Location l) { this.corner1 = l != null ? l.clone() : null; }
|
||||
public Location getCorner2() { return corner2; }
|
||||
public void setCorner2(Location l) { this.corner2 = l != null ? l.clone() : null; }
|
||||
public Map<Team, List<Location>> getAllSpawns() { return teamSpawns; }
|
||||
public Map<Team, Location> getAllBases() { return teamBases; }
|
||||
}
|
||||
Reference in New Issue
Block a user