Added option to only set footer, and clear both

This commit is contained in:
replaceitem committed 2021-04-17 12:33:31 +02:00
1 parent a106f2611f
commit eaa242c8eb
2 files changed
+21 -5

No files matched your search

+4 -1
View File
@@ -277,9 +277,12 @@ Sends the player (or players if `players` is a list) a title of a specific type,
Executing with those will set the times to the specified ones.
Note that `actionbar` type doesn't support changing times (vanilla bug, see [MC-106167](https://bugs.mojang.com/browse/MC-106167)).
### `display_title(players, 'player_list', header, footer),`
### `display_title(players, 'player_list')`
### `display_title(players, 'player_list', footer)`
### `display_title(players, 'player_list', header, footer)`
Changes the header and footer of the player list.
When no `header` and `footer` is specified, they will be reset.
Keep in mind this would interfere with carpet's loggers, so if you are using this, you need to keep them off.
### `logger(msg), logger(type, msg)`
+17 -4
View File
@@ -561,21 +561,34 @@ public class Auxiliary {
action = Action.CLEAR;
break;
case "player_list":
Text header;
Text footer;
if (lv.size() > 3)
{
Text header;
if(lv.size() == 2) {
footer = new LiteralText("");
header = new LiteralText("");
} else if(lv.size() == 3) {
pVal = lv.get(2).evalValue(c);
if (pVal instanceof FormattedTextValue)
footer = ((FormattedTextValue) pVal).getText();
else
footer = new LiteralText(pVal.getString());
header = new LiteralText("");
} else {
pVal = lv.get(2).evalValue(c);
if (pVal instanceof FormattedTextValue)
header = ((FormattedTextValue) pVal).getText();
else
header = new LiteralText(pVal.getString());
pVal = lv.get(3).evalValue(c);
if (pVal instanceof FormattedTextValue)
footer = ((FormattedTextValue) pVal).getText();
else
footer = new LiteralText(pVal.getString());
} else throw new InternalExpressionException("Third and fourth argument of 'display_title' must be present for 'player_list' type");
}
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
((PlayerListHeaderS2CPacketMixin) packet).setFooter(footer);
((PlayerListHeaderS2CPacketMixin) packet).setHeader(header);