mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-16 13:11:40 +01:00
Add more component support to Player
This commit is contained in:
parent
9e9e979104
commit
1c2620840f
@ -406,10 +406,7 @@ public class Player extends LivingEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(Component textObject) {
|
public void sendMessage(Component textObject) {
|
||||||
sendMessageJson(Chat.toJsonString(textObject));
|
String json = Chat.toJsonString(textObject);
|
||||||
}
|
|
||||||
|
|
||||||
private void sendMessageJson(String json) {
|
|
||||||
playerConnection.sendPacket(new ChatMessagePacket(json, ChatMessagePacket.Position.CHAT));
|
playerConnection.sendPacket(new ChatMessagePacket(json, ChatMessagePacket.Position.CHAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,24 +447,31 @@ public class Player extends LivingEntity {
|
|||||||
playerConnection.sendPacket(stopSoundPacket);
|
playerConnection.sendPacket(stopSoundPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHeaderFooter(String header, String footer, char colorChar) {
|
public void sendHeaderFooter(Component header, Component footer) {
|
||||||
PlayerListHeaderAndFooterPacket playerListHeaderAndFooterPacket = new PlayerListHeaderAndFooterPacket();
|
PlayerListHeaderAndFooterPacket playerListHeaderAndFooterPacket = new PlayerListHeaderAndFooterPacket();
|
||||||
playerListHeaderAndFooterPacket.emptyHeader = header == null;
|
playerListHeaderAndFooterPacket.emptyHeader = header == null;
|
||||||
playerListHeaderAndFooterPacket.emptyFooter = footer == null;
|
playerListHeaderAndFooterPacket.emptyFooter = footer == null;
|
||||||
|
playerListHeaderAndFooterPacket.header = Chat.toJsonString(header);
|
||||||
playerListHeaderAndFooterPacket.header = Chat.toJsonString(Chat.fromLegacyText(header, colorChar));
|
playerListHeaderAndFooterPacket.footer = Chat.toJsonString(footer);
|
||||||
playerListHeaderAndFooterPacket.footer = Chat.toJsonString(Chat.fromLegacyText(footer, colorChar));
|
|
||||||
|
|
||||||
playerConnection.sendPacket(playerListHeaderAndFooterPacket);
|
playerConnection.sendPacket(playerListHeaderAndFooterPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendActionBarMessage(String message, char colorChar) {
|
public void sendHeaderFooter(String header, String footer, char colorChar) {
|
||||||
|
sendHeaderFooter(Chat.fromLegacyText(header, colorChar), Chat.fromLegacyText(footer, colorChar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendActionBarMessage(Component message) {
|
||||||
TitlePacket titlePacket = new TitlePacket();
|
TitlePacket titlePacket = new TitlePacket();
|
||||||
titlePacket.action = TitlePacket.Action.SET_ACTION_BAR;
|
titlePacket.action = TitlePacket.Action.SET_ACTION_BAR;
|
||||||
titlePacket.actionBarText = Chat.toJsonString(Chat.fromLegacyText(message, colorChar));
|
titlePacket.actionBarText = Chat.toJsonString(message);
|
||||||
playerConnection.sendPacket(titlePacket);
|
playerConnection.sendPacket(titlePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendActionBarMessage(String message, char colorChar) {
|
||||||
|
sendActionBarMessage(Chat.fromLegacyText(message, colorChar));
|
||||||
|
}
|
||||||
|
|
||||||
public void sendActionBarMessage(String message) {
|
public void sendActionBarMessage(String message) {
|
||||||
sendActionBarMessage(message, Chat.COLOR_CHAR);
|
sendActionBarMessage(message, Chat.COLOR_CHAR);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user