SteamWar/FightSystem
Archiviert
13
1

Allow stationary moving pistons during preparation #316

Zusammengeführt
Lixfel hat 1 Commits von stationaryMovingPistons nach master 2021-12-23 11:42:05 +01:00 zusammengeführt

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.Region;
@ -37,10 +38,25 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
public class PrepareSchem implements Listener { public class PrepareSchem implements Listener {
private final Set<Vector> stationaryMovingPistons = new HashSet<>();
public PrepareSchem() { public PrepareSchem() {
new OneShotStateDependent(ArenaMode.Prepare, FightState.PostSchemSetup, () -> Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
stationaryMovingPistons.clear();
World world = Bukkit.getWorlds().get(0);
Fight.getUnrotated().getSchemRegion().forEach((x, y, z) -> {
if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z)))
stationaryMovingPistons.add(new Vector(x, y, z));
});
}, 1));
new StateDependentListener(ArenaMode.Prepare, FightState.Setup, this){ new StateDependentListener(ArenaMode.Prepare, FightState.Setup, this){
@Override @Override
public void disable() { public void disable() {
@ -60,7 +76,7 @@ public class PrepareSchem implements Listener {
try{ try{
region.forEach((x, y, z) -> { region.forEach((x, y, z) -> {
if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z))){ if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z)) && !stationaryMovingPistons.contains(new Vector(x, y, z))){
FightSystem.getMessage().broadcast("PREPARE_ACTIVE_PISTON"); FightSystem.getMessage().broadcast("PREPARE_ACTIVE_PISTON");
Bukkit.shutdown(); Bukkit.shutdown();
throw new IllegalStateException(); throw new IllegalStateException();