Skip to content

Commit

Permalink
Update to latest pgm changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablete1234 committed Feb 23, 2023
1 parent 976ba89 commit 8088827
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<dependency>
<groupId>tc.oc.pgm</groupId>
<artifactId>core</artifactId>
<version>0.15-SNAPSHOT</version>
<version>0.16-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/dev/pgm/events/listeners/PlayerJoinListen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,7 +33,7 @@ public void onJoin(MatchPlayerAddEvent event) {
Optional<Team> 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;

Expand All @@ -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 {
Expand Down Expand Up @@ -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));
Expand All @@ -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();
}
}
2 changes: 1 addition & 1 deletion src/main/java/dev/pgm/events/utils/Parties.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8088827

Please sign in to comment.