Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.proc>full</maven.compiler.proc>
<tlibs.version>2.0.0</tlibs.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public LinkDiscordCommand(
this.gateService = gateService;
}

// Keep the existing legacy text representation, formatting, and exact-string comparisons.
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ private void tick() {
Bukkit.getScheduler().runTask(plugin, () -> deliverAndAck(snapshot));
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ private static boolean rejectIfScopeDisabled(Player player, String apiScope) {
return true;
}

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

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

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

// Keep the existing legacy text representation, formatting, and exact-string comparisons.
@SuppressWarnings("deprecation")
private boolean handleCreate(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Players only.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public UnlinkDiscordCommand(
this.gateService = gateService;
}

// Keep the existing legacy text representation, formatting, and exact-string comparisons.
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public WarningCommand(JavaPlugin plugin, LinkCache linkCache) {
this.linkCache = linkCache;
}

// Keep the existing legacy text representation, formatting, and exact-string comparisons.
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("tfmcweb.warning")) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/net/tfminecraft/tfmcweb/managers/WebCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public WebCommand(JavaPlugin plugin, LinkCache linkCache, DiscordGateService gat
this.gateService = gateService;
}

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

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

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

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

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

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

// Keep the existing legacy text representation, formatting, and exact-string comparisons.
@SuppressWarnings("deprecation")
private boolean cmdReconcile(CommandSender sender) {
List<Player> online = new ArrayList<>(Bukkit.getOnlinePlayers());
sender.sendMessage(ChatColor.GREEN + "[TFMCWeb] Reconciling "
Expand Down
44 changes: 16 additions & 28 deletions src/main/java/net/tfminecraft/tfmcweb/utils/ChatMessages.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package net.tfminecraft.tfmcweb.utils;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;

/**
* Prefixed chat helpers, including click-to-copy codes.
*/
public final class ChatMessages {

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

private ChatMessages() {}

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

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

public static void sendCopyableCode(Player player, String intro, String code) {
Expand All @@ -33,26 +33,14 @@ public static void sendCopyableCode(Player player, String intro, String code) {
return;
}

TextComponent label = new TextComponent("Code: ");
label.setColor(net.md_5.bungee.api.ChatColor.GRAY);

TextComponent codeComp = new TextComponent(code);
codeComp.setColor(net.md_5.bungee.api.ChatColor.AQUA);
codeComp.setBold(true);
codeComp.setClickEvent(
new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, code)
);
@SuppressWarnings("deprecation")
HoverEvent hover = new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder("Click to copy").create()
);
codeComp.setHoverEvent(hover);

TextComponent hint = new TextComponent(" (click to copy)");
hint.setColor(net.md_5.bungee.api.ChatColor.DARK_GRAY);
hint.setItalic(true);

player.spigot().sendMessage(label, codeComp, hint);
Component label = Component.text("Code: ", NamedTextColor.GRAY);
Component codeComp = Component.text(code, NamedTextColor.AQUA)
.decorate(TextDecoration.BOLD)
.clickEvent(ClickEvent.copyToClipboard(code))
.hoverEvent(HoverEvent.showText(Component.text("Click to copy")));
Component hint = Component.text(" (click to copy)", NamedTextColor.DARK_GRAY)
.decorate(TextDecoration.ITALIC);

player.sendMessage(Component.empty().append(label).append(codeComp).append(hint));
}
}