+ * This value has no effect on players, they will always use their real + * name. + * + * @return the custom name, or null if none is set + */ + @Nullable + public BaseComponent getCustomName(); + + /** + * Sets the custom name of this object. This name will be used in death + * messages and can be sent to the client as a nameplate over the mob. + * Setting the name to null will clear it. + *
+ * This value has no effect on players, they will always use their real + * name. + * + * @param name the name to set + */ + public void setCustomName(@Nullable BaseComponent name); + } } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index b5740535..62b76e9d 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -14,6 +14,7 @@ import java.util.Set; import java.util.UUID; import java.util.function.Consumer; import java.util.logging.Logger; +import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.Warning.WarningState; import org.bukkit.advancement.Advancement; import org.bukkit.block.data.BlockData; @@ -356,6 +357,7 @@ public interface Server extends PluginMessageRecipient { * * @param message the message * @return the number of players + * @see Components#broadcast(BaseComponent) */ public int broadcastMessage(@NotNull String message); @@ -1053,6 +1055,7 @@ public interface Server extends PluginMessageRecipient { * @param permission the required permission {@link Permissible * permissibles} must have to receive the broadcast * @return number of message recipients + * @see Components#broadcast(BaseComponent, String) */ public int broadcast(@NotNull String message, @NotNull String permission); @@ -1294,6 +1297,7 @@ public interface Server extends PluginMessageRecipient { * viewed. * * @see InventoryType#isCreatable() + * @see Components#createInventory(InventoryHolder, InventoryType, BaseComponent) */ @NotNull Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title); @@ -1320,6 +1324,7 @@ public interface Server extends PluginMessageRecipient { * viewed * @return a new inventory * @throws IllegalArgumentException if the size is not a multiple of 9 + * @see Components#createInventory(InventoryHolder, int, BaseComponent) */ @NotNull Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull String title) throws IllegalArgumentException; @@ -1330,6 +1335,7 @@ public interface Server extends PluginMessageRecipient { * @param title the title of the corresponding merchant inventory, displayed * when the merchant inventory is viewed * @return a new merchant + * @see Components#createMerchant(BaseComponent) */ @NotNull Merchant createMerchant(@Nullable String title); @@ -1586,6 +1592,7 @@ public interface Server extends PluginMessageRecipient { * @param style the style of the boss bar * @param flags an optional list of flags to set on the boss bar * @return the created boss bar + * @see Components#createBossBar(BaseComponent, BarColor, BarStyle, BarFlag...) */ @NotNull BossBar createBossBar(@Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags); @@ -1603,6 +1610,7 @@ public interface Server extends PluginMessageRecipient { * @param style the style of the boss bar * @param flags an optional list of flags to set on the boss bar * @return the created boss bar + * @see Components#createBossBar(NamespacedKey, BaseComponent, BarColor, BarStyle, BarFlag...) */ @NotNull KeyedBossBar createBossBar(@NotNull NamespacedKey key, @Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags); @@ -1834,4 +1842,123 @@ public interface Server extends PluginMessageRecipient { @Deprecated @NotNull UnsafeValues getUnsafe(); + + /** + * Access to API revolving around {@link BaseComponent BaseComponents}. + * + * @return component API access + */ + @NotNull + Components components(); + + /** + * Access to API revolving around {@link BaseComponent BaseComponents}. + * + * @see Server#components() + * @see Bukkit#components() + */ + interface Components { + + /** + * Sends the given chat component message to all players on the server. + *
+ * This is the same as calling {@link #broadcast(BaseComponent, String)}
+ * to {@link #BROADCAST_CHANNEL_USERS}.
+ *
+ * @param message the message to broadcast
+ * @return number of message recipients
+ */
+ int broadcast(@NotNull BaseComponent message);
+
+ /**
+ * Broadcasts the given chat component message to all permissible objects
+ * on the server that have the given permission.
+ *
+ * @param message message to broadcast
+ * @param permission the required permission {@link Permissible permissibles}
+ * must have to receive the broadcast
+ * @return number of message recipients
+ */
+ int broadcast(@NotNull BaseComponent message, @NotNull String permission);
+
+ /**
+ * Creates an empty inventory with the specified type and title. If the type
+ * is {@link InventoryType#CHEST}, the new inventory has a size of 27;
+ * otherwise the new inventory has the normal size for its type.
+ * It should be noted that some inventory types do not support titles and
+ * may not render with said titles on the Minecraft client.
+ *
+ * {@link InventoryType#WORKBENCH} will not process crafting recipes if
+ * created with this method. Use
+ * {@link Player#openWorkbench(Location, boolean)} instead.
+ *
+ * {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s
+ * for possible enchanting results. Use
+ * {@link Player#openEnchanting(Location, boolean)} instead.
+ *
+ * @param owner the holder of the inventory, or null to indicate no holder
+ * @param type the type of inventory to create
+ * @param title the title of the inventory, to be displayed when it is viewed
+ * @return the new inventory
+ * @throws IllegalArgumentException if the {@link InventoryType} cannot be
+ * viewed
+ *
+ * @see InventoryType#isCreatable()
+ */
+ @NotNull
+ Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull BaseComponent title);
+
+ /**
+ * Creates an empty inventory of type {@link InventoryType#CHEST} with the
+ * specified size and title.
+ *
+ * @param owner the holder of the inventory, or null to indicate no holder
+ * @param size a multiple of 9 as the size of inventory to create
+ * @param title the title of the inventory, to be displayed when it is viewed
+ * @return a new inventory
+ * @throws IllegalArgumentException if the size is not a multiple of 9
+ */
+ @NotNull
+ Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull BaseComponent title);
+
+ /**
+ * Creates an empty merchant.
+ *
+ * @param title the title of the corresponding merchant inventory, displayed
+ * when the merchant inventory is viewed
+ * @return a new merchant
+ */
+ @NotNull
+ Merchant createMerchant(@Nullable BaseComponent title);
+
+ /**
+ * Creates a boss bar instance to display to players. The progress
+ * defaults to 1.0
+ *
+ * @param title the title of the boss bar
+ * @param color the color of the boss bar
+ * @param style the style of the boss bar
+ * @param flags an optional list of flags to set on the boss bar
+ * @return the created boss bar
+ */
+ @NotNull
+ BossBar createBossBar(@Nullable BaseComponent title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags);
+
+ /**
+ * Creates a boss bar instance to display to players. The progress defaults
+ * to 1.0.
+ *
+ * This instance is added to the persistent storage of the server and will
+ * be editable by commands and restored after restart.
+ *
+ * @param key the key of the boss bar that is used to access the boss bar
+ * @param title the title of the boss bar
+ * @param color the color of the boss bar
+ * @param style the style of the boss bar
+ * @param flags an optional list of flags to set on the boss bar
+ * @return the created boss bar
+ */
+ @NotNull
+ KeyedBossBar createBossBar(@NotNull NamespacedKey key, @Nullable BaseComponent title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags);
+ }
}
diff --git a/src/main/java/org/bukkit/Translatable.java b/src/main/java/org/bukkit/Translatable.java
index e3faa2c6..3387d956 100644
--- a/src/main/java/org/bukkit/Translatable.java
+++ b/src/main/java/org/bukkit/Translatable.java
@@ -1,18 +1,10 @@
package org.bukkit;
-import org.jetbrains.annotations.NotNull;
+import net.md_5.bungee.api.chat.TranslationProvider;
/**
* Represents an object with a text representation that can be translated by the
* Minecraft client.
*/
-public interface Translatable {
-
- /**
- * Get the translation key, suitable for use in a translation component.
- *
- * @return the translation key
- */
- @NotNull
- String getTranslationKey();
+public interface Translatable extends TranslationProvider {
}
diff --git a/src/main/java/org/bukkit/advancement/AdvancementDisplay.java b/src/main/java/org/bukkit/advancement/AdvancementDisplay.java
index 0ff86a39..f2f15bf4 100644
--- a/src/main/java/org/bukkit/advancement/AdvancementDisplay.java
+++ b/src/main/java/org/bukkit/advancement/AdvancementDisplay.java
@@ -1,5 +1,6 @@
package org.bukkit.advancement;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -12,6 +13,7 @@ public interface AdvancementDisplay {
* Gets the title of the advancement.
*
* @return The advancement title without colour codes.
+ * @see Components#getTitle()
*/
@NotNull
String getTitle();
@@ -20,6 +22,7 @@ public interface AdvancementDisplay {
* Gets the visible description of the advancement.
*
* @return The advancement description without colour codes.
+ * @see Components#getDescription()
*/
@NotNull
String getDescription();
@@ -79,4 +82,37 @@ public interface AdvancementDisplay {
*/
@NotNull
AdvancementDisplayType getType();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @return component API access
+ */
+ @NotNull
+ Components components();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @see AdvancementDisplay#components()
+ */
+ interface Components {
+
+ /**
+ * Gets the title of the advancement.
+ *
+ * @return the advancement title
+ */
+ @NotNull
+ public BaseComponent getTitle();
+
+ /**
+ * Gets the visible description of the advancement.
+ *
+ * @return the advancement description
+ */
+ @NotNull
+ public BaseComponent getDescription();
+
+ }
}
diff --git a/src/main/java/org/bukkit/block/CommandBlock.java b/src/main/java/org/bukkit/block/CommandBlock.java
index 372c0bd5..7fb113f5 100644
--- a/src/main/java/org/bukkit/block/CommandBlock.java
+++ b/src/main/java/org/bukkit/block/CommandBlock.java
@@ -1,5 +1,6 @@
package org.bukkit.block;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,6 +34,7 @@ public interface CommandBlock extends TileState {
* by default is "@".
*
* @return Name of this CommandBlock.
+ * @see Components#getName()
*/
@NotNull
public String getName();
@@ -43,6 +45,42 @@ public interface CommandBlock extends TileState {
* same as setting it to "@".
*
* @param name New name for this CommandBlock.
+ * @see Components#setName(BaseComponent)
*/
public void setName(@Nullable String name);
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @return component API access
+ */
+ @NotNull
+ public Components components();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @see CommandBlock#components()
+ */
+ public interface Components {
+
+ /**
+ * Gets the name of this command block. The name is used with commands
+ * that this command block executes. This name will never be null, and
+ * by default is "@".
+ *
+ * @return the name of this command block.
+ */
+ @NotNull
+ public BaseComponent getName();
+
+ /**
+ * Sets the name of this command block. The name is used with commands
+ * that this command block executes. Setting the name to null is the
+ * same as setting it to "@".
+ *
+ * @param name new name for this command block.
+ */
+ public void setName(@Nullable BaseComponent name);
+ }
}
diff --git a/src/main/java/org/bukkit/block/sign/SignSide.java b/src/main/java/org/bukkit/block/sign/SignSide.java
index 0f4ae7bd..cb6345b3 100644
--- a/src/main/java/org/bukkit/block/sign/SignSide.java
+++ b/src/main/java/org/bukkit/block/sign/SignSide.java
@@ -1,5 +1,6 @@
package org.bukkit.block.sign;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.material.Colorable;
import org.jetbrains.annotations.NotNull;
@@ -12,6 +13,7 @@ public interface SignSide extends Colorable {
* Gets all the lines of text currently on this side of the sign.
*
* @return Array of Strings containing each line of text
+ * @see Components#getLines()
*/
@NotNull
public String[] getLines();
@@ -24,6 +26,7 @@ public interface SignSide extends Colorable {
* @param index Line number to get the text from, starting at 0
* @return Text on the given line
* @throws IndexOutOfBoundsException Thrown when the line does not exist
+ * @see Components#getLine(int)
*/
@NotNull
public String getLine(int index) throws IndexOutOfBoundsException;
@@ -37,6 +40,7 @@ public interface SignSide extends Colorable {
* @param index Line number to set the text at, starting from 0
* @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3
+ * @see Components#setLine(int, BaseComponent)
*/
public void setLine(int index, @NotNull String line) throws IndexOutOfBoundsException;
@@ -53,4 +57,51 @@ public interface SignSide extends Colorable {
* @param glowing if this side of the sign has glowing text
*/
public void setGlowingText(boolean glowing);
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @return component API access
+ */
+ @NotNull
+ public Components components();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @see SignSide#components()
+ */
+ public interface Components {
+
+ /**
+ * Gets all the lines of text currently on this side of the sign.
+ *
+ * @return array of {@link BaseComponent BaseComponents} containing each
+ * line of text
+ */
+ @NotNull
+ public BaseComponent[] getLines();
+
+ /**
+ * Gets the line of text at the specified index on this side of the sign.
+ * For example, {@code getLine(0)} will return the first line of text.
+ *
+ * @param index line number to get the text from, starting at 0
+ * @return text on the given line
+ * @throws IndexOutOfBoundsException thrown when the line does not exist
+ */
+ @NotNull
+ public BaseComponent getLine(int index);
+
+ /**
+ * Sets the line of text at the specified index. For example, {@code
+ * setLine(0, new TextComponent("Line One"))} will set the first line of
+ * text to "Line One".
+ *
+ * @param index line number to set the text at, starting from 0
+ * @param line new text to set at the specified index
+ * @throws IndexOutOfBoundsException if the index is out of the range 0..3
+ */
+ public void setLine(int index, @NotNull BaseComponent line);
+ }
}
diff --git a/src/main/java/org/bukkit/boss/BossBar.java b/src/main/java/org/bukkit/boss/BossBar.java
index 70274f2e..74aa4f30 100644
--- a/src/main/java/org/bukkit/boss/BossBar.java
+++ b/src/main/java/org/bukkit/boss/BossBar.java
@@ -1,6 +1,7 @@
package org.bukkit.boss;
import java.util.List;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -11,6 +12,7 @@ public interface BossBar {
* Returns the title of this boss bar
*
* @return the title of the bar
+ * @see Components#getTitle()
*/
@NotNull
String getTitle();
@@ -19,6 +21,7 @@ public interface BossBar {
* Sets the title of this boss bar
*
* @param title the title of the bar
+ * @see Components#setTitle(BaseComponent)
*/
void setTitle(@Nullable String title);
@@ -146,4 +149,35 @@ public interface BossBar {
*/
@Deprecated
void hide();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @return component API access
+ */
+ @NotNull
+ Components components();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @see BossBar#components()
+ */
+ interface Components {
+
+ /**
+ * Gets the title of this boss bar.
+ *
+ * @return the title of the bar
+ */
+ @NotNull
+ public BaseComponent getTitle();
+
+ /**
+ * Sets the title of this boss bar.
+ *
+ * @param title the new title of the bar
+ */
+ public void setTitle(@Nullable BaseComponent title);
+ }
}
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
index a7a2587b..f321ef9f 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -1,6 +1,7 @@
package org.bukkit.command;
import java.util.UUID;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Server;
import org.bukkit.permissions.Permissible;
import org.jetbrains.annotations.NotNull;
@@ -12,6 +13,7 @@ public interface CommandSender extends Permissible {
* Sends this sender a message
*
* @param message Message to be displayed
+ * @see Components#sendMessage(BaseComponent)
*/
public void sendMessage(@NotNull String message);
@@ -19,6 +21,7 @@ public interface CommandSender extends Permissible {
* Sends this sender multiple messages
*
* @param messages An array of messages to be displayed
+ * @see Components#sendMessage(BaseComponent)
*/
public void sendMessage(@NotNull String... messages);
@@ -27,6 +30,7 @@ public interface CommandSender extends Permissible {
*
* @param message Message to be displayed
* @param sender The sender of this message
+ * @see Components#sendMessage(UUID, BaseComponent)
*/
public void sendMessage(@Nullable UUID sender, @NotNull String message);
@@ -35,6 +39,7 @@ public interface CommandSender extends Permissible {
*
* @param messages An array of messages to be displayed
* @param sender The sender of this message
+ * @see Components#sendMessage(UUID, BaseComponent)
*/
public void sendMessage(@Nullable UUID sender, @NotNull String... messages);
@@ -53,4 +58,35 @@ public interface CommandSender extends Permissible {
*/
@NotNull
public String getName();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @return component API access
+ */
+ @NotNull
+ public Components components();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @see CommandSender#components()
+ */
+ public interface Components {
+
+ /**
+ * Sends this sender a chat component message.
+ *
+ * @param message the message to send
+ */
+ public void sendMessage(@NotNull BaseComponent message);
+
+ /**
+ * Sends this sender a chat component message.
+ *
+ * @param component the message to send
+ * @param sender the sender of the message
+ */
+ public void sendMessage(@Nullable UUID sender, @NotNull BaseComponent component);
+ }
}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index 80fb27d6..5774b110 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -3,6 +3,7 @@ package org.bukkit.enchantments;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -242,6 +243,8 @@ public abstract class Enchantment implements Keyed, Translatable {
* Gets the unique name of this enchantment
*
* @return Unique name
+ * @see Components#getName()
+ * @see Components#getName(int)
* @deprecated enchantments are badly named, use {@link #getKey()}.
*/
@NotNull
@@ -317,6 +320,46 @@ public abstract class Enchantment implements Keyed, Translatable {
*/
public abstract boolean canEnchantItem(@NotNull ItemStack item);
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @return component API access
+ */
+ @NotNull
+ public abstract Components components();
+
+ /**
+ * Access to API revolving around {@link BaseComponent BaseComponents}.
+ *
+ * @see Enchantment#components()
+ */
+ public interface Components {
+
+ /**
+ * Get this Enchantment's name as a {@link BaseComponent}.
+ *
+ * @return the display name
+ */
+ @NotNull
+ public BaseComponent getName();
+
+ /**
+ * Get the full display name of this Enchantment with the given level.
+ *
+ * The display name will be colored as though it was displayed on an item (i.e. curses being red + * and regular enchantments being gray). Additionally, if {@code level} is less than + * {@link Enchantment#getStartLevel()} or greater than {@link Enchantment#getMaxLevel()}, the level + * may not show as expected unless a resource pack is installed on the client which supports values + * beyond vanilla's built-in levels. These are implementation details and cannot be guaranteed from + * version to version. + * + * @param level the level + * @return the display name with the level + */ + @NotNull + public BaseComponent getName(int level); + } + /** * Gets the Enchantment at the specified key * diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java index dee99ac2..da1a6c4e 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -3,6 +3,7 @@ package org.bukkit.entity; import java.util.List; import java.util.Set; import java.util.UUID; +import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Nameable; @@ -766,4 +767,20 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent @NotNull @ApiStatus.Experimental Entity copy(@NotNull Location to); + + /** + * Access to API revolving around {@link BaseComponent BaseComponents}. + * + * @return component API access + */ + @NotNull + public Components components(); + + /** + * Access to API revolving around {@link BaseComponent BaseComponents}. + * + * @see Entity#components() + */ + public interface Components extends CommandSender.Components, Nameable.Components { + } } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index c91e6406..eb45cb79 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -9,6 +9,8 @@ import java.util.Date; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.BanEntry; import org.bukkit.DyeColor; import org.bukkit.Effect; @@ -93,6 +95,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Gets the name that is shown on the player list. * * @return the player list name + * @see Components#getPlayerListName() */ @NotNull public String getPlayerListName(); @@ -103,6 +106,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * If the value is null, the name will be identical to {@link #getName()}. * * @param name new player list name + * @see Components#setPlayerListName(BaseComponent) */ public void setPlayerListName(@Nullable String name); @@ -110,6 +114,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Gets the currently displayed player list header for this player. * * @return player list header or null + * @see Components#getPlayerListHeader() */ @Nullable public String getPlayerListHeader(); @@ -118,6 +123,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Gets the currently displayed player list footer for this player. * * @return player list header or null + * @see Components#getPlayerListFooter() */ @Nullable public String getPlayerListFooter(); @@ -126,6 +132,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Sets the currently displayed player list header for this player. * * @param header player list header, null for empty + * @see Components#setPlayerListHeader(BaseComponent) */ public void setPlayerListHeader(@Nullable String header); @@ -133,6 +140,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Sets the currently displayed player list footer for this player. * * @param footer player list footer, null for empty + * @see Components#setPlayerListFooter(BaseComponent) */ public void setPlayerListFooter(@Nullable String footer); @@ -142,6 +150,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param header player list header, null for empty * @param footer player list footer, null for empty + * @see Components#setPlayerListHeaderFooter(BaseComponent, BaseComponent) */ public void setPlayerListHeaderFooter(@Nullable String header, @Nullable String footer); @@ -219,6 +228,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Kicks player with custom kick message. * * @param message kick message + * @see Components#kickPlayer(BaseComponent) */ public void kickPlayer(@Nullable String message); @@ -901,6 +911,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param lines the new text on the sign or null to clear it * @throws IllegalArgumentException if location is null * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + * @see Components#sendSignChange(Location, BaseComponent[]) */ public void sendSignChange(@NotNull Location loc, @Nullable String[] lines) throws IllegalArgumentException; @@ -923,6 +934,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if location is null * @throws IllegalArgumentException if dyeColor is null * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + * @see Components#sendSignChange(Location, BaseComponent[], DyeColor) */ public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException; @@ -946,6 +958,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if location is null * @throws IllegalArgumentException if dyeColor is null * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + * @see Components#sendSignChange(Location, BaseComponent[], DyeColor, boolean) */ public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException; @@ -1543,6 +1556,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * length restriction is an implementation specific arbitrary value. * @throws IllegalArgumentException Thrown if the hash is not 20 bytes * long. + * @see Components#setResourcePack(String, byte[], BaseComponent) */ public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt); @@ -1632,6 +1646,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * length restriction is an implementation specific arbitrary value. * @throws IllegalArgumentException Thrown if the hash is not 20 bytes * long. + * @see Components#setResourcePack(String, byte[], BaseComponent, boolean) */ public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force); @@ -1678,6 +1693,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * length restriction is an implementation specific arbitrary value. * @throws IllegalArgumentException Thrown if the hash is not 20 bytes * long. + * @see Components#setResourcePack(UUID, String, byte[], BaseComponent, boolean) */ public void setResourcePack(@NotNull UUID id, @NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force); @@ -1724,6 +1740,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * length restriction is an implementation specific arbitrary value. * @throws IllegalArgumentException Thrown if the hash is not 20 bytes * long. + * @see Components#addResourcePack(UUID, String, byte[], BaseComponent, boolean) */ public void addResourcePack(@NotNull UUID id, @NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force); @@ -1876,6 +1893,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param title Title text * @param subtitle Subtitle text + * @see Components#sendTitle(BaseComponent, BaseComponent, int, int, int) * @deprecated API behavior subject to change */ @Deprecated @@ -1895,6 +1913,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param fadeIn time in ticks for titles to fade in. Defaults to 10. * @param stay time in ticks for titles to stay. Defaults to 70. * @param fadeOut time in ticks for titles to fade out. Defaults to 20. + * @see Components#sendTitle(BaseComponent, BaseComponent, int, int, int) */ public void sendTitle(@Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut); @@ -2247,4 +2266,342 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @return whether the player allows server listings */ public boolean isAllowingServerListings(); + + @NotNull + @Override + Components components(); + + /** + * Access to API revolving around {@link BaseComponent BaseComponents}. + * + * @see Player#components() + */ + public interface Components extends Entity.Components { + + /** + * Gets the name that is shown on the player list. + * + * @return the player list name + */ + @NotNull + public BaseComponent getPlayerListName(); + + /** + * Sets the name that is shown on the in-game player list. + *
+ * If the value is null, the name will be identical to {@link #getName()}. + * + * @param name new player list name + */ + public void setPlayerListName(@Nullable BaseComponent name); + + /** + * Gets the currently displayed player list header for this player. + * + * @return player list header or null + */ + @Nullable + public BaseComponent getPlayerListHeader(); + + /** + * Gets the currently displayed player list footer for this player. + * + * @return player list header or null + */ + @Nullable + public BaseComponent getPlayerListFooter(); + + /** + * Sets the currently displayed player list header for this player. + * + * @param header player list header, null for empty + */ + public void setPlayerListHeader(@Nullable BaseComponent header); + + /** + * Sets the currently displayed player list footer for this player. + * + * @param footer player list footer, null for empty + */ + public void setPlayerListFooter(@Nullable BaseComponent footer); + + /** + * Sets the currently displayed player list header and footer for this + * player. + * + * @param header player list header, null for empty + * @param footer player list footer, null for empty + */ + public void setPlayerListHeaderFooter(@Nullable BaseComponent header, @Nullable BaseComponent footer); + + /** + * Kicks player with custom kick message. + * + * @param message kick message + */ + public void kickPlayer(@Nullable BaseComponent message); + + /** + * Send a sign change. This fakes a sign change packet for a user at + * a certain location. This will not actually change the world in any way. + * This method will use a sign at the location's block or a faked sign + * sent via + * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}. + *
+ * If the client does not have a sign at the given location it will + * display an error message to the user. + * + * @param loc the location of the sign + * @param lines the new text on the sign or null to clear it + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ + public void sendSignChange(@NotNull Location loc, @Nullable BaseComponent[] lines); + + /** + * Send a sign change. This fakes a sign change packet for a user at + * a certain location. This will not actually change the world in any way. + * This method will use a sign at the location's block or a faked sign + * sent via + * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}. + *
+ * If the client does not have a sign at the given location it will + * display an error message to the user. + * + * @param loc the location of the sign + * @param lines the new text on the sign or null to clear it + * @param dyeColor the color of the sign + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ + public void sendSignChange(@NotNull Location loc, @Nullable BaseComponent[] lines, @NotNull DyeColor dyeColor); + + /** + * Send a sign change. This fakes a sign change packet for a user at + * a certain location. This will not actually change the world in any way. + * This method will use a sign at the location's block or a faked sign + * sent via + * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}. + *
+ * If the client does not have a sign at the given location it will + * display an error message to the user. + * + * @param loc the location of the sign + * @param lines the new text on the sign or null to clear it + * @param dyeColor the color of the sign + * @param hasGlowingText if the sign's text should be glowing + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ + public void sendSignChange(@NotNull Location loc, @Nullable BaseComponent[] lines, @NotNull DyeColor dyeColor, boolean hasGlowingText); + + /** + * Request that the player's client download and switch resource packs. + *
+ * The player's client will download the new resource pack asynchronously + * in the background, and will automatically switch to it once the + * download is complete. If the client has downloaded and cached a + * resource pack with the same hash in the past it will not download but + * directly apply the cached pack. If the hash is null and the client has + * downloaded and cached the same resource pack in the past, it will + * perform a file size check against the response content to determine if + * the resource pack has changed and needs to be downloaded again. When + * this request is sent for the very first time from a given server, the + * client will first display a confirmation GUI to the player before + * proceeding with the download. + *
+ * Notes: + *
+ * The player's client will download the new resource pack asynchronously + * in the background, and will automatically switch to it once the + * download is complete. If the client has downloaded and cached a + * resource pack with the same hash in the past it will not download but + * directly apply the cached pack. If the hash is null and the client has + * downloaded and cached the same resource pack in the past, it will + * perform a file size check against the response content to determine if + * the resource pack has changed and needs to be downloaded again. When + * this request is sent for the very first time from a given server, the + * client will first display a confirmation GUI to the player before + * proceeding with the download. + *
+ * Notes: + *
+ * The player's client will download the new resource pack asynchronously + * in the background, and will automatically switch to it once the + * download is complete. If the client has downloaded and cached a + * resource pack with the same hash in the past it will not download but + * directly apply the cached pack. If the hash is null and the client has + * downloaded and cached the same resource pack in the past, it will + * perform a file size check against the response content to determine if + * the resource pack has changed and needs to be downloaded again. When + * this request is sent for the very first time from a given server, the + * client will first display a confirmation GUI to the player before + * proceeding with the download. + *
+ * Notes: + *
+ * The player's client will download the new resource pack asynchronously + * in the background, and will automatically add to it once the + * download is complete. If the client has downloaded and cached a + * resource pack with the same hash in the past it will not download but + * directly apply the cached pack. If the hash is null and the client has + * downloaded and cached the same resource pack in the past, it will + * perform a file size check against the response content to determine if + * the resource pack has changed and needs to be downloaded again. When + * this request is sent for the very first time from a given server, the + * client will first display a confirmation GUI to the player before + * proceeding with the download. + *
+ * Notes: + *
+ * Note if the inventory does not support titles that can be changed (i.e. it
+ * is not creatable or viewed by a player), then this method will throw an
+ * exception.
+ *t
+ * @param title the new title to set
+ */
+ public void setTitle(@NotNull BaseComponent title);
+ }
+
}
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 9fb9f00f..1ed0e186 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
@@ -44,6 +45,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* before calling this method.
*
* @return the display name that is set
+ * @see Components#getDisplayName()
*/
@NotNull
String getDisplayName();
@@ -52,6 +54,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* Sets the display name.
*
* @param name the name to set
+ * @see Components#setDisplayName(BaseComponent)
*/
void setDisplayName(@Nullable String name);
@@ -75,6 +78,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* calling this method.
*
* @return the item name that is set
+ * @see Components#getItemName()
*/
@NotNull
String getItemName();
@@ -86,6 +90,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* anvil, is not styled with italics, and does not show labels.
*
* @param name the name to set
+ * @see Components#setItemName(BaseComponent)
*/
void setItemName(@Nullable String name);
@@ -134,6 +139,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* calling this method.
*
* @return a list of lore that is set
+ * @see Components#getLore()
*/
@Nullable
List
+ * Plugins should check that hasItemName() returns
+ * Plugins should check if hasLore() returns
+ * The data can be up to 256 characters in length, additional characters
+ * are truncated.
+ *
+ * @param page the page number to set
+ * @param text the component text to set for that page
+ */
+ public void setPage(int page, @Nullable BaseComponent text);
+
+ /**
+ * Gets all the pages in the book.
+ *
+ * @return list of all the pages in the book
+ */
+ @NotNull
+ public List
+ * Item name differs from display name in that it is cannot be edited by an
+ * anvil, is not styled with italics, and does not show labels.
+ * true
before
+ * calling this method.
+ *
+ * @return the item name that is set
+ */
+ @NotNull
+ BaseComponent getItemName();
+
+ /**
+ * Sets the item name.
+ *
+ * Item name differs from display name in that it is cannot be edited by an
+ * anvil, is not styled with italics, and does not show labels.
+ *
+ * @param name the name to set
+ */
+ void setItemName(@Nullable BaseComponent name);
+
+ /**
+ * Gets the lore that is set as a list of components where each entry
+ * in the list is a line of lore.
+ * true
before
+ * calling this method.
+ *
+ * @return the lore, or null if no lore is set
+ */
+ @Nullable
+ List