diff --git a/src/main/java/net/minestom/server/advancements/Advancement.java b/src/main/java/net/minestom/server/advancements/Advancement.java index c6a7e356b..ea0dc2a55 100644 --- a/src/main/java/net/minestom/server/advancements/Advancement.java +++ b/src/main/java/net/minestom/server/advancements/Advancement.java @@ -45,36 +45,91 @@ public class Advancement { this(title, description, new ItemStack(icon, (byte) 1), frameType, x, y); } + /** + * Get the advancement tab linked to this advancement + * + * @return the {@link AdvancementTab} linked to this advancement + */ public AdvancementTab getTab() { return tab; } - public void setTab(AdvancementTab tab) { + protected void setTab(AdvancementTab tab) { this.tab = tab; } + /** + * Get the title of the advancement + * + * @return the advancement title + */ public ColoredText getTitle() { return title; } + /** + * Change the advancement title + * + * @param title the new title + */ public void setTitle(ColoredText title) { this.title = title; update(); } + /** + * Get the description of the advancement + * + * @return the description title + */ public ColoredText getDescription() { return description; } + /** + * Change the description title + * + * @param description the new description + */ public void setDescription(ColoredText description) { this.description = description; update(); } + /** + * Get the advancement icon + * + * @return the advancement icon + */ + public ItemStack getIcon() { + return icon; + } + + /** + * Change the advancement icon + * + * @param icon the new advancement icon + */ + public void setIcon(ItemStack icon) { + this.icon = icon; + update(); + } + + /** + * Get if this advancement has a toast + * + * @return true if the advancement has a toast + */ public boolean hasToast() { return toast; } + /** + * Make this argument a toast + * + * @param toast true to make this advancement a toast + * @return this advancement + */ public Advancement showToast(boolean toast) { this.toast = toast; return this; @@ -90,28 +145,58 @@ public class Advancement { return this; } + /** + * Get the advancement frame type + * + * @return this advancement frame type + */ public FrameType getFrameType() { return frameType; } + /** + * Change the advancement frame type + * + * @param frameType the new frame type + */ public void setFrameType(FrameType frameType) { this.frameType = frameType; update(); } + /** + * Get the X position of this advancement + * + * @return this advancement X + */ public float getX() { return x; } + /** + * Change this advancement X coordinate + * + * @param x the new X coordinate + */ public void setX(float x) { this.x = x; update(); } + /** + * Get the Y position of this advancement + * + * @return this advancement Y + */ public float getY() { return y; } + /** + * Change this advancement Y coordinate + * + * @param y the new Y coordinate + */ public void setY(float y) { this.y = y; update(); diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 6351b80be..56cd9f49f 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -716,8 +716,8 @@ public class Player extends LivingEntity implements CommandSender { PlayerListHeaderAndFooterPacket playerListHeaderAndFooterPacket = new PlayerListHeaderAndFooterPacket(); playerListHeaderAndFooterPacket.emptyHeader = header == null; playerListHeaderAndFooterPacket.emptyFooter = footer == null; - playerListHeaderAndFooterPacket.header = header.toString(); - playerListHeaderAndFooterPacket.footer = footer.toString(); + playerListHeaderAndFooterPacket.header = header; + playerListHeaderAndFooterPacket.footer = footer; playerConnection.sendPacket(playerListHeaderAndFooterPacket); } @@ -728,13 +728,13 @@ public class Player extends LivingEntity implements CommandSender { switch (action) { case SET_TITLE: - titlePacket.titleText = text.toString(); + titlePacket.titleText = text; break; case SET_SUBTITLE: - titlePacket.subtitleText = text.toString(); + titlePacket.subtitleText = text; break; case SET_ACTION_BAR: - titlePacket.actionBarText = text.toString(); + titlePacket.actionBarText = text; break; default: throw new UnsupportedOperationException("Invalid TitlePacket.Action type!"); @@ -1328,7 +1328,7 @@ public class Player extends LivingEntity implements CommandSender { */ public void kick(ColoredText text) { DisconnectPacket disconnectPacket = new DisconnectPacket(); - disconnectPacket.message = text.toString(); + disconnectPacket.message = text; playerConnection.sendPacket(disconnectPacket); playerConnection.disconnect(); playerConnection.refreshOnline(false); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java index 4eaffd5f8..30054dacb 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java @@ -1,16 +1,17 @@ package net.minestom.server.network.packet.server.play; +import net.minestom.server.chat.ColoredText; import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; public class DisconnectPacket implements ServerPacket { - public String message; + public ColoredText message; @Override public void write(PacketWriter writer) { - writer.writeSizedString(message); + writer.writeSizedString(message.toString()); } @Override diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java index b75ebe0ac..b916ab29d 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java @@ -1,5 +1,6 @@ package net.minestom.server.network.packet.server.play; +import net.minestom.server.chat.ColoredText; import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; @@ -11,8 +12,8 @@ public class PlayerListHeaderAndFooterPacket implements ServerPacket { public boolean emptyHeader; public boolean emptyFooter; - public String header; - public String footer; + public ColoredText header; + public ColoredText footer; @Override @@ -20,13 +21,13 @@ public class PlayerListHeaderAndFooterPacket implements ServerPacket { if (emptyHeader) { writer.writeSizedString(EMPTY_COMPONENT); } else { - writer.writeSizedString(header); + writer.writeSizedString(header.toString()); } if (emptyFooter) { writer.writeSizedString(EMPTY_COMPONENT); } else { - writer.writeSizedString(footer); + writer.writeSizedString(footer.toString()); } } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java index 41014cf9a..dfa41ef22 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java @@ -1,5 +1,6 @@ package net.minestom.server.network.packet.server.play; +import net.minestom.server.chat.ColoredText; import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; @@ -8,11 +9,11 @@ public class TitlePacket implements ServerPacket { public Action action; - public String titleText; + public ColoredText titleText; - public String subtitleText; + public ColoredText subtitleText; - public String actionBarText; + public ColoredText actionBarText; public int fadeIn; public int stay; @@ -24,13 +25,13 @@ public class TitlePacket implements ServerPacket { switch (action) { case SET_TITLE: - writer.writeSizedString(titleText); + writer.writeSizedString(titleText.toString()); break; case SET_SUBTITLE: - writer.writeSizedString(subtitleText); + writer.writeSizedString(subtitleText.toString()); break; case SET_ACTION_BAR: - writer.writeSizedString(actionBarText); + writer.writeSizedString(actionBarText.toString()); break; case SET_TIMES_AND_DISPLAY: writer.writeInt(fadeIn);