JSON now handled by JsonMessage Builder
This commit is contained in:
parent
88c53bf464
commit
f1314d5c26
@ -24,6 +24,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
import com.google.gson.stream.MalformedJsonException;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -34,6 +35,7 @@ import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jooq.tools.json.JSONObject;
|
||||
|
||||
@ -243,23 +245,17 @@ public class GameChatManager implements Listener
|
||||
|
||||
public boolean safeSend(Player sender, String format, String name, String message, Collection<Player> sendto)
|
||||
{
|
||||
String json = buildJSON(sender, format, name, _chatStats, message);
|
||||
final JsonMessage json = buildJSON(sender, format, name, _chatStats, message);
|
||||
try
|
||||
{
|
||||
IChatBaseComponent baseComponent = IChatBaseComponent.ChatSerializer.a(json);
|
||||
for(Player player : sendto)
|
||||
{
|
||||
UtilPlayer.sendPacket(player, new PacketPlayOutChat(baseComponent));
|
||||
}
|
||||
json.send(JsonMessage.MessageType.CHAT_BOX, sendto.toArray(new Player[sendto.size()]));
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("");
|
||||
System.out.println("ChatStats Failed to send JSON message..");
|
||||
System.out.println(json);
|
||||
System.out.println("");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -273,7 +269,7 @@ public class GameChatManager implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
private String buildJSON(Player player, String format, String name, LinkedList<ChatStatData> hoverText, String message)
|
||||
private JsonMessage buildJSON(Player player, String format, String name, LinkedList<ChatStatData> hoverText, String message)
|
||||
{
|
||||
LinkedList<Map.Entry<String, String>> temp = new LinkedList<Map.Entry<String, String>>();
|
||||
|
||||
@ -330,18 +326,17 @@ public class GameChatManager implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
String f = "{\"text\":\"\",\"extra\":[{\"text\":\"" + JSONObject.escape(format) + "\"},";
|
||||
String n = "{\"text\":\"" + JSONObject.escape(name) + "\",";
|
||||
String stats = "\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"";
|
||||
String m = ",{\"text\":\"" + JSONObject.escape(message) + "\"}]}";
|
||||
|
||||
String stats2 = "";
|
||||
for (int i = 0; i < temp.size(); i++)
|
||||
{
|
||||
stats += C.cWhite + JSONObject.escape(temp.get(i).getKey()) + C.cGray + JSONObject.escape(temp.get(i).getValue()) + (i >= temp.size()-1 ? "\"}}}" : "\\n");
|
||||
stats2 += C.cWhite + JSONObject.escape(temp.get(i).getKey()) + C.cGray + JSONObject.escape(temp.get(i).getValue()) + (i >= temp.size()-1 ? "" : "\\n");
|
||||
}
|
||||
|
||||
System.out.println(f + n + stats + m);
|
||||
return f + n + stats + m;
|
||||
JsonMessage jsonMessage = new JsonMessage("")
|
||||
.extra(JSONObject.escape(format))
|
||||
.add(JSONObject.escape(name)).hover("show_text", stats2)
|
||||
.add(JSONObject.escape(message));
|
||||
return jsonMessage;
|
||||
}
|
||||
|
||||
public String getRatio(int var1, int var2, String format)
|
||||
|
Loading…
Reference in New Issue
Block a user