SteamWar/FightSystem
Archiviert
13
1

Merge pull request 'Fix arena border, piston border, and y-Damage' (#383) from fixBordersAndDamage into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #383
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Lixfel 2023-03-01 20:06:13 +01:00
Commit 22c22bab87
2 geänderte Dateien mit 25 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -61,6 +61,7 @@ public class Config {
public static final Region BlueExtendRegion;
public static final Region RedExtendRegion;
public static final Region ArenaRegion;
public static final Region PlayerRegion;
public static final Location TeamBlueSpawn;
public static final Location TeamRedSpawn;
@ -300,14 +301,13 @@ public class Config {
RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate;
int arenaYSize = blueCornerY - underBorder + schemsizeY + PreperationArea;
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ);
RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
ArenaRegion = new Region(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, world.getMaxHeight() - underBorder, arenaMaxZ - arenaMinZ);
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){

Datei anzeigen

@ -26,7 +26,9 @@ 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.states.StateDependentTask;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -38,40 +40,39 @@ public class ArenaBorder implements Listener {
public ArenaBorder() {
new StateDependentListener(ArenaMode.All, FightState.All, this);
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
}
@EventHandler
public void arenaBorder(PlayerMoveEvent event){
Player player = event.getPlayer();
if(Config.ArenaLeaveable && !Fight.fighting(player))
FightTeam team = Fight.getPlayerTeam(player);
if(Config.ArenaLeaveable && team == null)
return;
Location to = event.getTo();
assert to != null;
if(!Config.ArenaRegion.in2dRegion(to)){
reset(event);
if(Config.PlayerRegion.inRegion(to))
return;
}
FightTeam team = Fight.getPlayerTeam(player);
if(team == null || player.getGameMode() == GameMode.SPECTATOR){
if(to.getY() <= Config.ArenaRegion.getMinY())
reset(event);
return;
}
if(to.getY() <= Config.ArenaRegion.getMinY()) {
if(FightState.infight())
player.damage(2);
else if(!Config.GroundWalkable)
if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) {
if(!Config.GroundWalkable && !FightState.infight())
player.teleport(team.getSpawn());
}
}
private void reset(PlayerMoveEvent event){
Player player = event.getPlayer();
return;
}
player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
}
private void damage() {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
FightTeam team = Fight.getPlayerTeam(player);
if(team != null && player.getLocation().getY() <= Config.PlayerRegion.getMinY())
player.damage(1);
}
}
}