From 1543a11049f079b39d2e3b2e51015a202a2cdb38 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 29 Jun 2016 14:36:25 +0200 Subject: [PATCH] Chat formatting still WIP... --- .../thebuttonmcchat/ChatProcessing.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/io/github/norbipeti/thebuttonmcchat/ChatProcessing.java b/src/io/github/norbipeti/thebuttonmcchat/ChatProcessing.java index cb808c8..f1195cb 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/ChatProcessing.java +++ b/src/io/github/norbipeti/thebuttonmcchat/ChatProcessing.java @@ -72,7 +72,8 @@ public class ChatProcessing { colormode = ChatFormatter.Color.Green; // If greentext, ignore channel or player colors - formatters.add(new ChatFormatter(Pattern.compile("(.+)"), colormode, "")); + formatters + .add(new ChatFormatter(Pattern.compile("(.+)"), colormode, "")); String formattedmessage = message; formattedmessage = formattedmessage.replace("\\", "\\\\"); @@ -85,18 +86,18 @@ public class ChatProcessing { formatters .add(new ChatFormatter( Pattern.compile("(? { + ChatFormatter.Color.Aqua, (String match) -> { Player p = Bukkit.getPlayer(match); if (p == null) { System.out.println("Error: Can't find player " + match @@ -137,7 +138,6 @@ public class ChatProcessing { .add(new ChatFormatter( Pattern.compile(sb.toString()), ChatFormatter.Color.Aqua, - "", (String match) -> { for (String n : PlayerListener.nicknames.keySet()) { String nwithoutformatting = new String(n); @@ -193,10 +193,10 @@ public class ChatProcessing { pingedconsole = false; formatters.add(new ChatFormatter(Pattern.compile("(?i)" - + Pattern.quote("@console")), ChatFormatter.Color.Aqua, "", ( + + Pattern.quote("@console")), ChatFormatter.Color.Aqua, ( String match) -> { if (!pingedconsole) { - System.out.println("\007"); + System.out.print("\007"); pingedconsole = true; } return true; @@ -244,11 +244,11 @@ public class ChatProcessing { (mp != null && mp.PlayerName.equals("\nAlpha_Bacca44") ? "\nDeaths: " + PlayerListener.AlphaDeaths : ""))); - json.append("{\"text\":\"> \",\"color\":\"white\"},"); + json.append("{\"text\":\"> \",\"color\":\"white\"}"); formatters .add(new ChatFormatter(Pattern.compile("#(\\w+)"), - ChatFormatter.Color.Blue, "", + ChatFormatter.Color.Blue, "https://twitter.com/hashtag/$1")); /* @@ -267,8 +267,12 @@ public class ChatProcessing { * , colormode, original, original)); } */ - json.append(String.format("{\"text\":\"%s\",\"color\":\"%s\"}]", - ChatFormatter.Combine(formatters, formattedmessage), colormode)); + /* + * json.append(String.format("{\"text\":\"%s\",\"color\":\"%s\"}]", + * ChatFormatter.Combine(formatters, formattedmessage), colormode)); + */ + json.append(ChatFormatter.Combine(formatters, formattedmessage)); + json.append("]"); String jsonstr = json.toString(); if (jsonstr.length() >= 32767) { sender.sendMessage("§cError: Message too large. Try shortening it, or remove hashtags and other formatting.");