diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java
index cda664d..2cce880 100644
--- a/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java
@@ -108,4 +108,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
public boolean isCrouching(Player player) {
return player.getPose() == Pose.SWIMMING;
}
+
+ @Override
+ public void sendBlockChange(Player player, Block block, Material type) {
+ player.sendBlockChange(block.getLocation(), type.createBlockData());
+ }
}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java
index 6a0e132..c788f06 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java
@@ -83,4 +83,10 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
public boolean isCrouching(Player player) {
return false;
}
+
+ @Override
+ @SuppressWarnings("deprecation")
+ public void sendBlockChange(Player player, Block block, Material type) {
+ player.sendBlockChange(block.getLocation(), type, (byte)0);
+ }
}
diff --git a/FightSystem_Core/build.gradle b/FightSystem_Core/build.gradle
index b9d32c2..25c8d64 100644
--- a/FightSystem_Core/build.gradle
+++ b/FightSystem_Core/build.gradle
@@ -47,6 +47,9 @@ dependencies {
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25'
+ compileOnly 'org.projectlombok:lombok:1.18.30'
+ annotationProcessor 'org.projectlombok:lombok:1.18.30'
+
compileOnly swdep("WorldEdit-1.15")
compileOnly swdep("SpigotCore")
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java
index b1030f7..dba60ee 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java
@@ -309,13 +309,13 @@ public class Config {
RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate;
- RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
- BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
+ RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
+ BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
- 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);
+ RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
+ BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
+ ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
+ PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java
index 48fe546..0b17349 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java
@@ -81,7 +81,6 @@ public class FightSystem extends JavaPlugin {
});
new Chat();
new ArenaBorder();
- new TeamArea();
new IngameDeath();
new InFightDamage();
new InFightInventory();
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
index 157c296..5581fe8 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
@@ -21,11 +21,13 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.techhider.ProtocolUtils;
import net.md_5.bungee.api.ChatMessageType;
+import org.bukkit.Bukkit;
import java.util.List;
@@ -55,6 +57,7 @@ public class EnternCountdown extends Countdown {
@Override
public void countdownFinished() {
+ Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
fightPlayer.ifPlayer(player -> {
FightSystem.getHullHider().updatePlayer(player);
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/events/BoardingEvent.java b/FightSystem_Core/src/de/steamwar/fightsystem/events/BoardingEvent.java
new file mode 100644
index 0000000..373d91b
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/events/BoardingEvent.java
@@ -0,0 +1,40 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2024 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.events;
+
+import de.steamwar.fightsystem.fight.FightPlayer;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+@Getter
+@AllArgsConstructor
+public class BoardingEvent extends Event {
+ @Getter
+ private static final HandlerList handlerList = new HandlerList();
+
+ private final FightPlayer fightPlayer;
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlerList;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamDeathEvent.java b/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamDeathEvent.java
new file mode 100644
index 0000000..6cbdd05
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamDeathEvent.java
@@ -0,0 +1,40 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2024 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.events;
+
+import de.steamwar.fightsystem.fight.FightPlayer;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+@Getter
+@AllArgsConstructor
+public class TeamDeathEvent extends Event {
+ @Getter
+ private static final HandlerList handlerList = new HandlerList();
+
+ private final FightPlayer fightPlayer;
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlerList;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamLeaveEvent.java b/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamLeaveEvent.java
new file mode 100644
index 0000000..36d96b0
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamLeaveEvent.java
@@ -0,0 +1,40 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2024 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.events;
+
+import de.steamwar.fightsystem.fight.FightPlayer;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+@Getter
+@AllArgsConstructor
+public class TeamLeaveEvent extends Event {
+ @Getter
+ private static final HandlerList handlerList = new HandlerList();
+
+ private final FightPlayer fightPlayer;
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlerList;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamSpawnEvent.java b/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamSpawnEvent.java
new file mode 100644
index 0000000..7ca62be
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/events/TeamSpawnEvent.java
@@ -0,0 +1,40 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2024 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.events;
+
+import de.steamwar.fightsystem.fight.FightPlayer;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+@Getter
+@AllArgsConstructor
+public class TeamSpawnEvent extends Event {
+ @Getter
+ private static final HandlerList handlerList = new HandlerList();
+
+ private final FightPlayer fightPlayer;
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlerList;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java
index e6740a8..f28c039 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java
@@ -23,6 +23,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.ai.AI;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.EnternCountdown;
+import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
@@ -62,6 +63,7 @@ public class FightPlayer {
public void setOut() {
isOut = true;
+ Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
stopEnternCountdown();
ifAI(AI::stop);
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
index 7aad62d..a8dfbca 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
@@ -25,10 +25,12 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.countdown.Countdown;
+import de.steamwar.fightsystem.events.TeamLeaveEvent;
+import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.Permanent;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
-import de.steamwar.fightsystem.record.GlobalRecorder;
+import de.steamwar.fightsystem.listener.TeamArea;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependent;
@@ -39,6 +41,7 @@ import de.steamwar.inventory.SWItem;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.techhider.ProtocolUtils;
+import lombok.Getter;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
@@ -89,24 +92,35 @@ public class FightTeam {
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
}
+ @Getter
private UUID designatedLeader;
+ @Getter
private FightPlayer leader;
+ @Getter
private boolean publicsOnly;
private final Map players = new HashMap<>();
+ @Getter
private String name;
+ @Getter
private String prefix;
+ @Getter
private ChatColor color;
private final FightSchematic schematic;
private final Team team;
+ @Getter
private final boolean blue;
+ @Getter
private boolean ready;
private boolean skip;
+ @Getter
private final Location spawn;
+ @Getter
private final Region schemRegion;
+ @Getter
private final Region extendRegion;
@SuppressWarnings("deprecation")
@@ -123,6 +137,7 @@ public class FightTeam {
this.schematic = new FightSchematic(this, rotate);
new KitLoader();
new SpectateHandler();
+ new TeamArea(this);
team = FightScoreboard.getBukkitTeam(name);
WorldOfColorWrapper.impl.setTeamColor(team, color);
@@ -146,26 +161,10 @@ public class FightTeam {
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("ยง", ""));
}
- public UUID getDesignatedLeader(){
- return designatedLeader;
- }
-
- public Region getSchemRegion() {
- return schemRegion;
- }
-
- public Region getExtendRegion() {
- return extendRegion;
- }
-
public boolean canbeLeader(Player p){
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
}
- public boolean isPublicsOnly() {
- return publicsOnly;
- }
-
public void teleportToSpawn(){
players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
}
@@ -265,6 +264,8 @@ public class FightTeam {
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
fightPlayer.revive();
players.put(entity.getUniqueId(), fightPlayer);
+ Bukkit.getPluginManager().callEvent(new TeamSpawnEvent(fightPlayer));
+
Permanent.getSpectatorTeam().removeEntry(entity.getName());
team.addEntry(entity.getName());
@@ -288,7 +289,6 @@ public class FightTeam {
if(FightState.Running.contains(FightState.getFightState()))
fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown());
- GlobalRecorder.getInstance().playerJoins(entity, user);
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunksToReload, false));
if(isLeaderless())
@@ -299,6 +299,7 @@ public class FightTeam {
public void removePlayer(LivingEntity entity) {
FightPlayer fightPlayer = getFightPlayer(entity);
+ Bukkit.getPluginManager().callEvent(new TeamLeaveEvent(fightPlayer));
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
List chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, true);
@@ -311,7 +312,6 @@ public class FightTeam {
if(fightPlayer.equals(leader))
removeLeader();
- GlobalRecorder.getInstance().entityDespawns(entity);
entity.teleport(Config.SpecSpawn);
fightPlayer.ifPlayer(player -> {
@@ -332,14 +332,6 @@ public class FightTeam {
return leader == null;
}
- public boolean isBlue(){
- return blue;
- }
-
- public FightPlayer getLeader() {
- return leader;
- }
-
private void removeLeader() {
this.leader = null;
if(!players.isEmpty()) {
@@ -383,10 +375,6 @@ public class FightTeam {
return players.values();
}
- public boolean isReady() {
- return ready;
- }
-
public void pasteSchem() {
testPasteAction();
}
@@ -457,26 +445,14 @@ public class FightTeam {
}
}
- public String getName() {
- return name;
- }
-
public String getColoredName() {
return prefix + name;
}
- public String getPrefix() {
- return prefix;
- }
-
public int getSchematic() {
return schematic.getId();
}
- public Location getSpawn() {
- return spawn;
- }
-
public double getCurrentHearts() {
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
}
@@ -494,10 +470,6 @@ public class FightTeam {
return (int) players.values().stream().filter(FightPlayer::isLiving).count();
}
- public ChatColor getColor() {
- return color;
- }
-
@Override
public String toString() {
return name;
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java
index d0a428e..8f9c287 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java
@@ -21,52 +21,72 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.events.TeamDeathEvent;
+import de.steamwar.fightsystem.events.TeamLeaveEvent;
+import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
-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.GameMode;
-import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
public class ArenaBorder implements Listener {
+ private final Border spectatorBorder = new Border(Config.PlayerRegion, true, 5, "NO_ARENA_LEAVING");
+ private final Border playerBorder = new Border(Config.PlayerRegion.to2d(), true, 5, "NO_ARENA_LEAVING");
+
public ArenaBorder() {
new StateDependentListener(ArenaMode.All, FightState.All, this);
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
+ new StateDependentListener(!Config.GroundWalkable, FightState.AntiIngame, new Listener() {
+ @EventHandler
+ public void onMove(PlayerMoveEvent e) {
+ Player player = e.getPlayer();
+ if(e.getTo().getY() <= Config.PlayerRegion.getMinY() && playerBorder.contains(player))
+ player.teleport(Fight.getPlayerTeam(player).getSpawn());
+ }
+ });
}
@EventHandler
- public void arenaBorder(PlayerMoveEvent event){
- Player player = event.getPlayer();
- FightTeam team = Fight.getPlayerTeam(player);
+ public void onPlayerJoin(PlayerJoinEvent e) {
+ addToSpectator(e.getPlayer());
+ }
- if(Config.ArenaLeaveable && team == null)
- return;
+ @EventHandler
+ public void onTeamJoin(TeamSpawnEvent e) {
+ e.getFightPlayer().ifPlayer(player -> {
+ spectatorBorder.removePlayer(player);
+ playerBorder.addPlayer(player);
+ });
+ }
- Location to = event.getTo();
- assert to != null;
+ @EventHandler
+ public void onTeamDeath(TeamDeathEvent e) {
+ e.getFightPlayer().ifPlayer(player -> {
+ playerBorder.removePlayer(player);
+ addToSpectator(player);
+ });
+ }
- if(Config.PlayerRegion.inRegion(to))
- return;
+ @EventHandler
+ public void onTeamLeave(TeamLeaveEvent e) {
+ e.getFightPlayer().ifPlayer(player -> {
+ playerBorder.removePlayer(player);
+ addToSpectator(player);
+ });
+ }
- if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) {
- if(!Config.GroundWalkable && !FightState.infight())
- player.teleport(team.getSpawn());
-
- return;
- }
-
- player.teleport(event.getFrom());
- FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
+ @EventHandler
+ public void onPlayerQuit(PlayerQuitEvent e) {
+ spectatorBorder.removePlayer(e.getPlayer());
}
private void damage() {
@@ -78,4 +98,11 @@ public class ArenaBorder implements Listener {
}
});
}
+
+ private void addToSpectator(Player player) {
+ if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
+ return;
+
+ spectatorBorder.addPlayer(player);
+ }
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java
new file mode 100644
index 0000000..6ae3384
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java
@@ -0,0 +1,131 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2024 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.listener;
+
+import de.steamwar.fightsystem.ArenaMode;
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.states.FightState;
+import de.steamwar.fightsystem.states.StateDependentTask;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
+import de.steamwar.fightsystem.utils.Region;
+import net.md_5.bungee.api.ChatMessageType;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class Border {
+
+ private final Map> ghostBarriers = new HashMap<>();
+ private final Map lastLocation = new HashMap<>();
+ private final boolean contain;
+ private final String resetMessage;
+ private final Region region;
+ private final int ghostRange;
+ private final int ghostSize;
+
+ public Border(Region region, boolean contain, int ghostRange, String resetMessage) {
+ this.contain = contain;
+ this.resetMessage = resetMessage;
+ this.region = region;
+ this.ghostRange = ghostRange;
+ this.ghostSize = 2*ghostRange + 1;
+
+ new StateDependentTask(ArenaMode.All, FightState.All, this::run, 1, 1);
+ }
+
+ public void addPlayer(Player player) {
+ ghostBarriers.computeIfAbsent(player, uuid -> new HashSet<>());
+ lastLocation.put(player, player.getLocation());
+ }
+
+ public boolean contains(Player player) {
+ return ghostBarriers.containsKey(player);
+ }
+
+ public void removePlayer(Player player) {
+ lastLocation.remove(player);
+ Set blocks = ghostBarriers.remove(player);
+ if(blocks == null || !player.isOnline())
+ return;
+
+ for(Block block : blocks)
+ sendChange(player, block, Material.AIR);
+ }
+
+ private void run() {
+ for(Map.Entry> entry : ghostBarriers.entrySet()) {
+ Player player = entry.getKey();
+ Location location = player.getLocation();
+ if(region.playerInRegion(location) != contain) {
+ player.teleport(lastLocation.get(player));
+ FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
+ return;
+ }
+
+ Set ghostBlocks = entry.getValue();
+ Region ghostRegion = Region.fromSize(location.getBlockX() - ghostRange, location.getBlockY() - ghostRange, location.getBlockZ() - ghostRange, ghostSize, ghostSize, ghostSize);
+ ghostBlocks.removeIf(block -> {
+ if(!ghostRegion.inRegion(block)) {
+ sendChange(player, block, Material.AIR);
+ return true;
+ }
+ return false;
+ });
+
+ if(contain) {
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
+ } else {
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
+ borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
+ }
+
+ lastLocation.put(entry.getKey(), location);
+ }
+ }
+
+ private void borderIteration(Player player, Set ghostBlocks, Region border) {
+ border.forEach((x, y, z) -> {
+ Block block = Config.world.getBlockAt(x, y, z);
+ if(ghostBlocks.add(block))
+ sendChange(player, block, Material.BARRIER);
+ });
+ }
+
+ private void sendChange(Player player, Block block, Material type) {
+ if(block.getType() == Material.AIR)
+ FlatteningWrapper.impl.sendBlockChange(player, block, type);
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java
index a0eabba..90342de 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java
@@ -37,8 +37,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
+import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFromToEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
@@ -217,4 +219,25 @@ public class Permanent implements Listener {
if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block))
e.setCancelled(true);
}
+
+ @EventHandler
+ public void blockPlace(BlockPlaceEvent event) {
+ Player player = event.getPlayer();
+ Block block = event.getBlock();
+ if(Fight.teams().stream().anyMatch(team -> team.getExtendRegion().inRegion(block)))
+ return;
+
+ event.setCancelled(true);
+ FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
+ }
+
+ @EventHandler
+ public void blockBreak(BlockBreakEvent event) {
+ Block block = event.getBlock();
+ if(Config.BlueExtendRegion.getMinY() <= block.getY())
+ return;
+
+ event.setCancelled(true);
+ FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
+ }
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java
index b51964b..f77c190 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java
@@ -23,6 +23,9 @@ import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.events.TeamDeathEvent;
+import de.steamwar.fightsystem.events.TeamLeaveEvent;
+import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
@@ -142,6 +145,11 @@ public class Recording implements Listener {
return packet;
}
+ @EventHandler
+ public void onPlayerSpawn(TeamSpawnEvent e) {
+ GlobalRecorder.getInstance().playerJoins(e.getFightPlayer().getEntity(), e.getFightPlayer().getUser());
+ }
+
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerMove(PlayerMoveEvent e){
if(isNotSent(e.getPlayer()))
@@ -151,19 +159,13 @@ public class Recording implements Listener {
}
@EventHandler
- public void onPlayerDeath(PlayerDeathEvent e) {
- if(isNotSent(e.getEntity()))
- return;
-
- GlobalRecorder.getInstance().entityDespawns(e.getEntity());
+ public void onPlayerDeath(TeamDeathEvent e) {
+ GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
}
@EventHandler
- public void onPlayerQuit(PlayerQuitEvent e){
- if(isNotSent(e.getPlayer()))
- return;
-
- GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
+ public void onPlayerLeave(TeamLeaveEvent e) {
+ GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java
index e091c92..154919c 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java
@@ -21,110 +21,106 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.events.BoardingEvent;
+import de.steamwar.fightsystem.events.TeamDeathEvent;
+import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
+import de.steamwar.fightsystem.fight.FightPlayer;
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.Region;
-import net.md_5.bungee.api.ChatMessageType;
-import org.bukkit.Bukkit;
-import org.bukkit.GameMode;
-import org.bukkit.block.Block;
+import de.steamwar.fightsystem.states.StateDependentTask;
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.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
import java.util.Set;
-import java.util.logging.Level;
public class TeamArea implements Listener {
- private static final Set realSpectator = new HashSet<>();
+ private final FightTeam team;
+ private final Border spectatorBorder;
+ private final Border bordingBorder;
+ private final Set realSpectator = new HashSet<>();
+
+ public TeamArea(FightTeam team) {
+ this.team = team;
+ this.spectatorBorder = new Border(team.getExtendRegion(), false, 5, "NO_TEAMAREA");
+ this.bordingBorder = new Border(team.getExtendRegion().to2d(), true, 1, "NO_ENTERN");
- public TeamArea() {
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
+ new StateDependentTask(ArenaMode.AntiTest, FightState.TeamFix, this::realSpectatorCheck, 1, 1);
+ new OneShotStateDependent(ArenaMode.AntiTest, FightState.Spectate, () -> Fight.teams().forEach(t -> t.getPlayers().forEach(this::teamSpectator)));
}
@EventHandler
- public void teamAreas(PlayerMoveEvent event) {
- Player player = event.getPlayer();
- if(Config.isReferee(player))
- return;
+ public void playerJoin(PlayerJoinEvent e) {
+ Player player = e.getPlayer();
+ if(Fight.getPlayerTeam(player) != team && !Config.isReferee(player))
+ spectatorBorder.addPlayer(player);
+ }
- FightTeam team = Fight.getPlayerTeam(player);
- Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team));
+ @EventHandler
+ public void teamJoin(TeamSpawnEvent e) {
+ FightPlayer fightPlayer = e.getFightPlayer();
+ if(fightPlayer.getTeam() == team) {
+ fightPlayer.ifPlayer(player -> {
+ spectatorBorder.removePlayer(player);
+ bordingBorder.addPlayer(player);
+ });
+ }
+ }
+
+ @EventHandler
+ public void boarding(BoardingEvent e) {
+ FightPlayer fightPlayer = e.getFightPlayer();
+ if(fightPlayer.getTeam() == team) {
+ fightPlayer.ifPlayer(bordingBorder::removePlayer);
+ } else {
+ fightPlayer.ifPlayer(spectatorBorder::removePlayer);
+ }
+ }
+
+ @EventHandler
+ public void teamDeath(TeamDeathEvent e) {
+ teamSpectator(e.getFightPlayer());
+ }
+
+ private void teamSpectator(FightPlayer fightPlayer) {
+ if(fightPlayer.getTeam() == team) {
+ fightPlayer.ifPlayer(bordingBorder::removePlayer);
+ } else {
+ fightPlayer.ifPlayer(spectatorBorder::addPlayer);
+ }
}
@EventHandler
public void playerQuit(PlayerQuitEvent e) {
- realSpectator.remove(e.getPlayer());
+ Player player = e.getPlayer();
+ spectatorBorder.removePlayer(player);
+ bordingBorder.removePlayer(player);
+ realSpectator.remove(player);
}
- @EventHandler
- public void blockPlace(BlockPlaceEvent event) {
- Player player = event.getPlayer();
- Block block = event.getBlock();
- if(Config.BlueExtendRegion.inRegion(block) || Config.RedExtendRegion.inRegion(block))
- return;
+ private void realSpectatorCheck() {
+ for(FightPlayer fightPlayer : team.getPlayers()) {
+ if(fightPlayer.isLiving())
+ continue;
- event.setCancelled(true);
- FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
- }
-
- @EventHandler
- public void blockBreak(BlockBreakEvent event) {
- Block block = event.getBlock();
- if(Config.BlueExtendRegion.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))
- return; // Player can entern
-
- Region region = team.getExtendRegion();
- boolean inRegion = region.in2dRegion(event.getTo());
- if(team == playerTeam) {
- if(spectator) {
- realSpectator(inRegion, player);
- } else if (!playerTeam.canPlayerEntern(player) && !inRegion) {
- reset(event, "NO_ENTERN"); // Leaving prior to entern
- }
- return; // Always allowed in own region
+ fightPlayer.ifPlayer(player -> {
+ boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation());
+ if(inRegion && !realSpectator.contains(player)) {
+ Fight.pseudoSpectator(player, false);
+ realSpectator.add(player);
+ }else if(!inRegion && realSpectator.contains(player)) {
+ Fight.pseudoSpectator(player, true);
+ realSpectator.remove(player);
+ }
+ });
}
-
- if(region.playerInRegion(event.getTo())) {
- reset(event, "NO_TEAMAREA"); // Not allowed in region
- if(team.getSchemRegion().playerInRegion(event.getTo()) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
- player.kickPlayer(null);
- Bukkit.getLogger().log(Level.INFO, player.getName() + " has entered a team area");
- }
- }
- }
-
- private void realSpectator(boolean inRegion, Player player) {
- if(inRegion && !realSpectator.contains(player)) {
- Fight.pseudoSpectator(player, false);
- realSpectator.add(player);
- }else if(!inRegion && realSpectator.contains(player)) {
- Fight.pseudoSpectator(player, true);
- realSpectator.remove(player);
- }
- }
-
- private void reset(PlayerMoveEvent event, String message){
- Player player = event.getPlayer();
- player.teleport(event.getFrom());
- FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR);
}
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java
index 4f76656..aa2f10e 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java
@@ -22,6 +22,7 @@ package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.DyeColor;
+import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -49,4 +50,5 @@ public interface FlatteningWrapper {
boolean isFacingWater(Block dispenser);
boolean isCrouching(Player player);
+ void sendBlockChange(Player player, Block block, Material type);
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java
index 1308f40..807822a 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java
@@ -20,13 +20,26 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.techhider.ProtocolUtils;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.block.Block;
import java.util.function.ObjIntConsumer;
+@Getter
+@AllArgsConstructor
public class Region {
+ public static Region withExtension(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
+ return Region.fromSize(minX - extendX, minY - extendY, minZ - extendZ,
+ sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
+ }
+
+ public static Region fromSize(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
+ return new Region(minX, minY, minZ, minX+sizeX, minY+sizeY, minZ+sizeZ);
+ }
+
private final int minX;
private final int minY;
private final int minZ;
@@ -34,44 +47,6 @@ public class Region {
private final int maxY;
private final int maxZ;
- public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
- this(minX - extendX, minY - extendY, minZ - extendZ,
- sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
- }
-
- public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
- this.minX = minX;
- this.minY = minY;
- this.minZ = minZ;
- this.maxX = minX + sizeX;
- this.maxY = minY + sizeY;
- this.maxZ = minZ + sizeZ;
- }
-
- public int getMinX() {
- return minX;
- }
-
- public int getMinY() {
- return minY;
- }
-
- public int getMinZ() {
- return minZ;
- }
-
- public int getMaxX() {
- return maxX;
- }
-
- public int getMaxY() {
- return maxY;
- }
-
- public int getMaxZ() {
- return maxZ;
- }
-
public int getSizeX() {
return maxX - minX;
}
@@ -161,6 +136,18 @@ public class Region {
return in2dRegion(x, z) && minY <= y && y < maxY;
}
+ public Region intersection(Region other) {
+ int x = Math.max(minX, other.minX);
+ int y = Math.max(minY, other.minY);
+ int z = Math.max(minZ, other.minZ);
+
+ return new Region(x, y, z, Math.min(maxX, other.maxX), Math.min(maxY, other.maxY), Math.min(maxZ, other.maxZ));
+ }
+
+ public Region to2d() {
+ return new Region(minX, Integer.MIN_VALUE/2, minZ, maxX, Integer.MAX_VALUE/2, maxZ);
+ }
+
public interface TriConsumer{
void accept(T x, V y, U z);
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
index 041a752..8f2d73a 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
@@ -19,16 +19,13 @@
package de.steamwar.fightsystem.winconditions;
+import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.fight.Fight;
-import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
-import org.bukkit.event.entity.EntityDeathEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead extends Wincondition implements Listener {
@@ -38,25 +35,12 @@ public class WinconditionAllDead extends Wincondition implements Listener {
}
@EventHandler
- public void handlePlayerDeath(EntityDeathEvent event) {
- handleDeath(event.getEntity());
- }
+ public void handlePlayerDeath(TeamDeathEvent event) {
+ FightTeam team = event.getFightPlayer().getTeam();
- @EventHandler
- public void handlePlayerQuit(PlayerQuitEvent event) {
- handleDeath(event.getPlayer());
- }
-
- private void handleDeath(Entity player){
- FightTeam team = isTarget(player);
- if(team == null)
+ if(team.getAlivePlayers() > 0)
return;
- for(FightPlayer fp : team.getPlayers()) {
- if(fp.isLiving() && fp.getEntity() != player)
- return;
- }
-
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
}
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
index 53759a9..de0205a 100644
--- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
@@ -19,16 +19,14 @@
package de.steamwar.fightsystem.winconditions;
+import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.fight.Fight;
+import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
-import org.bukkit.event.entity.EntityDeathEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead extends Wincondition implements Listener {
@@ -38,22 +36,12 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
}
@EventHandler
- public void handlePlayerDeath(EntityDeathEvent event) {
- handleDeath(event.getEntity());
- }
-
- @EventHandler
- public void handlePlayerQuit(PlayerQuitEvent event) {
- handleDeath(event.getPlayer());
- }
-
- private void handleDeath(Entity player){
- FightTeam team = isTarget(player);
- if(team == null)
+ public void handlePlayerDeath(TeamDeathEvent event) {
+ FightPlayer leader = event.getFightPlayer();
+ if(!leader.isLeader())
return;
- if(team.isPlayerLeader((LivingEntity) player)) {
- win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getEntity().getName());
- }
+ FightTeam team = leader.getTeam();
+ win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName());
}
}
diff --git a/build.gradle b/build.gradle
index 3cacf6e..2c1673c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -46,11 +46,6 @@ mainClassName = ''
allprojects {
repositories {
mavenCentral()
- jcenter()
-
- maven {
- url = uri("https://repo.codemc.io/repository/maven-snapshots/")
- }
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')