From 1880a61b2dd3ea5dcb5c597b97cd464ffaf84da3 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Fri, 4 Oct 2019 16:43:17 -0500 Subject: [PATCH] Update colors to JSON message format Signed-off-by: Etzelia --- docs/source/commands.rst | 2 +- .../xyz/etztech/qol/commands/DynmapLinkCommand.java | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/source/commands.rst b/docs/source/commands.rst index 6f35513..9267bf1 100644 --- a/docs/source/commands.rst +++ b/docs/source/commands.rst @@ -43,4 +43,4 @@ Alias ``/names`` and ``/name`` ``/checkup `` Start a checkup, teleporting to all online players. -``/dynmaplink [] []`` Start a checkup, teleporting to all online players. +``/dynmaplink [] []`` Get a link to Dynmap with your current location. Optionally choose the map (flat, surface, etc.) and zoom level. diff --git a/src/main/java/xyz/etztech/qol/commands/DynmapLinkCommand.java b/src/main/java/xyz/etztech/qol/commands/DynmapLinkCommand.java index e23e930..fe002b4 100644 --- a/src/main/java/xyz/etztech/qol/commands/DynmapLinkCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/DynmapLinkCommand.java @@ -1,22 +1,17 @@ package xyz.etztech.qol.commands; +import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.TextComponent; -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.dynmap.DynmapAPI; import xyz.etztech.qol.EtzTechUtil; import xyz.etztech.qol.Lang; import xyz.etztech.qol.QoL; -import java.util.*; - public class DynmapLinkCommand implements CommandExecutor { QoL plugin; @@ -48,10 +43,12 @@ public class DynmapLinkCommand implements CommandExecutor { String map = args.length > 0 ? args[0] : defaultMap; String zoom = args.length > 1 ? args[1] : defaultZoom; String url = String.format("%s?worldname=%s&mapname=%s&zoom=%s&x=%s&y=%s&z=%s", base, world, map, zoom, x, y, z); - message = new TextComponent(ChatColor.YELLOW + "Click here to see your location on Dynmap."); + message = new TextComponent("Click here to see your location on Dynmap."); + message.setColor(ChatColor.YELLOW); message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)); } else { - message = new TextComponent(ChatColor.RED + "This command is currently disabled or the server has no Dynmap!"); + message = new TextComponent("This command is currently disabled or the server has no Dynmap!"); + message.setColor(ChatColor.RED); } player.spigot().sendMessage(message);