Bug Fixes

Fixes Ticket message in-game
Combines Application/Ticket messages to one source
master
Etzelia 2018-09-15 16:19:38 -05:00
parent 7cdf9509ae
commit 8a3c5a8962
3 changed files with 19 additions and 7 deletions

View File

@ -17,6 +17,7 @@ import xyz.etztech.minecraftmanager.MCMAPI;
import xyz.etztech.minecraftmanager.MCMUtil; import xyz.etztech.minecraftmanager.MCMUtil;
import xyz.etztech.minecraftmanager.objects.MCMResponse; import xyz.etztech.minecraftmanager.objects.MCMResponse;
import xyz.etztech.minecraftmanager.MinecraftManager; import xyz.etztech.minecraftmanager.MinecraftManager;
import xyz.etztech.minecraftmanager.objects.MinecraftManagerThread;
import java.util.Map; import java.util.Map;
@ -41,10 +42,7 @@ public class CommandTicket implements CommandExecutor {
player.sendMessage(response.getMCMessage()); player.sendMessage(response.getMCMessage());
try { try {
JsonObject extra = (JsonObject) response.getExtra(); JsonObject extra = (JsonObject) response.getExtra();
TextComponent message = new TextComponent(ChatColor.GREEN + "New Ticket #" + MinecraftManagerThread.ticket(player.getName(), extra.get("id").getAsString(), extra.get("link").getAsString());
extra.get("id").getAsString() + ". Click for more info.");
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, extra.get("link").getAsString()));
MCMUtil.staffMessage(message);
} catch (Exception ex) {} } catch (Exception ex) {}
} }
} }

View File

@ -15,6 +15,7 @@ import xyz.etztech.core.web.ICallback;
import xyz.etztech.minecraftmanager.*; import xyz.etztech.minecraftmanager.*;
import xyz.etztech.minecraftmanager.objects.Application; import xyz.etztech.minecraftmanager.objects.Application;
import xyz.etztech.minecraftmanager.objects.MCMResponse; import xyz.etztech.minecraftmanager.objects.MCMResponse;
import xyz.etztech.minecraftmanager.objects.MinecraftManagerThread;
import xyz.etztech.minecraftmanager.objects.Question; import xyz.etztech.minecraftmanager.objects.Question;
import java.util.ArrayList; import java.util.ArrayList;
@ -145,8 +146,7 @@ public class AsyncPlayerChatListener implements Listener {
public void invoke(String s) { public void invoke(String s) {
MCMResponse response = new MCMResponse(s); MCMResponse response = new MCMResponse(s);
if (response.getStatus()) { if (response.getStatus()) {
player.sendMessage(ChatColor.GOLD + Question.COMPLETE.getQuestion()); MinecraftManagerThread.application(player.getName(), response.getExtra().getAsString());
MCMUtil.staffMessage(ChatColor.GREEN + "New application #" + response.getExtra().getAsString() + " from " + player.getName(), "/app info " + response.getExtra().getAsString());
} else { } else {
player.sendMessage(ChatColor.RED + response.getMessage()); player.sendMessage(ChatColor.RED + response.getMessage());
} }

View File

@ -1,5 +1,8 @@
package xyz.etztech.minecraftmanager.objects; 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.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -56,6 +59,9 @@ public class MinecraftManagerThread extends Thread {
case "application": case "application":
application(args.get(0), args.get(1)); application(args.get(0), args.get(1));
break; break;
case "ticket":
ticket(args.get(0), args.get(1), args.get(2));
break;
case "accept": case "accept":
action(args.get(0), true); action(args.get(0), true);
break; 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; 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); MCMUtil.staffMessage(message);
} }