Skip to content

Commit db5f35a

Browse files
authored
Cleanup for modern support and fix auto-vanishing (#8)
1 parent 826a277 commit db5f35a

6 files changed

Lines changed: 53 additions & 35 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
2424
/target/
25+
26+
# Idea
27+
.idea/

pom.xml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
<description>Prevent players from going afk in PGM</description>
1010

1111
<properties>
12-
<maven.compiler.source>1.8</maven.compiler.source>
13-
<maven.compiler.target>1.8</maven.compiler.target>
12+
<maven.compiler.release>21</maven.compiler.release>
1413
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1514
<project.bukkit.main>tc.oc.occ.idly.Idly</project.bukkit.main>
1615
<project.author>applenick</project.author>
@@ -24,10 +23,6 @@
2423
</distributionManagement>
2524

2625
<repositories>
27-
<repository>
28-
<id>jitpack.io</id>
29-
<url>https://jitpack.io</url>
30-
</repository>
3126
<repository>
3227
<id>aikar</id>
3328
<url>https://repo.aikar.co/content/groups/aikar/</url>
@@ -41,9 +36,9 @@
4136
<dependencies>
4237
<!-- SportBukkit 1.8 -->
4338
<dependency>
44-
<groupId>app.ashcon</groupId>
45-
<artifactId>sportpaper</artifactId>
46-
<version>1.8.8-R0.1-SNAPSHOT</version>
39+
<groupId>dev.pgm.paper</groupId>
40+
<artifactId>paper-api</artifactId>
41+
<version>1.8_1.21.11-SNAPSHOT</version>
4742
<scope>provided</scope>
4843
</dependency>
4944

@@ -66,6 +61,22 @@
6661
<version>0.5.0-SNAPSHOT</version>
6762
</dependency>
6863

64+
<!-- Minecraft dependencies -->
65+
<dependency>
66+
<groupId>com.google.guava</groupId>
67+
<artifactId>guava</artifactId>
68+
<version>17.0</version>
69+
<scope>provided</scope>
70+
</dependency>
71+
72+
<!-- Annotations -->
73+
<dependency>
74+
<groupId>org.jetbrains</groupId>
75+
<artifactId>annotations</artifactId>
76+
<version>26.0.2</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
6980
</dependencies>
7081

7182
<build>
@@ -81,7 +92,7 @@
8192
<plugin>
8293
<groupId>org.apache.maven.plugins</groupId>
8394
<artifactId>maven-compiler-plugin</artifactId>
84-
<version>3.8.1</version>
95+
<version>3.14.1</version>
8596
<configuration>
8697
<compilerArgs>
8798
<arg>-parameters</arg> <!-- Required for aikar/commands to auto generate syntax -->
@@ -108,7 +119,7 @@
108119
<plugin>
109120
<groupId>org.apache.maven.plugins</groupId>
110121
<artifactId>maven-shade-plugin</artifactId>
111-
<version>3.2.3</version>
122+
<version>3.6.1</version>
112123
<configuration>
113124
<createDependencyReducedPom>false</createDependencyReducedPom>
114125
<minimizeJar>true</minimizeJar>
@@ -138,19 +149,23 @@
138149
</plugin>
139150
<!-- Validates that code is properly formatted with Google's code style -->
140151
<plugin>
141-
<groupId>com.coveo</groupId>
152+
<groupId>com.spotify.fmt</groupId>
142153
<artifactId>fmt-maven-plugin</artifactId>
143-
<version>2.9</version>
144-
<configuration>
145-
<style>google</style>
146-
</configuration>
154+
<version>2.27</version>
147155
<executions>
148156
<execution>
149157
<goals>
150-
<goal>check</goal>
158+
<goal>format</goal>
151159
</goals>
152160
</execution>
153161
</executions>
162+
<dependencies>
163+
<dependency>
164+
<groupId>com.google.googlejavaformat</groupId>
165+
<artifactId>google-java-format</artifactId>
166+
<version>1.27.0</version>
167+
</dependency>
168+
</dependencies>
154169
</plugin>
155170
</plugins>
156171
</build>

src/main/java/tc/oc/occ/idly/IdlyAutoVanishManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package tc.oc.occ.idly;
22

3-
import static net.kyori.adventure.key.Key.key;
4-
import static net.kyori.adventure.sound.Sound.sound;
53
import static net.kyori.adventure.text.Component.text;
64
import static tc.oc.occ.idly.Idly.log;
75

@@ -13,11 +11,12 @@
1311
import org.bukkit.entity.Player;
1412
import tc.oc.pgm.api.integration.Integration;
1513
import tc.oc.pgm.util.Audience;
14+
import tc.oc.pgm.util.bukkit.Sounds;
1615

1716
public class IdlyAutoVanishManager {
1817

1918
private final int PRE_AFK_DELAY = 5; // SECONDS
20-
private final Sound WARN_SOUND = sound(key("note.pling"), Sound.Source.MASTER, 1f, 0.5f);
19+
private final Sound WARN_SOUND = Sounds.sound("NOTE_PLING", "BLOCK_NOTE_BLOCK_PLING", 1f, 0.5f);
2120

2221
private final IdlyConfig config;
2322
private final IdlyManager manager;

src/main/java/tc/oc/occ/idly/IdlyCommand.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package tc.oc.occ.idly;
22

3+
import static net.kyori.adventure.text.Component.text;
4+
35
import co.aikar.commands.BaseCommand;
46
import co.aikar.commands.annotation.CommandAlias;
57
import co.aikar.commands.annotation.CommandPermission;
68
import co.aikar.commands.annotation.Dependency;
79
import co.aikar.commands.annotation.Subcommand;
8-
import org.bukkit.ChatColor;
10+
import net.kyori.adventure.text.format.NamedTextColor;
911
import org.bukkit.command.CommandSender;
12+
import tc.oc.pgm.util.Audience;
1013

1114
@CommandAlias("idle|idly")
1215
@CommandPermission(IdlyPermissions.COMMAND)
@@ -20,6 +23,6 @@ public class IdlyCommand extends BaseCommand {
2023
public void reload(CommandSender sender) {
2124
plugin.reloadConfig();
2225
config.reload(plugin.getConfig());
23-
sender.sendMessage(ChatColor.GREEN + "Idly config has been reloaded");
26+
Audience.get(sender).sendMessage(text("Idly config has been reloaded", NamedTextColor.GREEN));
2427
}
2528
}

src/main/java/tc/oc/occ/idly/IdlyManager.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
package tc.oc.occ.idly;
22

3-
import static net.kyori.adventure.key.Key.key;
4-
import static net.kyori.adventure.sound.Sound.sound;
53
import static net.kyori.adventure.text.Component.text;
64

75
import com.google.common.base.Objects;
86
import java.util.Map;
97
import java.util.UUID;
10-
import javax.annotation.Nullable;
118
import net.kyori.adventure.audience.Audience;
129
import net.kyori.adventure.sound.Sound;
1310
import net.kyori.adventure.text.Component;
1411
import net.kyori.adventure.text.format.NamedTextColor;
1512
import org.bukkit.Bukkit;
1613
import org.bukkit.entity.Player;
14+
import org.jetbrains.annotations.Nullable;
1715
import tc.oc.occ.idly.utils.OnlinePlayerUUIDMapAdapter;
1816
import tc.oc.pgm.api.match.Match;
1917
import tc.oc.pgm.api.player.MatchPlayer;
18+
import tc.oc.pgm.util.bukkit.Sounds;
2019

2120
public class IdlyManager {
2221

@@ -63,20 +62,19 @@ private void checkPlayers() {
6362
}
6463

6564
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);
6868

6969
boolean isPlaying = plugin.getAPI().isPlaying(player);
7070

7171
// Don't track observers when kick mode is disabled
7272
if (!config.isKickMode() && !isPlaying) return;
7373

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;
7976

77+
int duration = (isPlaying ? config.getParticipantDelay() : config.getObserverDelay());
8078
float remaining = duration - inactivity;
8179
if (remaining <= 0) {
8280
kick(player);
@@ -139,9 +137,9 @@ private void sendWarningCountdown(Player player, float tickTime) {
139137

140138
private static final Component OBSERVERS = text("Observers", NamedTextColor.AQUA);
141139
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);
143141
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);
145143

146144
private void sendWarning(Audience viewer, Component message, @Nullable Sound sound) {
147145
viewer.sendMessage(text().append(WARNING).append(message));

src/main/java/tc/oc/occ/idly/IdlyUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package tc.oc.occ.idly;
22

3-
import javax.annotation.Nullable;
43
import org.bukkit.entity.Player;
4+
import org.jetbrains.annotations.Nullable;
55
import tc.oc.pgm.api.PGM;
66
import tc.oc.pgm.api.player.MatchPlayer;
77

0 commit comments

Comments
 (0)