From 80888271b5667710152681e4bd348874082ebb7f Mon Sep 17 00:00:00 2001 From: Pablo Herrera Date: Thu, 23 Feb 2023 01:34:16 +0100 Subject: [PATCH] Update to latest pgm changes --- pom.xml | 2 +- .../pgm/events/listeners/PlayerJoinListen.java | 18 ++++++------------ .../java/dev/pgm/events/utils/Parties.java | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index b231a40..cb2c401 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ tc.oc.pgm core - 0.15-SNAPSHOT + 0.16-SNAPSHOT provided diff --git a/src/main/java/dev/pgm/events/listeners/PlayerJoinListen.java b/src/main/java/dev/pgm/events/listeners/PlayerJoinListen.java index dd6d299..b3a7975 100644 --- a/src/main/java/dev/pgm/events/listeners/PlayerJoinListen.java +++ b/src/main/java/dev/pgm/events/listeners/PlayerJoinListen.java @@ -3,6 +3,7 @@ import static net.kyori.adventure.text.Component.text; import dev.pgm.events.team.TournamentTeamManager; +import dev.pgm.events.utils.Parties; import java.util.Optional; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -32,7 +33,7 @@ public void onJoin(MatchPlayerAddEvent event) { Optional playerTeam = manager.playerTeam(event.getPlayer().getId()); if (playerTeam.isPresent()) { Team team = playerTeam.get(); - if (!isFull(team)) { + if (!Parties.isFull(team)) { if (event.getMatch().isRunning() && event.getMatch().hasModule(BlitzMatchModule.class)) return; @@ -56,7 +57,7 @@ public void beforeLogin(PlayerLoginEvent event) { if (playerTeam.isPresent()) { Team team = playerTeam.get(); - if (isFull(team)) { + if (Parties.isFull(team)) { // team is full -- lets kick this mad lad event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your team is full!"); } else { @@ -87,7 +88,7 @@ public void onParticipate(PlayerParticipationStartEvent event) { // check if the player is on one of the teams if (playerTeam.isPresent()) { Team team = playerTeam.get(); - if (!isFull(team)) return; + if (!Parties.isFull(team)) return; } event.cancel(text("You may not join in a tournament setting!", NamedTextColor.RED)); @@ -102,15 +103,8 @@ public void onLeaveParticipate(PlayerParticipationStopEvent event) { event.cancel(text("You may not leave in a tournament setting!", NamedTextColor.RED)); BlitzMatchModule blitz = event.getMatch().getModule(BlitzMatchModule.class); - if (blitz != null) { - if (blitz.getNumOfLives(event.getPlayer().getId()) <= 0) { - event.setCancelled(false); - return; - } + if (blitz != null && blitz.getNumOfLives(event.getPlayer().getId()) <= 0) { + event.setCancelled(false); } } - - private boolean isFull(Team team) { - return team.getSizeAfterJoin(null, team, false) >= team.getMaxPlayers(); - } } diff --git a/src/main/java/dev/pgm/events/utils/Parties.java b/src/main/java/dev/pgm/events/utils/Parties.java index 5a35010..a2bdeae 100644 --- a/src/main/java/dev/pgm/events/utils/Parties.java +++ b/src/main/java/dev/pgm/events/utils/Parties.java @@ -9,7 +9,7 @@ public static boolean isFull(Party party) { if (party instanceof Team) { Team team = (Team) party; - return team.getSize(false) >= team.getMaxPlayers(); + return team.getSize() >= team.getMaxPlayers(); } return false;