diff --git a/src/main/java/xyz/etztech/minecraftmanager/command/CommandTicket.java b/src/main/java/xyz/etztech/minecraftmanager/command/CommandTicket.java index 5a23023..df7ea3b 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/command/CommandTicket.java +++ b/src/main/java/xyz/etztech/minecraftmanager/command/CommandTicket.java @@ -17,6 +17,7 @@ import xyz.etztech.minecraftmanager.MCMAPI; import xyz.etztech.minecraftmanager.MCMUtil; import xyz.etztech.minecraftmanager.objects.MCMResponse; import xyz.etztech.minecraftmanager.MinecraftManager; +import xyz.etztech.minecraftmanager.objects.MinecraftManagerThread; import java.util.Map; @@ -41,10 +42,7 @@ public class CommandTicket implements CommandExecutor { player.sendMessage(response.getMCMessage()); try { JsonObject extra = (JsonObject) response.getExtra(); - TextComponent message = new TextComponent(ChatColor.GREEN + "New Ticket #" + - extra.get("id").getAsString() + ". Click for more info."); - message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, extra.get("link").getAsString())); - MCMUtil.staffMessage(message); + MinecraftManagerThread.ticket(player.getName(), extra.get("id").getAsString(), extra.get("link").getAsString()); } catch (Exception ex) {} } } diff --git a/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java b/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java index 7032b2c..e9edba8 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java +++ b/src/main/java/xyz/etztech/minecraftmanager/listeners/AsyncPlayerChatListener.java @@ -15,6 +15,7 @@ import xyz.etztech.core.web.ICallback; import xyz.etztech.minecraftmanager.*; import xyz.etztech.minecraftmanager.objects.Application; import xyz.etztech.minecraftmanager.objects.MCMResponse; +import xyz.etztech.minecraftmanager.objects.MinecraftManagerThread; import xyz.etztech.minecraftmanager.objects.Question; import java.util.ArrayList; @@ -145,8 +146,7 @@ public class AsyncPlayerChatListener implements Listener { public void invoke(String s) { MCMResponse response = new MCMResponse(s); if (response.getStatus()) { - player.sendMessage(ChatColor.GOLD + Question.COMPLETE.getQuestion()); - MCMUtil.staffMessage(ChatColor.GREEN + "New application #" + response.getExtra().getAsString() + " from " + player.getName(), "/app info " + response.getExtra().getAsString()); + MinecraftManagerThread.application(player.getName(), response.getExtra().getAsString()); } else { player.sendMessage(ChatColor.RED + response.getMessage()); } diff --git a/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java b/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java index a0449fd..8192239 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java +++ b/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java @@ -1,5 +1,8 @@ package xyz.etztech.minecraftmanager.objects; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.TextComponent; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -56,6 +59,9 @@ public class MinecraftManagerThread extends Thread { case "application": application(args.get(0), args.get(1)); break; + case "ticket": + ticket(args.get(0), args.get(1), args.get(2)); + break; case "accept": action(args.get(0), true); break; @@ -82,8 +88,16 @@ public class MinecraftManagerThread extends Thread { } } - private void application(String username, String id) { + public static void application(String username, String id) { String message = ChatColor.GREEN + "New application #" + id + " from " + username; + MCMUtil.staffMessage(message, "/app info " + id); + } + + public static void ticket(String username, String id, String link) { + ComponentBuilder builder = new ComponentBuilder("New ticket #" + id + " from " + username + ". Click for more info.") + .color(net.md_5.bungee.api.ChatColor.GREEN) + .event(new ClickEvent(ClickEvent.Action.OPEN_URL, link)); + TextComponent message = new TextComponent(builder.create()); MCMUtil.staffMessage(message); }