From 037d4520cd72b1a075bbaca707f6785ae149919a Mon Sep 17 00:00:00 2001 From: szumielxd <43210079+szumielxd@users.noreply.github.com> Date: Tue, 20 Jun 2023 19:09:43 +0200 Subject: [PATCH] Added check for not started challenges --- .../a5h73y/parkour/type/challenge/ChallengeManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/a5h73y/parkour/type/challenge/ChallengeManager.java b/src/main/java/io/github/a5h73y/parkour/type/challenge/ChallengeManager.java index e829c8f0..776bee1b 100644 --- a/src/main/java/io/github/a5h73y/parkour/type/challenge/ChallengeManager.java +++ b/src/main/java/io/github/a5h73y/parkour/type/challenge/ChallengeManager.java @@ -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)); } /** @@ -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", @@ -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);