|
1 | 1 | package tc.oc.occ.idly; |
2 | 2 |
|
3 | | -import static net.kyori.adventure.key.Key.key; |
4 | | -import static net.kyori.adventure.sound.Sound.sound; |
5 | 3 | import static net.kyori.adventure.text.Component.text; |
6 | 4 |
|
7 | 5 | import com.google.common.base.Objects; |
8 | 6 | import java.util.Map; |
9 | 7 | import java.util.UUID; |
10 | | -import javax.annotation.Nullable; |
11 | 8 | import net.kyori.adventure.audience.Audience; |
12 | 9 | import net.kyori.adventure.sound.Sound; |
13 | 10 | import net.kyori.adventure.text.Component; |
14 | 11 | import net.kyori.adventure.text.format.NamedTextColor; |
15 | 12 | import org.bukkit.Bukkit; |
16 | 13 | import org.bukkit.entity.Player; |
| 14 | +import org.jetbrains.annotations.Nullable; |
17 | 15 | import tc.oc.occ.idly.utils.OnlinePlayerUUIDMapAdapter; |
18 | 16 | import tc.oc.pgm.api.match.Match; |
19 | 17 | import tc.oc.pgm.api.player.MatchPlayer; |
| 18 | +import tc.oc.pgm.util.bukkit.Sounds; |
20 | 19 |
|
21 | 20 | public class IdlyManager { |
22 | 21 |
|
@@ -63,20 +62,19 @@ private void checkPlayers() { |
63 | 62 | } |
64 | 63 |
|
65 | 64 | private void checkPlayer(Player player) { |
66 | | - // Ignore those with the bypass permission |
67 | | - if (config.isBypassEnabled() && player.hasPermission(IdlyPermissions.BYPASS)) return; |
| 65 | + int inactivity = |
| 66 | + playerInactivityTicks.compute( |
| 67 | + player.getUniqueId(), (p, t) -> Objects.firstNonNull(t, 0) + TICK_FREQUENCY); |
68 | 68 |
|
69 | 69 | boolean isPlaying = plugin.getAPI().isPlaying(player); |
70 | 70 |
|
71 | 71 | // Don't track observers when kick mode is disabled |
72 | 72 | if (!config.isKickMode() && !isPlaying) return; |
73 | 73 |
|
74 | | - int duration = (isPlaying ? config.getParticipantDelay() : config.getObserverDelay()); |
75 | | - |
76 | | - int inactivity = |
77 | | - playerInactivityTicks.compute( |
78 | | - player.getUniqueId(), (p, t) -> Objects.firstNonNull(t, 0) + TICK_FREQUENCY); |
| 74 | + // Ignore those with the bypass permission |
| 75 | + if (config.isBypassEnabled() && player.hasPermission(IdlyPermissions.BYPASS)) return; |
79 | 76 |
|
| 77 | + int duration = (isPlaying ? config.getParticipantDelay() : config.getObserverDelay()); |
80 | 78 | float remaining = duration - inactivity; |
81 | 79 | if (remaining <= 0) { |
82 | 80 | kick(player); |
@@ -139,9 +137,9 @@ private void sendWarningCountdown(Player player, float tickTime) { |
139 | 137 |
|
140 | 138 | private static final Component OBSERVERS = text("Observers", NamedTextColor.AQUA); |
141 | 139 | private static final Component WARNING = text(" \u26a0 ", NamedTextColor.YELLOW); |
142 | | - private static final Sound COUNTDOWN = sound(key("random.break"), Sound.Source.MASTER, 1f, 1.15f); |
| 140 | + private static final Sound COUNTDOWN = Sounds.sound("ITEM_BREAK", "ENTITY_ITEM_BREAK", 1f, 1.15f); |
143 | 141 | private static final Sound KICK = |
144 | | - sound(key("mob.zombie.woodbreak"), Sound.Source.MASTER, 1f, 1.20f); |
| 142 | + Sounds.sound("ZOMBIE_WOODBREAK", "ENTITY_ZOMBIE_BREAK_WOODEN_DOOR", 1f, 1.2f); |
145 | 143 |
|
146 | 144 | private void sendWarning(Audience viewer, Component message, @Nullable Sound sound) { |
147 | 145 | viewer.sendMessage(text().append(WARNING).append(message)); |
|
0 commit comments