Skip to content

Commit 69e3399

Browse files
authored
fix: resolve Paper API build warnings (#20)
1 parent 9f59414 commit 69e3399

8 files changed

Lines changed: 47 additions & 28 deletions

File tree

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<properties>
1212
<maven.compiler.release>21</maven.compiler.release>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.proc>full</maven.compiler.proc>
1415
<tlibs.version>2.0.0</tlibs.version>
1516
</properties>
1617

‎src/main/java/net/tfminecraft/tfmcweb/managers/LinkDiscordCommand.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public LinkDiscordCommand(
3333
this.gateService = gateService;
3434
}
3535

36+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
37+
@SuppressWarnings("deprecation")
3638
@Override
3739
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
3840
if (!(sender instanceof Player)) {

‎src/main/java/net/tfminecraft/tfmcweb/managers/PluginNoticePoller.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ private void tick() {
7373
Bukkit.getScheduler().runTask(plugin, () -> deliverAndAck(snapshot));
7474
}
7575

76+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
77+
@SuppressWarnings("deprecation")
7678
private void deliverAndAck(List<PluginNotice> notices) {
7779
List<Integer> toAck = new ArrayList<>();
7880

‎src/main/java/net/tfminecraft/tfmcweb/managers/TokenCommand.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ private static boolean rejectIfScopeDisabled(Player player, String apiScope) {
7575
return true;
7676
}
7777

78+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
79+
@SuppressWarnings("deprecation")
7880
@Override
7981
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
8082
if (args.length == 0) {
@@ -98,6 +100,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
98100
return true;
99101
}
100102

103+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
104+
@SuppressWarnings("deprecation")
101105
private void sendUsage(CommandSender sender) {
102106
boolean canCreate = sender.hasPermission(PERM_CREATE) || sender.hasPermission(PERM_CREATE_STAFF);
103107
boolean canReset = sender.hasPermission(PERM_RESET);
@@ -121,6 +125,8 @@ private void sendUsage(CommandSender sender) {
121125
}
122126
}
123127

128+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
129+
@SuppressWarnings("deprecation")
124130
private boolean handleResetCooldowns(CommandSender sender, String[] args) {
125131
if (!sender.hasPermission(PERM_RESET)) {
126132
if (sender instanceof Player) {
@@ -185,6 +191,8 @@ private boolean handleResetCooldowns(CommandSender sender, String[] args) {
185191
return true;
186192
}
187193

194+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
195+
@SuppressWarnings("deprecation")
188196
private boolean handleCreate(CommandSender sender, String[] args) {
189197
if (!(sender instanceof Player)) {
190198
sender.sendMessage(ChatColor.RED + "Players only.");

‎src/main/java/net/tfminecraft/tfmcweb/managers/UnlinkDiscordCommand.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public UnlinkDiscordCommand(
3232
this.gateService = gateService;
3333
}
3434

35+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
36+
@SuppressWarnings("deprecation")
3537
@Override
3638
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
3739
if (!(sender instanceof Player)) {

‎src/main/java/net/tfminecraft/tfmcweb/managers/WarningCommand.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public WarningCommand(JavaPlugin plugin, LinkCache linkCache) {
3131
this.linkCache = linkCache;
3232
}
3333

34+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
35+
@SuppressWarnings("deprecation")
3436
@Override
3537
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
3638
if (!sender.hasPermission("tfmcweb.warning")) {

‎src/main/java/net/tfminecraft/tfmcweb/managers/WebCommand.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public WebCommand(JavaPlugin plugin, LinkCache linkCache, DiscordGateService gat
4646
this.gateService = gateService;
4747
}
4848

49+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
50+
@SuppressWarnings("deprecation")
4951
@Override
5052
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
5153
if (!sender.hasPermission("tfmcweb.admin")) {
@@ -78,6 +80,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
7880
}
7981
}
8082

83+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
84+
@SuppressWarnings("deprecation")
8185
private boolean cmdStatus(CommandSender sender) {
8286
sender.sendMessage(ChatColor.GREEN + "[TFMCWeb] Checking API…");
8387
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
@@ -101,6 +105,8 @@ private boolean cmdStatus(CommandSender sender) {
101105
return true;
102106
}
103107

108+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
109+
@SuppressWarnings("deprecation")
104110
private boolean cmdReload(CommandSender sender) {
105111
if (plugin instanceof TFMCWeb) {
106112
((TFMCWeb) plugin).reloadLocalConfig();
@@ -114,6 +120,8 @@ private boolean cmdReload(CommandSender sender) {
114120
return true;
115121
}
116122

123+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
124+
@SuppressWarnings("deprecation")
117125
private boolean cmdSyncMeta(CommandSender sender, String[] args) {
118126
if (args.length >= 2) {
119127
OfflinePlayer target = resolvePlayer(args[1]);
@@ -136,6 +144,8 @@ private boolean cmdSyncMeta(CommandSender sender, String[] args) {
136144
return true;
137145
}
138146

147+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
148+
@SuppressWarnings("deprecation")
139149
private boolean cmdLookup(CommandSender sender, String[] args) {
140150
if (args.length < 2) {
141151
sender.sendMessage(ChatColor.YELLOW + "Usage: /web lookup <player>");
@@ -182,6 +192,8 @@ private boolean cmdLookup(CommandSender sender, String[] args) {
182192
return true;
183193
}
184194

195+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
196+
@SuppressWarnings("deprecation")
185197
private boolean cmdUnlink(CommandSender sender, String[] args) {
186198
if (args.length < 2) {
187199
sender.sendMessage(ChatColor.YELLOW + "Usage: /web unlink <player>");
@@ -214,6 +226,8 @@ private boolean cmdUnlink(CommandSender sender, String[] args) {
214226
return true;
215227
}
216228

229+
// Keep the existing legacy text representation, formatting, and exact-string comparisons.
230+
@SuppressWarnings("deprecation")
217231
private boolean cmdReconcile(CommandSender sender) {
218232
List<Player> online = new ArrayList<>(Bukkit.getOnlinePlayers());
219233
sender.sendMessage(ChatColor.GREEN + "[TFMCWeb] Reconciling "
Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package net.tfminecraft.tfmcweb.utils;
22

3-
import org.bukkit.ChatColor;
43
import org.bukkit.entity.Player;
54

6-
import net.md_5.bungee.api.chat.ClickEvent;
7-
import net.md_5.bungee.api.chat.ComponentBuilder;
8-
import net.md_5.bungee.api.chat.HoverEvent;
9-
import net.md_5.bungee.api.chat.TextComponent;
5+
import net.kyori.adventure.text.Component;
6+
import net.kyori.adventure.text.event.ClickEvent;
7+
import net.kyori.adventure.text.event.HoverEvent;
8+
import net.kyori.adventure.text.format.NamedTextColor;
9+
import net.kyori.adventure.text.format.TextDecoration;
1010

1111
/**
1212
* Prefixed chat helpers, including click-to-copy codes.
1313
*/
1414
public final class ChatMessages {
1515

16-
public static final String PREFIX = ChatColor.GREEN + "[TFMCWeb] " + ChatColor.RESET;
16+
public static final String PREFIX = "\u00A7a[TFMCWeb] \u00A7r";
1717

1818
private ChatMessages() {}
1919

@@ -22,7 +22,7 @@ public static void info(Player player, String message) {
2222
}
2323

2424
public static void error(Player player, String message) {
25-
player.sendMessage(PREFIX + ChatColor.RED + message);
25+
player.sendMessage(PREFIX + "\u00A7c" + message);
2626
}
2727

2828
public static void sendCopyableCode(Player player, String intro, String code) {
@@ -33,26 +33,14 @@ public static void sendCopyableCode(Player player, String intro, String code) {
3333
return;
3434
}
3535

36-
TextComponent label = new TextComponent("Code: ");
37-
label.setColor(net.md_5.bungee.api.ChatColor.GRAY);
38-
39-
TextComponent codeComp = new TextComponent(code);
40-
codeComp.setColor(net.md_5.bungee.api.ChatColor.AQUA);
41-
codeComp.setBold(true);
42-
codeComp.setClickEvent(
43-
new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, code)
44-
);
45-
@SuppressWarnings("deprecation")
46-
HoverEvent hover = new HoverEvent(
47-
HoverEvent.Action.SHOW_TEXT,
48-
new ComponentBuilder("Click to copy").create()
49-
);
50-
codeComp.setHoverEvent(hover);
51-
52-
TextComponent hint = new TextComponent(" (click to copy)");
53-
hint.setColor(net.md_5.bungee.api.ChatColor.DARK_GRAY);
54-
hint.setItalic(true);
55-
56-
player.spigot().sendMessage(label, codeComp, hint);
36+
Component label = Component.text("Code: ", NamedTextColor.GRAY);
37+
Component codeComp = Component.text(code, NamedTextColor.AQUA)
38+
.decorate(TextDecoration.BOLD)
39+
.clickEvent(ClickEvent.copyToClipboard(code))
40+
.hoverEvent(HoverEvent.showText(Component.text("Click to copy")));
41+
Component hint = Component.text(" (click to copy)", NamedTextColor.DARK_GRAY)
42+
.decorate(TextDecoration.ITALIC);
43+
44+
player.sendMessage(Component.empty().append(label).append(codeComp).append(hint));
5745
}
5846
}

0 commit comments

Comments
 (0)