Archiviert
13
0
Dieser Commit ist enthalten in:
Chaoscaot 2023-08-13 20:56:06 +02:00
Ursprung 1d153c6a17
Commit ac499b32b8
Signiert von: Chaoscaot
GPG-Schlüssel-ID: BDF8FADD7D5EDB7A
4 geänderte Dateien mit 22 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,9 @@
package de.steamwar.towerrun.config; package de.steamwar.towerrun.config;
import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.TowerRun;
import de.steamwar.towerrun.winconditions.FirstOutsideWincondition;
import de.steamwar.towerrun.winconditions.LastOutsideWincondition;
import de.steamwar.towerrun.winconditions.LastRemainingWincondition;
import de.steamwar.towerrun.winconditions.WinCondition; import de.steamwar.towerrun.winconditions.WinCondition;
import lombok.Getter; import lombok.Getter;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@ -30,9 +33,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
@UtilityClass @UtilityClass
public class WorldConfig { public class WorldConfig {
@ -46,6 +48,13 @@ public class WorldConfig {
public static final Location MAX_TOWER; public static final Location MAX_TOWER;
public static final List<String> ACTIVE_WINCONDITIONS; public static final List<String> ACTIVE_WINCONDITIONS;
public static final List<WinCondition> WINCONDITIONS = new ArrayList<>();
static {
WINCONDITIONS.add(new LastRemainingWincondition());
WINCONDITIONS.add(new LastOutsideWincondition());
WINCONDITIONS.add(new FirstOutsideWincondition());
}
private static Location parseLocation(ConfigurationSection section) { private static Location parseLocation(ConfigurationSection section) {
Location loc = new Location( Location loc = new Location(
Bukkit.getWorlds().get(0), Bukkit.getWorlds().get(0),
@ -70,8 +79,6 @@ public class WorldConfig {
} }
ConfigurationSection config = YamlConfiguration.loadConfiguration(configFile); ConfigurationSection config = YamlConfiguration.loadConfiguration(configFile);
System.out.println(configFile.getAbsolutePath());
System.out.println(config.getKeys(false));
ConfigurationSection tower = config.getConfigurationSection("tower"); ConfigurationSection tower = config.getConfigurationSection("tower");
List<ConfigurationSection> regions = tower.getConfigurationSection("regions").getKeys(false).stream() List<ConfigurationSection> regions = tower.getConfigurationSection("regions").getKeys(false).stream()
@ -119,8 +126,8 @@ public class WorldConfig {
} }
LAVA_Y = tower.getInt("lavaY"); LAVA_Y = tower.getInt("lavaY");
ACTIVE_WINCONDITIONS = tower.getStringList("winconditions"); ACTIVE_WINCONDITIONS = config.getStringList("winconditions");
WinCondition.WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(WinCondition::enable); WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(winCondition -> winCondition.setActive(true));
} }
@Getter @Getter

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.towerrun.game; package de.steamwar.towerrun.game;
import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.config.WorldConfig;
import lombok.ToString;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -46,4 +47,11 @@ public record TowerRunPlayer(Player player) {
player.teleport(WorldConfig.SPAWN); player.teleport(WorldConfig.SPAWN);
player.setVelocity(new Vector(0, 0, 0)); player.setVelocity(new Vector(0, 0, 0));
} }
@Override
public String toString() {
return "TowerRunPlayer{" +
"player=" + player.getName() +
'}';
}
} }

Datei anzeigen

@ -51,7 +51,7 @@ public abstract class OutsideWincondition extends WinCondition {
return; return;
} }
if (event.getPlayer().getLocation().add(0, -0.1, 0).getBlock().getType() == Material.AIR) { if (event.getPlayer().getVelocity().getY() != -0.0784000015258789) {
return; return;
} }

Datei anzeigen

@ -29,13 +29,6 @@ import java.util.*;
@Getter @Getter
public abstract class WinCondition extends GameStateBukkitListener { public abstract class WinCondition extends GameStateBukkitListener {
public static final List<WinCondition> WINCONDITIONS = new ArrayList<>();
static {
WINCONDITIONS.add(new LastRemainingWincondition());
WINCONDITIONS.add(new LastOutsideWincondition());
WINCONDITIONS.add(new FirstOutsideWincondition());
}
private final String name; private final String name;
@Setter @Setter
private boolean active = false; private boolean active = false;