SteamWar/FightSystem
Archiviert
13
1

WaterRemover remove on direct water hit
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-03-14 09:49:51 +01:00
Ursprung acf31ec6ec
Commit fe191a51b5

Datei anzeigen

@ -21,27 +21,61 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import java.util.HashMap;
import java.util.Map;
public class WaterRemover implements Listener {
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
private final Map<Integer, FightTeam> tnt = new HashMap<>();
public WaterRemover() {
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this){
@Override
public void enable() {
tnt.clear();
super.enable();
}
};
}
@EventHandler
public void handleEntitySpawn(EntitySpawnEvent event) {
if(event.getEntityType() != EntityType.PRIMED_TNT)
return;
Location location = event.getLocation();
if (Config.BlueExtendRegion.inRegion(location)) {
tnt.put(event.getEntity().getEntityId(), Fight.getBlueTeam());
} else if (Config.RedExtendRegion.inRegion(location)) {
tnt.put(event.getEntity().getEntityId(), Fight.getRedTeam());
}
}
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
event.setYield(0); //No drops (additionally to world config)
FightTeam spawn = tnt.remove(event.getEntity().getEntityId());
if(spawn != null && event.blockList().isEmpty() && Fight.getOpposite(spawn).getExtendRegion().inRegion(event.getLocation())) {
checkBlock(event.getLocation().getBlock());
}
for(Block b : event.blockList()){
//b cannot be water or air due to current explosion