Requesting PR for 1.19.1 (and 1.19.2) #44
No files matched your search
@@ -119,7 +119,7 @@ public class Bot extends Thread {
|
||||
new ArrayList<>(),
|
||||
true,
|
||||
new ArrayList<>(),
|
||||
new LastSeenMessage(uuid, new byte[0])
|
||||
null
|
||||
));
|
||||
} else {
|
||||
// Send chat message
|
||||
@@ -132,7 +132,7 @@ public class Bot extends Thread {
|
||||
new byte[0],
|
||||
true,
|
||||
new ArrayList<>(),
|
||||
new LastSeenMessage(uuid, new byte[0])
|
||||
null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,11 @@ public class MainListener implements SessionListener {
|
||||
} else { // If this was normal case when unsigned content was not null.
|
||||
if (message instanceof TextComponent) { // For normal chat packets.
|
||||
// Log.chat(Utils.getFullText((TextComponent) message, Main.coloredChat)); // Use this for only messages.
|
||||
if (sender != null)
|
||||
Log.chat(Utils.getFullText((TextComponent) sender, (TextComponent) message, Main.coloredChat)); // Use this for messages and sender's username.
|
||||
else
|
||||
Log.chat(Utils.getFullText(null, (TextComponent) message, Main.coloredChat)); // Use this for messages and sender's username.
|
||||
}
|
||||
|
||||
if (message instanceof TranslatableComponent) { // For system chat packets (such as user joining server).
|
||||
TranslatableComponent msg = (TranslatableComponent) message;
|
||||
Log.chat("[T]", Utils.translate(msg));
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -59,21 +60,21 @@ public class Utils {
|
||||
* @param colored Whether if this output was colored or not.
|
||||
* @return Returns String in "Username : Message" format.
|
||||
*/
|
||||
public static String getFullText(TextComponent sender, TextComponent message, boolean colored) {
|
||||
public static String getFullText(@Nullable TextComponent sender, TextComponent message, boolean colored) {
|
||||
if (colored) { // Check if we are using colors.
|
||||
Style senderStyle = sender.style();
|
||||
Style messageStyle = message.style();
|
||||
|
||||
StringBuilder outString = new StringBuilder();
|
||||
|
||||
if (sender != null) {
|
||||
Style senderStyle = sender.style();
|
||||
if (senderStyle.color() != null) { // Generate sender text with color.
|
||||
NamedTextColor color = (NamedTextColor) senderStyle.color();
|
||||
outString.append(colorize(sender.content(), getColor(color)));
|
||||
} else {
|
||||
outString.append(sender.content());
|
||||
}
|
||||
|
||||
outString.append(" : "); // Add delimiter as : between sender and message.
|
||||
}
|
||||
|
||||
if (messageStyle.color() != null) { // Generate message text with color.
|
||||
NamedTextColor color = (NamedTextColor) messageStyle.color();
|
||||
@@ -84,6 +85,9 @@ public class Utils {
|
||||
|
||||
return outString.toString();
|
||||
} else { // When color formating was disabled.
|
||||
if (sender == null)
|
||||
return message.content();
|
||||
else
|
||||
return sender.content() + " : " + message.content();
|
||||
}
|
||||
}
|
||||
@@ -98,23 +102,27 @@ public class Utils {
|
||||
* @param colored Whether if this output was colored or not.
|
||||
* @return Returns String in "Username : Message" format.
|
||||
*/
|
||||
public static String getFullText(TextComponent sender, String message, boolean colored) {
|
||||
public static String getFullText(@Nullable TextComponent sender, String message, boolean colored) {
|
||||
if (colored) { // Check if we are using colors.
|
||||
Style senderStyle = sender.style();
|
||||
|
||||
StringBuilder outString = new StringBuilder();
|
||||
|
||||
if (sender != null) {
|
||||
Style senderStyle = sender.style();
|
||||
if (senderStyle.color() != null) { // Generate sender text with color.
|
||||
NamedTextColor color = (NamedTextColor) senderStyle.color();
|
||||
outString.append(colorize(sender.content(), getColor(color)));
|
||||
} else {
|
||||
outString.append(sender.content());
|
||||
}
|
||||
|
||||
outString.append(" : "); // Add delimiter as : between sender and message.
|
||||
}
|
||||
|
||||
outString.append(message);
|
||||
return outString.toString();
|
||||
} else { // When color formating was disabled.
|
||||
if (sender == null)
|
||||
return message;
|
||||
else
|
||||
return sender.content() + " : " + message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user