diff --git a/src/de/steamwar/towerrun/config/WorldConfig.java b/src/de/steamwar/towerrun/config/WorldConfig.java index 3c71f4f..6cf6c92 100644 --- a/src/de/steamwar/towerrun/config/WorldConfig.java +++ b/src/de/steamwar/towerrun/config/WorldConfig.java @@ -20,6 +20,9 @@ package de.steamwar.towerrun.config; 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 lombok.Getter; import lombok.experimental.UtilityClass; @@ -30,9 +33,8 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.util.Vector; import java.io.File; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @UtilityClass public class WorldConfig { @@ -46,6 +48,13 @@ public class WorldConfig { public static final Location MAX_TOWER; public static final List ACTIVE_WINCONDITIONS; + public static final List WINCONDITIONS = new ArrayList<>(); + static { + WINCONDITIONS.add(new LastRemainingWincondition()); + WINCONDITIONS.add(new LastOutsideWincondition()); + WINCONDITIONS.add(new FirstOutsideWincondition()); + } + private static Location parseLocation(ConfigurationSection section) { Location loc = new Location( Bukkit.getWorlds().get(0), @@ -70,8 +79,6 @@ public class WorldConfig { } ConfigurationSection config = YamlConfiguration.loadConfiguration(configFile); - System.out.println(configFile.getAbsolutePath()); - System.out.println(config.getKeys(false)); ConfigurationSection tower = config.getConfigurationSection("tower"); List regions = tower.getConfigurationSection("regions").getKeys(false).stream() @@ -119,8 +126,8 @@ public class WorldConfig { } LAVA_Y = tower.getInt("lavaY"); - ACTIVE_WINCONDITIONS = tower.getStringList("winconditions"); - WinCondition.WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(WinCondition::enable); + ACTIVE_WINCONDITIONS = config.getStringList("winconditions"); + WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(winCondition -> winCondition.setActive(true)); } @Getter diff --git a/src/de/steamwar/towerrun/game/TowerRunPlayer.java b/src/de/steamwar/towerrun/game/TowerRunPlayer.java index 87347d8..db445dd 100644 --- a/src/de/steamwar/towerrun/game/TowerRunPlayer.java +++ b/src/de/steamwar/towerrun/game/TowerRunPlayer.java @@ -20,6 +20,7 @@ package de.steamwar.towerrun.game; import de.steamwar.towerrun.config.WorldConfig; +import lombok.ToString; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -46,4 +47,11 @@ public record TowerRunPlayer(Player player) { player.teleport(WorldConfig.SPAWN); player.setVelocity(new Vector(0, 0, 0)); } + + @Override + public String toString() { + return "TowerRunPlayer{" + + "player=" + player.getName() + + '}'; + } } diff --git a/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java b/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java index 9f105d2..967d209 100644 --- a/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java +++ b/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java @@ -51,7 +51,7 @@ public abstract class OutsideWincondition extends WinCondition { return; } - if (event.getPlayer().getLocation().add(0, -0.1, 0).getBlock().getType() == Material.AIR) { + if (event.getPlayer().getVelocity().getY() != -0.0784000015258789) { return; } diff --git a/src/de/steamwar/towerrun/winconditions/WinCondition.java b/src/de/steamwar/towerrun/winconditions/WinCondition.java index aceca1d..4a736dd 100644 --- a/src/de/steamwar/towerrun/winconditions/WinCondition.java +++ b/src/de/steamwar/towerrun/winconditions/WinCondition.java @@ -29,13 +29,6 @@ import java.util.*; @Getter public abstract class WinCondition extends GameStateBukkitListener { - public static final List WINCONDITIONS = new ArrayList<>(); - static { - WINCONDITIONS.add(new LastRemainingWincondition()); - WINCONDITIONS.add(new LastOutsideWincondition()); - WINCONDITIONS.add(new FirstOutsideWincondition()); - } - private final String name; @Setter private boolean active = false;