Skip to content

Commit

Permalink
Merge pull request #344 from szumielxd/challenge-fix
Browse files Browse the repository at this point in the history
Added check for not started challenges
  • Loading branch information
A5H73Y authored Jul 3, 2023
2 parents d1b9965 + 037d452 commit f43ca88
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void removeInvitation(Player player) {
*/
public boolean hasPlayerBeenChallenged(Player player) {
return hasPlayerBeenInvited(player)
|| challenges.values().stream().anyMatch(challenge -> challenge.isPlayerParticipating(player));
|| challenges.values().stream().filter(challenge -> challenge.hasStarted()).anyMatch(challenge -> challenge.isPlayerParticipating(player));
}

/**
Expand Down Expand Up @@ -248,7 +248,7 @@ public void forfeitChallenge(Player player) {
public void completeChallenge(Player winner) {
Challenge challenge = getChallengeForPlayer(winner);

if (challenge != null && !challenge.isForfeited(winner)) {
if (challenge != null && challenge.hasStarted() && !challenge.isForfeited(winner)) {
removeChallenge(challenge.getChallengeHost());

TranslationUtils.sendValueTranslation("Parkour.Challenge.Winner",
Expand Down Expand Up @@ -360,6 +360,9 @@ public void prepareParticipant(Challenge challenge, Player participant) {
parkour.getParkourSessionManager().forceInvisible(participant);
}

if (parkour.getParkourSessionManager().isPlaying(participant)) {
parkour.getPlayerManager().leaveCourse(participant, false);
}
parkour.getPlayerManager().joinCourse(participant, challenge.getCourseName());
participant.setWalkSpeed(0f);
PlayerUtils.applyPotionEffect(PotionEffectType.JUMP, 100000, 100000, participant);
Expand Down

0 comments on commit f43ca88

Please sign in to comment.