SteamWar/FightSystem
Archiviert
13
1

Merge branch 'master' into Anti_Ice_Melt
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
zOnlyKroks 2021-12-23 16:59:04 +01:00
Commit 5c8a00a25a
3 geänderte Dateien mit 31 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPistonExtendEvent;
@ -44,7 +45,8 @@ public class PistonListener implements Listener {
public void handlePistonExtend(BlockPistonExtendEvent e){
BlockFace face = e.getDirection();
for(Block block : e.getBlocks()){
if(!Config.BlueExtendRegion.inRegion(block.getRelative(face)) && !Config.RedExtendRegion.inRegion(block.getRelative(face))){
Block target = block.getRelative(face);
if(!Config.BlueExtendRegion.inRegion(target) && !Config.RedExtendRegion.inRegion(target) && block.getPistonMoveReaction() != PistonMoveReaction.BREAK) {
e.setCancelled(true);
return;
}

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region;
@ -37,10 +38,25 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
public class PrepareSchem implements Listener {
private final Set<Vector> stationaryMovingPistons = new HashSet<>();
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){
@Override
public void disable() {
@ -60,7 +76,7 @@ public class PrepareSchem implements Listener {
try{
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");
Bukkit.shutdown();
throw new IllegalStateException();

Datei anzeigen

@ -34,6 +34,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -77,6 +78,16 @@ public class TeamArea implements Listener {
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
}
@EventHandler
public void blockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if(Config.BluePasteRegion.getMinY() <= block.getY())
return;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
}
private void checkInTeamRegion(PlayerMoveEvent event, FightTeam team, Player player, FightTeam playerTeam) {
boolean spectator = player.getGameMode() == GameMode.SPECTATOR;
if(!spectator && playerTeam != null && playerTeam.canPlayerEntern(player))