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