Added Deprecated to old staffMessage method
Fixed most places using old method to use new JSON message
master
Etzelia 2018-09-21 19:21:09 -05:00
parent a7fae8e96c
commit 8ef9dff69f
2 changed files with 30 additions and 9 deletions

View File

@ -45,9 +45,19 @@ public class MCMUtil {
} }
public static void staffMessage(String message) { public static void staffMessage(String message) {
staffMessage(message, null); log(staffLog, message);
HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create());
TextComponent text = new TextComponent(message);
text.setHoverEvent(hover);
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
if (player.hasPermission("minecraftmanager.staff")) {
player.spigot().sendMessage(text);
}
}
Bukkit.getConsoleSender().sendMessage(message);
} }
@Deprecated
public static void staffMessage(String message, String hoverCommand) { public static void staffMessage(String message, String hoverCommand) {
log(staffLog, message); log(staffLog, message);
HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create()); HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create());
@ -71,7 +81,7 @@ public class MCMUtil {
player.spigot().sendMessage(message); player.spigot().sendMessage(message);
} }
} }
Bukkit.getConsoleSender().sendMessage(message.getText()); Bukkit.getConsoleSender().spigot().sendMessage(message);
} }
public static void globalMessage(String message) { public static void globalMessage(String message) {

View File

@ -1,13 +1,13 @@
package xyz.etztech.minecraftmanager.objects; package xyz.etztech.minecraftmanager.objects;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; 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.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import xyz.etztech.minecraftmanager.MCMUtil; import xyz.etztech.minecraftmanager.MCMUtil;
import xyz.etztech.minecraftmanager.MinecraftManager; import xyz.etztech.minecraftmanager.MinecraftManager;
@ -89,13 +89,16 @@ public class MinecraftManagerThread extends Thread {
} }
public static void application(String username, String id) { public static void application(String username, String id) {
String message = ChatColor.GREEN + "New application #" + id + " from " + username; ComponentBuilder builder = new ComponentBuilder("New application #" + id + " from " + username)
MCMUtil.staffMessage(message, "/app info " + id); .color(ChatColor.GREEN)
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/app info " + id));
TextComponent message = new TextComponent(builder.create());
MCMUtil.staffMessage(message);
} }
public static void ticket(String username, String id, String link) { public static void ticket(String username, String id, String link) {
ComponentBuilder builder = new ComponentBuilder("New ticket #" + id + " from " + username + ". Click for more info.") ComponentBuilder builder = new ComponentBuilder("New ticket #" + id + " from " + username + ". Click for more info.")
.color(net.md_5.bungee.api.ChatColor.GREEN) .color(ChatColor.GREEN)
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, link)); .event(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
TextComponent message = new TextComponent(builder.create()); TextComponent message = new TextComponent(builder.create());
MCMUtil.staffMessage(message); MCMUtil.staffMessage(message);
@ -134,7 +137,10 @@ public class MinecraftManagerThread extends Thread {
} }
// Message to staff // Message to staff
MCMUtil.staffMessage(ChatColor.GREEN + username + " was " + (accepted ? "accepted" : "denied") + "."); ComponentBuilder builder = new ComponentBuilder(username + " was " + (accepted ? "accepted" : "denied") + ".")
.color(ChatColor.GREEN);
TextComponent staffMessage = new TextComponent(builder.create());
MCMUtil.staffMessage(staffMessage);
} }
private static void runTask(final String command, final String username) { private static void runTask(final String command, final String username) {
@ -156,7 +162,12 @@ public class MinecraftManagerThread extends Thread {
private void staffChat(ArrayList<String> args) { private void staffChat(ArrayList<String> args) {
String name = args.get(0); String name = args.get(0);
args.remove(0); args.remove(0);
MCMUtil.staffMessage(ChatColor.GOLD + "[MCM] " + name + " > " + ChatColor.GREEN + StringUtils.join(args, " ")); ComponentBuilder builder = new ComponentBuilder("[MCM] " + name + " > ")
.color(ChatColor.GOLD)
.append(StringUtils.join(args, " "), ComponentBuilder.FormatRetention.NONE)
.color(ChatColor.GREEN);
TextComponent message = new TextComponent(builder.create());
MCMUtil.staffMessage(message);
} }
} }