use of net.minecraft.text.Text in project dynmap by webbukkit.
the class FabricPlayer method sendMessage.
@Override
public void sendMessage(String msg) {
Text ichatcomponent = new LiteralText(msg);
player.sendSystemMessage(ichatcomponent, Util.NIL_UUID);
}
use of net.minecraft.text.Text in project dynmap by webbukkit.
the class FabricServer method broadcastMessage.
@Override
public void broadcastMessage(String msg) {
Text component = new LiteralText(msg);
server.getPlayerManager().broadcastChatMessage(component, MessageType.SYSTEM, Util.NIL_UUID);
Log.info(stripChatColor(msg));
}
use of net.minecraft.text.Text in project dynmap by webbukkit.
the class FabricPlayer method sendMessage.
@Override
public void sendMessage(String msg) {
Text ichatcomponent = new LiteralText(msg);
player.sendSystemMessage(ichatcomponent, Util.NIL_UUID);
}
use of net.minecraft.text.Text in project dynmap by webbukkit.
the class FabricServer method broadcastMessage.
@Override
public void broadcastMessage(String msg) {
Text component = new LiteralText(msg);
server.getPlayerManager().broadcastChatMessage(component, MessageType.SYSTEM, Util.NIL_UUID);
Log.info(stripChatColor(msg));
}
use of net.minecraft.text.Text in project meteor-client by MeteorDevelopment.
the class TextUtils method preOrderTraverse.
/**
* Performs a pre-order text traversal of {@link Text} components and ref-returns a sequential list
* of {@link ColoredText}, such that one could know the text and its color by iterating over the list.
*
* @param text The text to flatten
* @param stack An empty stack. This is used by the recursive algorithm to keep track of the parents of the current iteration
* @param coloredTexts The list of colored text to return
*/
private static void preOrderTraverse(Text text, Stack<ColoredText> stack, List<ColoredText> coloredTexts) {
if (text == null)
return;
// Do actions here
String textString = text.asString();
TextColor mcTextColor = text.getStyle().getColor();
// If mcTextColor is null, the color should be inherited from its parent. In this case, the path of the recursion is stored on the stack,
// with the current element's parent at the top, so simply peek it if possible. If not, there is no parent element,
// and with no color, use the default of white.
Color textColor;
if (mcTextColor == null) {
if (stack.empty())
// No color defined, use default white
textColor = new Color(255, 255, 255);
else
// Use parent color
textColor = stack.peek().getColor();
} else {
// Has a color defined, so use that
// Sets alpha to max. Some damn reason Color's packed ctor is in ARGB format, not RGBA
textColor = new Color((text.getStyle().getColor().getRgb()) | 0xFF000000);
}
ColoredText coloredText = new ColoredText(textString, textColor);
coloredTexts.add(coloredText);
// For the recursion algorithm's child, the current coloredText is its parent, so add to stack
stack.push(coloredText);
// Recursively traverse
for (Text child : text.getSiblings()) preOrderTraverse(child, stack, coloredTexts);
stack.pop();
}
Aggregations