diff --git a/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java b/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java index e04d7ec..5ab1705 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java +++ b/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java @@ -1,20 +1,19 @@ package xyz.etztech.minecraftmanager; import com.google.gson.JsonArray; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.*; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import javax.xml.soap.Text; import java.io.FileWriter; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; public class MCMUtil { @@ -75,13 +74,13 @@ public class MCMUtil { } public static void staffMessage(TextComponent message) { - log(staffLog, message.getText()); + log(staffLog, message.toPlainText()); for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (player.hasPermission("minecraftmanager.staff")) { player.spigot().sendMessage(message); } } - Bukkit.getConsoleSender().spigot().sendMessage(message); + Bukkit.getConsoleSender().sendMessage(message.toPlainText()); } public static void globalMessage(String message) { diff --git a/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java b/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java index e9edba8..1dc6295 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java +++ b/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java @@ -70,12 +70,7 @@ public class AsyncPlayerChatListener implements Listener { HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create()); message.event(hover); message.append(chat).color(ChatColor.GREEN).event(hover); - for (Player player : event.getRecipients()) { - if (player.hasPermission("minecraftmanager.staff")) { - player.spigot().sendMessage(message.create()); - } - } - MCMUtil.log(MCMUtil.staffLog, componentText(message.create())); + MCMUtil.staffMessage(new TextComponent(message.create())); } else { message.append(chat); if (!MinecraftManager.getLogOverride()) { diff --git a/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java b/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java index 7ffc148..af97fc6 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java +++ b/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java @@ -93,6 +93,7 @@ public class MinecraftManagerThread extends Thread { .color(ChatColor.GREEN) .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/app info " + id)); TextComponent message = new TextComponent(builder.create()); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); MCMUtil.staffMessage(message); } @@ -101,6 +102,7 @@ public class MinecraftManagerThread extends Thread { .color(ChatColor.GREEN) .event(new ClickEvent(ClickEvent.Action.OPEN_URL, link)); TextComponent message = new TextComponent(builder.create()); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); MCMUtil.staffMessage(message); } @@ -140,6 +142,7 @@ public class MinecraftManagerThread extends Thread { ComponentBuilder builder = new ComponentBuilder(username + " was " + (accepted ? "accepted" : "denied") + ".") .color(ChatColor.GREEN); TextComponent staffMessage = new TextComponent(builder.create()); + staffMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); MCMUtil.staffMessage(staffMessage); } @@ -167,6 +170,7 @@ public class MinecraftManagerThread extends Thread { .append(StringUtils.join(args, " "), ComponentBuilder.FormatRetention.NONE) .color(ChatColor.GREEN); TextComponent message = new TextComponent(builder.create()); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); MCMUtil.staffMessage(message); }