From e6ac18e0c7d8c9f2e178dc4b926132cbb9576b1b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 17 Jul 2018 17:06:42 +0200 Subject: [PATCH] Fixed hover info for Discord --- src/main/java/buttondevteam/chat/ChatProcessing.java | 10 +++++----- src/test/java/buttondevteam/chat/ChatFormatIT.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/buttondevteam/chat/ChatProcessing.java b/src/main/java/buttondevteam/chat/ChatProcessing.java index c323ded..f363fb6 100644 --- a/src/main/java/buttondevteam/chat/ChatProcessing.java +++ b/src/main/java/buttondevteam/chat/ChatProcessing.java @@ -128,7 +128,7 @@ public class ChatProcessing { pingedconsole = false; // Will set it to true onmatch (static constructor) final String channelidentifier = getChannelID(channel, sender); - TellrawPart json = createTellraw(sender, message, player, mp, channelidentifier); + TellrawPart json = createTellraw(sender, message, player, mp, e.getUser(), channelidentifier); long combinetime = System.nanoTime(); ChatFormatter.Combine(formatters, message, json); combinetime = System.nanoTime() - combinetime; @@ -191,8 +191,8 @@ public class ChatProcessing { return gson.toJson(json); } - static TellrawPart createTellraw(CommandSender sender, String message, @Nullable Player player, @Nullable ChatPlayer mp, - final String channelidentifier) { + static TellrawPart createTellraw(CommandSender sender, String message, @Nullable Player player, + @Nullable ChatPlayer mp, @Nullable ChromaGamerBase cg, final String channelidentifier) { TellrawPart json = new TellrawPart(""); if (mp != null && mp.ChatOnly) { json.addExtra(new TellrawPart("[C]") @@ -213,8 +213,8 @@ public class ChatProcessing { .setHoverEvent(TellrawEvent.create(TellrawEvent.HoverAction.SHOW_TEXT, "Gold Patreon supporter"))); json.addExtra(new TellrawPart(" <")); TellrawPart hovertp = new TellrawPart(""); - if (mp != null) - hovertp.addExtra(new TellrawPart(mp.getInfo(ChromaGamerBase.InfoTarget.MCHover))); + if (cg != null) + hovertp.addExtra(new TellrawPart(cg.getInfo(ChromaGamerBase.InfoTarget.MCHover))); json.addExtra(new TellrawPart(getSenderName(sender, player)) .setHoverEvent(TellrawEvent.create(TellrawEvent.HoverAction.SHOW_TEXT, hovertp))); json.addExtra(new TellrawPart("> ")); diff --git a/src/test/java/buttondevteam/chat/ChatFormatIT.java b/src/test/java/buttondevteam/chat/ChatFormatIT.java index c59815b..af45011 100644 --- a/src/test/java/buttondevteam/chat/ChatFormatIT.java +++ b/src/test/java/buttondevteam/chat/ChatFormatIT.java @@ -66,11 +66,11 @@ public class ChatFormatIT { public void testMessage() { ArrayList cfs = ChatProcessing.addFormatters(Color.White); final String chid = ChatProcessing.getChannelID(Channel.GlobalChat, sender); - final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, chid); + final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, null, chid); ChatFormatter.Combine(cfs, message, tp); System.out.println("Testing: " + message); // System.out.println(ChatProcessing.toJson(tp)); - final TellrawPart expectedtp = ChatProcessing.createTellraw(sender, message, null, null, chid); + final TellrawPart expectedtp = ChatProcessing.createTellraw(sender, message, null, null, null, chid); // System.out.println("Raw: " + ChatProcessing.toJson(expectedtp)); for (TellrawPart extra : extras) expectedtp.addExtra(extra);