diff --git a/core/src/main/java/tc/oc/pgm/flag/state/Carried.java b/core/src/main/java/tc/oc/pgm/flag/state/Carried.java index 8df518cf9e..994e3f294f 100644 --- a/core/src/main/java/tc/oc/pgm/flag/state/Carried.java +++ b/core/src/main/java/tc/oc/pgm/flag/state/Carried.java @@ -213,7 +213,7 @@ public void tickRunning() { } if (!isFlag(carrier.getInventory().getHelmet())) { - this.dropFlag(); + if (isCurrent()) this.dropFlag(); } } diff --git a/core/src/main/java/tc/oc/pgm/flag/state/Respawning.java b/core/src/main/java/tc/oc/pgm/flag/state/Respawning.java index d417fe2a26..21481b5bfe 100644 --- a/core/src/main/java/tc/oc/pgm/flag/state/Respawning.java +++ b/core/src/main/java/tc/oc/pgm/flag/state/Respawning.java @@ -10,6 +10,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; import org.bukkit.Location; +import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; import tc.oc.pgm.api.party.Party; import tc.oc.pgm.flag.Flag; @@ -54,7 +55,8 @@ protected Duration getDuration() { public void enterState() { super.enterState(); - if (Duration.ZERO.equals(respawnTime)) return; + if (Duration.ZERO.equals(respawnTime) || !this.flag.getMatch().isRunning()) return; + // Respawn is delayed String postName = this.post.getPostName(); @@ -84,6 +86,11 @@ protected void respawn(Component message) { this.flag.transition(new Returned(this.flag, this.post, this.respawnTo)); } + @Override + protected boolean canSeeParticles(Player player) { + return !this.flag.getMatch().isFinished(); + } + @Override protected void tickSeconds(long seconds) { super.tickSeconds(seconds); diff --git a/core/src/main/java/tc/oc/pgm/goals/TouchableGoal.java b/core/src/main/java/tc/oc/pgm/goals/TouchableGoal.java index 8e4b1f120a..f55923446c 100644 --- a/core/src/main/java/tc/oc/pgm/goals/TouchableGoal.java +++ b/core/src/main/java/tc/oc/pgm/goals/TouchableGoal.java @@ -24,7 +24,6 @@ import tc.oc.pgm.goals.events.GoalCompleteEvent; import tc.oc.pgm.goals.events.GoalTouchEvent; import tc.oc.pgm.spawns.events.ParticipantDespawnEvent; -import tc.oc.pgm.util.Audience; /** * A {@link Goal} that may be 'touched' by players, meaning the player has made some tangible @@ -189,19 +188,18 @@ public boolean shouldShowTouched(@Nullable Competitor team, Party viewer) { protected void sendTouchMessage(@Nullable ParticipantState toucher, boolean includeToucher) { if (!hasShowOption(ShowOption.SHOW_MESSAGES)) return; - Component message = getTouchMessage(toucher, false); - Audience.console().sendMessage(message); - - if (shouldShowTouched(toucher.getParty())) { - if (showEnemyTouches()) - ChatManager.broadcastMessage( - message, viewer -> toucher == null || !toucher.isPlayer(viewer)); - else - ChatManager.broadcastPartyMessage( - message, toucher.getParty(), viewer -> toucher == null || !toucher.isPlayer(viewer)); - } - if (toucher != null) { + Component message = getTouchMessage(toucher, false); + + if (shouldShowTouched(toucher.getParty())) { + if (showEnemyTouches()) { + ChatManager.broadcastMessage(message, viewer -> !toucher.isPlayer(viewer)); + } else { + ChatManager.broadcastPartyMessage( + message, toucher.getParty(), viewer -> !toucher.isPlayer(viewer)); + } + } + if (includeToucher) { toucher.sendMessage(getTouchMessage(toucher, true)); } diff --git a/core/src/main/java/tc/oc/pgm/listeners/MatchAnnouncer.java b/core/src/main/java/tc/oc/pgm/listeners/MatchAnnouncer.java index 75600145aa..a7f3a2fb0d 100644 --- a/core/src/main/java/tc/oc/pgm/listeners/MatchAnnouncer.java +++ b/core/src/main/java/tc/oc/pgm/listeners/MatchAnnouncer.java @@ -62,23 +62,28 @@ public void onMatchBegin(final MatchStartEvent event) { @EventHandler(priority = EventPriority.MONITOR) public void onMatchEnd(final MatchFinishEvent event) { final Match match = event.getMatch(); + final Collection winners = event.getWinners(); + final boolean singleWinner = winners.size() == 1; + + Component title; + if (winners.isEmpty()) { + title = translatable("broadcast.gameOver"); + } else if (singleWinner) { + title = translatable( + Iterables.getOnlyElement(winners).isNamePlural() + ? "broadcast.gameOver.teamWinners" + : "broadcast.gameOver.teamWinner", + TextFormatter.nameList(winners, NameStyle.FANCY, NamedTextColor.WHITE)); + } else { + // 2 or more winners, show "Tied!" as the title + title = translatable("broadcast.gameOver.tied", NamedTextColor.YELLOW); + } - // broadcast match finish message + // Broadcast match finish titles to participants for (MatchPlayer viewer : match.getPlayers()) { - Component title = null, subtitle = empty(); - final Collection winners = event.getWinners(); - final boolean singleWinner = winners.size() == 1; - if (winners.isEmpty()) { - title = translatable("broadcast.gameOver"); - } else { - if (singleWinner) { - title = translatable( - Iterables.getOnlyElement(winners).isNamePlural() - ? "broadcast.gameOver.teamWinners" - : "broadcast.gameOver.teamWinner", - TextFormatter.nameList(winners, NameStyle.FANCY, NamedTextColor.WHITE)); - } + Component subtitle = empty(); + if (!winners.isEmpty()) { // Use stream here instead of #contains to avoid unchecked cast if (winners.stream().anyMatch(w -> w == viewer.getParty())) { // Winner @@ -98,10 +103,7 @@ public void onMatchEnd(final MatchFinishEvent event) { } } - if (title == null) { - // 2 or more winners, show "Tied!" as the title - title = translatable("broadcast.gameOver.tied", NamedTextColor.YELLOW); - + if (subtitle == empty()) { // If 2 or 3 winners we show the winners as the subtitle if (winners.size() <= 3) { subtitle = TextFormatter.nameList(winners, NameStyle.FANCY, NamedTextColor.WHITE); @@ -111,10 +113,12 @@ public void onMatchEnd(final MatchFinishEvent event) { final Title.Times titleTimes = Title.Times.times(Duration.ZERO, fromTicks(40), fromTicks(40)); viewer.showTitle(title(title, subtitle, titleTimes)); - viewer.sendMessage(title); - if (viewer.getParty() instanceof Competitor || !singleWinner) viewer.sendMessage(subtitle); } + + // Broadcast match finish message to the match + // This includes console + match.sendMessage(title); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)