mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-04-13 09:41:09 +00:00
SPIGOT-7327, SPIGOT-7289, SPIGOT-6818, SPIGOT-6223, SPIGOT-6089, SPIGOT-6046, SPIGOT-5954, SPIGOT-5705: Complete the BungeeChat API
This commit is contained in:
parent
1fc1020ad0
commit
b40e111449
22 changed files with 1281 additions and 38 deletions
6
pom.xml
6
pom.xml
|
@ -57,6 +57,12 @@
|
|||
<version>2.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.20-R0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- not part of the API proper -->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
|
|
@ -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;
|
||||
|
@ -2142,6 +2143,16 @@ public final class Bukkit {
|
|||
return server.getRegistry(tClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @return component API access
|
||||
*/
|
||||
@NotNull
|
||||
public static Server.Components components() {
|
||||
return server.components();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unsafe values instance
|
||||
* @see UnsafeValues
|
||||
|
|
|
@ -15,91 +15,91 @@ public enum ChatColor {
|
|||
/**
|
||||
* Represents black
|
||||
*/
|
||||
BLACK('0', 0x00),
|
||||
BLACK('0', 0x00, net.md_5.bungee.api.ChatColor.BLACK),
|
||||
/**
|
||||
* Represents dark blue
|
||||
*/
|
||||
DARK_BLUE('1', 0x1),
|
||||
DARK_BLUE('1', 0x1, net.md_5.bungee.api.ChatColor.DARK_BLUE),
|
||||
/**
|
||||
* Represents dark green
|
||||
*/
|
||||
DARK_GREEN('2', 0x2),
|
||||
DARK_GREEN('2', 0x2, net.md_5.bungee.api.ChatColor.DARK_GREEN),
|
||||
/**
|
||||
* Represents dark blue (aqua)
|
||||
*/
|
||||
DARK_AQUA('3', 0x3),
|
||||
DARK_AQUA('3', 0x3, net.md_5.bungee.api.ChatColor.DARK_AQUA),
|
||||
/**
|
||||
* Represents dark red
|
||||
*/
|
||||
DARK_RED('4', 0x4),
|
||||
DARK_RED('4', 0x4, net.md_5.bungee.api.ChatColor.DARK_RED),
|
||||
/**
|
||||
* Represents dark purple
|
||||
*/
|
||||
DARK_PURPLE('5', 0x5),
|
||||
DARK_PURPLE('5', 0x5, net.md_5.bungee.api.ChatColor.DARK_PURPLE),
|
||||
/**
|
||||
* Represents gold
|
||||
*/
|
||||
GOLD('6', 0x6),
|
||||
GOLD('6', 0x6, net.md_5.bungee.api.ChatColor.GOLD),
|
||||
/**
|
||||
* Represents gray
|
||||
*/
|
||||
GRAY('7', 0x7),
|
||||
GRAY('7', 0x7, net.md_5.bungee.api.ChatColor.GRAY),
|
||||
/**
|
||||
* Represents dark gray
|
||||
*/
|
||||
DARK_GRAY('8', 0x8),
|
||||
DARK_GRAY('8', 0x8, net.md_5.bungee.api.ChatColor.DARK_GRAY),
|
||||
/**
|
||||
* Represents blue
|
||||
*/
|
||||
BLUE('9', 0x9),
|
||||
BLUE('9', 0x9, net.md_5.bungee.api.ChatColor.BLUE),
|
||||
/**
|
||||
* Represents green
|
||||
*/
|
||||
GREEN('a', 0xA),
|
||||
GREEN('a', 0xA, net.md_5.bungee.api.ChatColor.GREEN),
|
||||
/**
|
||||
* Represents aqua
|
||||
*/
|
||||
AQUA('b', 0xB),
|
||||
AQUA('b', 0xB, net.md_5.bungee.api.ChatColor.AQUA),
|
||||
/**
|
||||
* Represents red
|
||||
*/
|
||||
RED('c', 0xC),
|
||||
RED('c', 0xC, net.md_5.bungee.api.ChatColor.RED),
|
||||
/**
|
||||
* Represents light purple
|
||||
*/
|
||||
LIGHT_PURPLE('d', 0xD),
|
||||
LIGHT_PURPLE('d', 0xD, net.md_5.bungee.api.ChatColor.LIGHT_PURPLE),
|
||||
/**
|
||||
* Represents yellow
|
||||
*/
|
||||
YELLOW('e', 0xE),
|
||||
YELLOW('e', 0xE, net.md_5.bungee.api.ChatColor.YELLOW),
|
||||
/**
|
||||
* Represents white
|
||||
*/
|
||||
WHITE('f', 0xF),
|
||||
WHITE('f', 0xF, net.md_5.bungee.api.ChatColor.WHITE),
|
||||
/**
|
||||
* Represents magical characters that change around randomly
|
||||
*/
|
||||
MAGIC('k', 0x10, true),
|
||||
MAGIC('k', 0x10, true, net.md_5.bungee.api.ChatColor.MAGIC),
|
||||
/**
|
||||
* Makes the text bold.
|
||||
*/
|
||||
BOLD('l', 0x11, true),
|
||||
BOLD('l', 0x11, true, net.md_5.bungee.api.ChatColor.BOLD),
|
||||
/**
|
||||
* Makes a line appear through the text.
|
||||
*/
|
||||
STRIKETHROUGH('m', 0x12, true),
|
||||
STRIKETHROUGH('m', 0x12, true, net.md_5.bungee.api.ChatColor.STRIKETHROUGH),
|
||||
/**
|
||||
* Makes the text appear underlined.
|
||||
*/
|
||||
UNDERLINE('n', 0x13, true),
|
||||
UNDERLINE('n', 0x13, true, net.md_5.bungee.api.ChatColor.UNDERLINE),
|
||||
/**
|
||||
* Makes the text italic.
|
||||
*/
|
||||
ITALIC('o', 0x14, true),
|
||||
ITALIC('o', 0x14, true, net.md_5.bungee.api.ChatColor.ITALIC),
|
||||
/**
|
||||
* Resets all previous chat colors or formats.
|
||||
*/
|
||||
RESET('r', 0x15);
|
||||
RESET('r', 0x15, net.md_5.bungee.api.ChatColor.RESET);
|
||||
|
||||
/**
|
||||
* The special character which prefixes all chat colour codes. Use this if
|
||||
|
@ -110,20 +110,32 @@ public enum ChatColor {
|
|||
|
||||
private final int intCode;
|
||||
private final char code;
|
||||
private final net.md_5.bungee.api.ChatColor bungee;
|
||||
private final boolean isFormat;
|
||||
private final String toString;
|
||||
private static final Map<Integer, ChatColor> BY_ID = Maps.newHashMap();
|
||||
private static final Map<Character, ChatColor> BY_CHAR = Maps.newHashMap();
|
||||
|
||||
private ChatColor(char code, int intCode) {
|
||||
this(code, intCode, false);
|
||||
private ChatColor(char code, int intCode, net.md_5.bungee.api.ChatColor bungee) {
|
||||
this(code, intCode, false, bungee);
|
||||
}
|
||||
|
||||
private ChatColor(char code, int intCode, boolean isFormat) {
|
||||
private ChatColor(char code, int intCode, boolean isFormat, net.md_5.bungee.api.ChatColor bungee) {
|
||||
this.code = code;
|
||||
this.intCode = intCode;
|
||||
this.isFormat = isFormat;
|
||||
this.toString = new String(new char[] {COLOR_CHAR, code});
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this ChatColor as its Bungee equivalent.
|
||||
*
|
||||
* @return the Bungee equivalent chat color
|
||||
*/
|
||||
@NotNull
|
||||
public net.md_5.bungee.api.ChatColor asBungee() {
|
||||
return bungee;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.bukkit;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +17,7 @@ public interface Nameable {
|
|||
* name.
|
||||
*
|
||||
* @return name of the mob/block or null
|
||||
* @see Components#getCustomName()
|
||||
*/
|
||||
@Nullable
|
||||
public String getCustomName();
|
||||
|
@ -29,6 +32,47 @@ public interface Nameable {
|
|||
* name.
|
||||
*
|
||||
* @param name the name to set
|
||||
* @see Components#setCustomName(BaseComponent)
|
||||
*/
|
||||
public void setCustomName(@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 Nameable#components()
|
||||
*/
|
||||
public interface Components {
|
||||
|
||||
/**
|
||||
* Gets the custom name of this objects. If there is no name then this
|
||||
* method will return null.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* 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.<br>
|
||||
* It should be noted that some inventory types do not support titles and
|
||||
* may not render with said titles on the Minecraft client.
|
||||
* <br>
|
||||
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
|
||||
* created with this method. Use
|
||||
* {@link Player#openWorkbench(Location, boolean)} instead.
|
||||
* <br>
|
||||
* {@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.
|
||||
* <br>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* 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)}.
|
||||
* <p>
|
||||
* 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)}.
|
||||
* <p>
|
||||
* 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)}.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Notes:
|
||||
* <ul>
|
||||
* <li>Players can disable server resources on their client, in which
|
||||
* case this method will have no affect on them. Use the
|
||||
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
|
||||
* the player loaded the pack!
|
||||
* <li>There is no concept of resetting resource packs back to default
|
||||
* within Minecraft, so players will have to relog to do so or you
|
||||
* have to send an empty pack.
|
||||
* <li>The request is sent with empty string as the hash when the hash is
|
||||
* not provided. This might result in newer versions not loading the
|
||||
* pack correctly.
|
||||
* </ul>
|
||||
*
|
||||
* @param url The URL from which the client will download the resource
|
||||
* pack. The string must contain only US-ASCII characters and should
|
||||
* be encoded as per RFC 1738.
|
||||
* @param hash The sha1 hash sum of the resource pack file which is used
|
||||
* to apply a cached version of the pack directly without downloading
|
||||
* if it is available. Hast to be 20 bytes long!
|
||||
* @param prompt The optional custom prompt message to be shown to client.
|
||||
* @throws IllegalArgumentException if the URL is too long. The
|
||||
* length restriction is an implementation specific arbitrary value.
|
||||
* @throws IllegalArgumentException if the hash is not 20 bytes
|
||||
* long.
|
||||
*/
|
||||
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable BaseComponent prompt);
|
||||
|
||||
/**
|
||||
* Request that the player's client download and switch resource packs.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Notes:
|
||||
* <ul>
|
||||
* <li>Players can disable server resources on their client, in which
|
||||
* case this method will have no affect on them. Use the
|
||||
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
|
||||
* the player loaded the pack!
|
||||
* <li>There is no concept of resetting resource packs back to default
|
||||
* within Minecraft, so players will have to relog to do so or you
|
||||
* have to send an empty pack.
|
||||
* <li>The request is sent with empty string as the hash when the hash is
|
||||
* not provided. This might result in newer versions not loading the
|
||||
* pack correctly.
|
||||
* </ul>
|
||||
*
|
||||
* @param url The URL from which the client will download the resource
|
||||
* pack. The string must contain only US-ASCII characters and should
|
||||
* be encoded as per RFC 1738.
|
||||
* @param hash The sha1 hash sum of the resource pack file which is used
|
||||
* to apply a cached version of the pack directly without downloading
|
||||
* if it is available. Hast to be 20 bytes long!
|
||||
* @param prompt The optional custom prompt message to be shown to client.
|
||||
* @param force If true, the client will be disconnected from the server
|
||||
* when it declines to use the resource pack.
|
||||
* @throws IllegalArgumentException Thrown if the URL is too long. The
|
||||
* length restriction is an implementation specific arbitrary value.
|
||||
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
|
||||
* long.
|
||||
*/
|
||||
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable BaseComponent prompt, boolean force);
|
||||
|
||||
/**
|
||||
* Request that the player's client download and switch resource packs.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Notes:
|
||||
* <ul>
|
||||
* <li>Players can disable server resources on their client, in which
|
||||
* case this method will have no affect on them. Use the
|
||||
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
|
||||
* the player loaded the pack!
|
||||
* <li>There is no concept of resetting resource packs back to default
|
||||
* within Minecraft, so players will have to relog to do so or you
|
||||
* have to send an empty pack.
|
||||
* <li>The request is sent with empty string as the hash when the hash is
|
||||
* not provided. This might result in newer versions not loading the
|
||||
* pack correctly.
|
||||
* </ul>
|
||||
*
|
||||
* @param id Unique resource pack ID.
|
||||
* @param url The URL from which the client will download the resource
|
||||
* pack. The string must contain only US-ASCII characters and should
|
||||
* be encoded as per RFC 1738.
|
||||
* @param hash The sha1 hash sum of the resource pack file which is used
|
||||
* to apply a cached version of the pack directly without downloading
|
||||
* if it is available. Hast to be 20 bytes long!
|
||||
* @param prompt The optional custom prompt message to be shown to client.
|
||||
* @param force If true, the client will be disconnected from the server
|
||||
* when it declines to use the resource pack.
|
||||
* @throws IllegalArgumentException Thrown if the URL is too long. The
|
||||
* length restriction is an implementation specific arbitrary value.
|
||||
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
|
||||
* long.
|
||||
*/
|
||||
public void setResourcePack(@NotNull UUID id, @NotNull String url, @Nullable byte[] hash, @Nullable BaseComponent prompt, boolean force);
|
||||
|
||||
/**
|
||||
* Request that the player's client download and include another resource pack.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Notes:
|
||||
* <ul>
|
||||
* <li>Players can disable server resources on their client, in which
|
||||
* case this method will have no affect on them. Use the
|
||||
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
|
||||
* the player loaded the pack!
|
||||
* <li>To remove a resource pack you can use
|
||||
* {@link #removeResourcePack(UUID)} or {@link #removeResourcePacks()}.
|
||||
* <li>The request is sent with empty string as the hash when the hash is
|
||||
* not provided. This might result in newer versions not loading the
|
||||
* pack correctly.
|
||||
* </ul>
|
||||
*
|
||||
* @param id Unique resource pack ID.
|
||||
* @param url The URL from which the client will download the resource
|
||||
* pack. The string must contain only US-ASCII characters and should
|
||||
* be encoded as per RFC 1738.
|
||||
* @param hash The sha1 hash sum of the resource pack file which is used
|
||||
* to apply a cached version of the pack directly without downloading
|
||||
* if it is available. Hast to be 20 bytes long!
|
||||
* @param prompt The optional custom prompt message to be shown to client.
|
||||
* @param force If true, the client will be disconnected from the server
|
||||
* when it declines to use the resource pack.
|
||||
* @throws IllegalArgumentException Thrown if the URL is too long. The
|
||||
* length restriction is an implementation specific arbitrary value.
|
||||
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
|
||||
* long.
|
||||
*/
|
||||
public void addResourcePack(@NotNull UUID id, @NotNull String url, @Nullable byte[] hash, @Nullable BaseComponent prompt, boolean force);
|
||||
|
||||
/**
|
||||
* Sends the component to the specified screen position of this player
|
||||
*
|
||||
* @param position the screen position
|
||||
* @param component the components to send
|
||||
*/
|
||||
public void sendMessage(@NotNull ChatMessageType position, @NotNull BaseComponent component);
|
||||
|
||||
/**
|
||||
* Sends the component to the specified screen position of this player
|
||||
*
|
||||
* @param position the screen position
|
||||
* @param sender the sender of the message
|
||||
* @param component the components to send
|
||||
*/
|
||||
public void sendMessage(@NotNull ChatMessageType position, @Nullable java.util.UUID sender, @NotNull BaseComponent component);
|
||||
|
||||
/**
|
||||
* Sends a title and a subtitle message to the player. If either of these
|
||||
* values are null, they will not be sent and the display will remain
|
||||
* unchanged. If the strings contain a new line, only the first line will
|
||||
* be sent. All timings values may take a value of -1 to indicate that they
|
||||
* will use the last value sent (or the defaults if no title has been
|
||||
* displayed).
|
||||
*
|
||||
* @param title Title component
|
||||
* @param subtitle Subtitle component
|
||||
* @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.
|
||||
*/
|
||||
public void sendTitle(@Nullable BaseComponent title, @Nullable BaseComponent subtitle, int fadeIn, int stay, int fadeOut);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.bukkit.entity;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -13,6 +14,7 @@ public interface TextDisplay extends Display {
|
|||
* Gets the displayed text.
|
||||
*
|
||||
* @return the displayed text.
|
||||
* @see Components#getText()
|
||||
*/
|
||||
@Nullable
|
||||
String getText();
|
||||
|
@ -21,6 +23,7 @@ public interface TextDisplay extends Display {
|
|||
* Sets the displayed text.
|
||||
*
|
||||
* @param text the new text
|
||||
* @see Components#setText(BaseComponent)
|
||||
*/
|
||||
void setText(@Nullable String text);
|
||||
|
||||
|
@ -142,4 +145,31 @@ public interface TextDisplay extends Display {
|
|||
*/
|
||||
RIGHT;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
Components components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see TextDisplay#components()
|
||||
*/
|
||||
interface Components extends Entity.Components {
|
||||
|
||||
/**
|
||||
* Gets the displayed text.
|
||||
*
|
||||
* @return the displayed text.
|
||||
*/
|
||||
@Nullable
|
||||
public BaseComponent getText();
|
||||
|
||||
/**
|
||||
* Sets the displayed text.
|
||||
*
|
||||
* @param text the new text
|
||||
*/
|
||||
public void setText(@Nullable BaseComponent text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.bukkit.event.server;
|
||||
|
||||
import java.util.Set;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
@ -18,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private String message;
|
||||
private BaseComponent message;
|
||||
private final Set<CommandSender> recipients;
|
||||
private boolean cancelled = false;
|
||||
|
||||
|
@ -27,7 +29,12 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
|||
this(false, message, recipients);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set<CommandSender> recipients) {
|
||||
this(isAsync, TextComponent.fromLegacy(message), recipients);
|
||||
}
|
||||
|
||||
public BroadcastMessageEvent(boolean isAsync, @NotNull BaseComponent message, @NotNull Set<CommandSender> recipients) {
|
||||
super(isAsync);
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
|
@ -37,19 +44,21 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
|||
* Get the message to broadcast.
|
||||
*
|
||||
* @return Message to broadcast
|
||||
* @see Components#getMessage()
|
||||
*/
|
||||
@NotNull
|
||||
public String getMessage() {
|
||||
return message;
|
||||
return BaseComponent.toLegacyText(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message to broadcast.
|
||||
*
|
||||
* @param message New message to broadcast
|
||||
* @see Components#setMessage(BaseComponent)
|
||||
*/
|
||||
public void setMessage(@NotNull String message) {
|
||||
this.message = message;
|
||||
this.message = TextComponent.fromLegacy(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,6 +89,48 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
|||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
private final Components components = new Components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @return component API access
|
||||
*/
|
||||
@NotNull
|
||||
public Components components() {
|
||||
return components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see BroadcastMessageEvent#components()
|
||||
*/
|
||||
public final class Components {
|
||||
|
||||
private Components() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message to broadcast.
|
||||
*
|
||||
* @param message new message to broadcast
|
||||
*/
|
||||
public void setMessage(@NotNull BaseComponent message) {
|
||||
BroadcastMessageEvent.this.message = message.duplicate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message to broadcast.
|
||||
*
|
||||
* @return message to broadcast
|
||||
*/
|
||||
@NotNull
|
||||
public BaseComponent getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.bukkit.inventory;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -273,6 +274,7 @@ public interface InventoryView {
|
|||
* Get the title of this inventory window.
|
||||
*
|
||||
* @return The title.
|
||||
* @see Components#getTitle()
|
||||
*/
|
||||
@NotNull
|
||||
public String getTitle();
|
||||
|
@ -282,6 +284,7 @@ public interface InventoryView {
|
|||
* made using {@link #setTitle(String)}.
|
||||
*
|
||||
* @return the original title
|
||||
* @see Components#getOriginalTitle()
|
||||
*/
|
||||
@NotNull
|
||||
public String getOriginalTitle();
|
||||
|
@ -295,6 +298,53 @@ public interface InventoryView {
|
|||
* exception.
|
||||
*
|
||||
* @param title The new title.
|
||||
* @see Components#setTitle(BaseComponent)
|
||||
*/
|
||||
public void setTitle(@NotNull String title);
|
||||
|
||||
/**
|
||||
* 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 InventoryView#components()
|
||||
*/
|
||||
public interface Components {
|
||||
|
||||
/**
|
||||
* Get the title of this inventory window.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
@NotNull
|
||||
public BaseComponent getTitle();
|
||||
|
||||
/**
|
||||
* Get the original title of this inventory window, before any changes were
|
||||
* made using {@link #setTitle(BaseComponent)}.
|
||||
*
|
||||
* @return the original title
|
||||
*/
|
||||
@NotNull
|
||||
public BaseComponent getOriginalTitle();
|
||||
|
||||
/**
|
||||
* Sets the title of this inventory window to the specified title if the
|
||||
* inventory window supports it.
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> getLore();
|
||||
|
@ -143,6 +149,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
|
|||
* Removes lore when given null.
|
||||
*
|
||||
* @param lore the lore that will be set
|
||||
* @see Components#setLore(List)
|
||||
*/
|
||||
void setLore(@Nullable List<String> lore);
|
||||
|
||||
|
@ -680,4 +687,78 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
|
|||
@SuppressWarnings("javadoc")
|
||||
@NotNull
|
||||
ItemMeta clone();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @return component API access
|
||||
*/
|
||||
@NotNull
|
||||
Components components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see ItemMeta#components()
|
||||
*/
|
||||
interface Components {
|
||||
|
||||
/**
|
||||
* Gets the display name of this item.
|
||||
*
|
||||
* @return the display name
|
||||
*/
|
||||
@Nullable
|
||||
BaseComponent getDisplayName();
|
||||
|
||||
/**
|
||||
* Sets the display name of this item.
|
||||
*
|
||||
* @param displayName the display name to set
|
||||
*/
|
||||
void setDisplayName(@Nullable BaseComponent displayName);
|
||||
|
||||
/**
|
||||
* Gets the item name that is set.
|
||||
* <br>
|
||||
* 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.
|
||||
* <p>
|
||||
* Plugins should check that hasItemName() returns <code>true</code> before
|
||||
* calling this method.
|
||||
*
|
||||
* @return the item name that is set
|
||||
*/
|
||||
@NotNull
|
||||
BaseComponent getItemName();
|
||||
|
||||
/**
|
||||
* Sets the item name.
|
||||
* <br>
|
||||
* 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.
|
||||
* <p>
|
||||
* Plugins should check if hasLore() returns <code>true</code> before
|
||||
* calling this method.
|
||||
*
|
||||
* @return the lore, or null if no lore is set
|
||||
*/
|
||||
@Nullable
|
||||
List<BaseComponent> getLore();
|
||||
|
||||
/**
|
||||
* Sets the lore for this item. Removes lore when given null.
|
||||
*
|
||||
* @param lore the lore to set
|
||||
*/
|
||||
void setLore(@Nullable List<BaseComponent> lore);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package org.bukkit.inventory.meta;
|
||||
|
||||
import java.util.List;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a book ({@link Material#WRITABLE_BOOK} or {@link
|
||||
|
@ -24,6 +26,7 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
*
|
||||
* @param page the page number to get, in range [1, getPageCount()]
|
||||
* @return the page from the book
|
||||
* @see Components#getPage(int)
|
||||
*/
|
||||
@NotNull
|
||||
String getPage(int page);
|
||||
|
@ -39,6 +42,7 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
*
|
||||
* @param page the page number to set, in range [1, getPageCount()]
|
||||
* @param data the data to set for that page
|
||||
* @see Components#setPage(int, BaseComponent)
|
||||
*/
|
||||
void setPage(int page, @NotNull String data);
|
||||
|
||||
|
@ -46,6 +50,7 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
* Gets all the pages in the book.
|
||||
*
|
||||
* @return list of all the pages in the book
|
||||
* @see Components#getPages()
|
||||
*/
|
||||
@NotNull
|
||||
List<String> getPages();
|
||||
|
@ -55,6 +60,7 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
* pages. Maximum 100 pages with 1024 characters per page.
|
||||
*
|
||||
* @param pages A list of pages to set the book to use
|
||||
* @see Components#setPages(List)
|
||||
*/
|
||||
void setPages(@NotNull List<String> pages);
|
||||
|
||||
|
@ -63,6 +69,7 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
* pages. Maximum 100 pages with 1024 characters per page.
|
||||
*
|
||||
* @param pages A list of strings, each being a page
|
||||
* @see Components#setPages(List)
|
||||
*/
|
||||
void setPages(@NotNull String... pages);
|
||||
|
||||
|
@ -71,6 +78,7 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
* 1024 characters per page.
|
||||
*
|
||||
* @param pages A list of strings, each being a page
|
||||
* @see Components#addPage(BaseComponent)
|
||||
*/
|
||||
void addPage(@NotNull String... pages);
|
||||
|
||||
|
@ -84,4 +92,69 @@ public interface WritableBookMeta extends ItemMeta {
|
|||
@Override
|
||||
@NotNull
|
||||
WritableBookMeta clone();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
Components components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see WritableBookMeta#components()
|
||||
*/
|
||||
interface Components extends ItemMeta.Components {
|
||||
|
||||
/**
|
||||
* Gets the specified page in the book. The given page must exist.
|
||||
*
|
||||
* @param page the page number to get
|
||||
* @return the page from the book
|
||||
*/
|
||||
@NotNull
|
||||
public BaseComponent getPage(int page);
|
||||
|
||||
/**
|
||||
* Sets the specified page in the book. Pages of the book must be
|
||||
* contiguous.
|
||||
* <p>
|
||||
* 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<BaseComponent> getPages();
|
||||
|
||||
/**
|
||||
* Clears the existing book pages and sets the book to use the provided
|
||||
* pages. Up to a maximum of 50 pages with 256 characters per page.
|
||||
*
|
||||
* @param pages the list of pages to set
|
||||
*/
|
||||
public void setPages(@NotNull List<BaseComponent> pages);
|
||||
|
||||
/**
|
||||
* Adds a new page to the end of the book. Up to a maximum of 50 pages
|
||||
* with 256 characters per page.
|
||||
*
|
||||
* @param text the component text to add
|
||||
*/
|
||||
public void addPage(@NotNull BaseComponent text);
|
||||
|
||||
/**
|
||||
* Adds new pages to the end of the book. Up to a maximum of 50 pages
|
||||
* with 256 characters per page.
|
||||
*
|
||||
* @param pages a list of components, each being a new page to add
|
||||
*/
|
||||
public void addPages(@NotNull List<BaseComponent> pages);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.bukkit.scoreboard;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -25,6 +26,7 @@ public interface Objective {
|
|||
*
|
||||
* @return this objective's display name
|
||||
* @throws IllegalStateException if this objective has been unregistered
|
||||
* @see Components#getDisplayName()
|
||||
*/
|
||||
@NotNull
|
||||
String getDisplayName();
|
||||
|
@ -34,6 +36,7 @@ public interface Objective {
|
|||
*
|
||||
* @param displayName Display name to set
|
||||
* @throws IllegalStateException if this objective has been unregistered
|
||||
* @see Components#setDisplayName(BaseComponent)
|
||||
*/
|
||||
void setDisplayName(@NotNull String displayName);
|
||||
|
||||
|
@ -140,4 +143,37 @@ public interface Objective {
|
|||
*/
|
||||
@NotNull
|
||||
Score getScore(@NotNull String entry);
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @return component API access
|
||||
*/
|
||||
@NotNull
|
||||
Components components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see Objective#components()
|
||||
*/
|
||||
interface Components {
|
||||
|
||||
/**
|
||||
* Gets the name displayed to players for this objective
|
||||
*
|
||||
* @return this objective's display name
|
||||
* @throws IllegalStateException if this objective has been unregistered
|
||||
*/
|
||||
@NotNull
|
||||
BaseComponent getDisplayName();
|
||||
|
||||
/**
|
||||
* Sets the name displayed to players for this objective.
|
||||
*
|
||||
* @param displayName display name to set
|
||||
* @throws IllegalStateException if this objective has been unregistered
|
||||
*/
|
||||
void setDisplayName(@NotNull BaseComponent displayName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.bukkit.scoreboard;
|
||||
|
||||
import java.util.Set;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -72,6 +73,7 @@ public interface Scoreboard {
|
|||
* characters.
|
||||
* @throws IllegalArgumentException if an objective by that name already
|
||||
* exists
|
||||
* @see Components#registerNewObjective(String, Criteria, BaseComponent)
|
||||
*/
|
||||
@NotNull
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName);
|
||||
|
@ -88,6 +90,7 @@ public interface Scoreboard {
|
|||
* characters.
|
||||
* @throws IllegalArgumentException if an objective by that name already
|
||||
* exists
|
||||
* @see Components#registerNewObjective(String, Criteria, BaseComponent, RenderType)
|
||||
*/
|
||||
@NotNull
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName, @NotNull RenderType renderType);
|
||||
|
@ -251,4 +254,45 @@ public interface Scoreboard {
|
|||
* @param slot the slot to remove objectives
|
||||
*/
|
||||
void clearSlot(@NotNull DisplaySlot slot);
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @return component API access
|
||||
*/
|
||||
@NotNull
|
||||
Components components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see Scoreboard#components()
|
||||
*/
|
||||
interface Components {
|
||||
|
||||
/**
|
||||
* Registers a new objective on this scoreboard.
|
||||
*
|
||||
* @param name the unique name of the objective
|
||||
* @param criteria the objective criteria
|
||||
* @param displayName the objective's display name shown to players
|
||||
* @return the registered Objective instance
|
||||
* @throws IllegalArgumentException if an objective by that name already exists
|
||||
*/
|
||||
@NotNull
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull BaseComponent displayName);
|
||||
|
||||
/**
|
||||
* Registers a new objective on this scoreboard.
|
||||
*
|
||||
* @param name the unique name of the objective
|
||||
* @param criteria the objective criteria
|
||||
* @param displayName the objective's display name shown to players
|
||||
* @param renderType manner of rendering the objective
|
||||
* @return the registered Objective instance
|
||||
* @throws IllegalArgumentException if an objective by that name already exists
|
||||
*/
|
||||
@NotNull
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull BaseComponent displayName, @NotNull RenderType renderType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.bukkit.scoreboard;
|
||||
|
||||
import java.util.Set;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
@ -28,6 +29,7 @@ public interface Team {
|
|||
*
|
||||
* @return Team display name
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
* @see Components#getDisplayName()
|
||||
*/
|
||||
@NotNull
|
||||
String getDisplayName();
|
||||
|
@ -37,6 +39,7 @@ public interface Team {
|
|||
*
|
||||
* @param displayName New display name
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
* @see Components#setDisplayName(BaseComponent)
|
||||
*/
|
||||
void setDisplayName(@NotNull String displayName);
|
||||
|
||||
|
@ -45,6 +48,7 @@ public interface Team {
|
|||
*
|
||||
* @return Team prefix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
* @see Components#getPrefix()
|
||||
*/
|
||||
@NotNull
|
||||
String getPrefix();
|
||||
|
@ -54,6 +58,7 @@ public interface Team {
|
|||
*
|
||||
* @param prefix New prefix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
* @see Components#setPrefix(BaseComponent)
|
||||
*/
|
||||
void setPrefix(@NotNull String prefix);
|
||||
|
||||
|
@ -62,6 +67,7 @@ public interface Team {
|
|||
*
|
||||
* @return the team's current suffix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
* @see Components#getSuffix()
|
||||
*/
|
||||
@NotNull
|
||||
String getSuffix();
|
||||
|
@ -71,6 +77,7 @@ public interface Team {
|
|||
*
|
||||
* @param suffix the new suffix for this team.
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
* @see Components#setSuffix(BaseComponent)
|
||||
*/
|
||||
void setSuffix(@NotNull String suffix);
|
||||
|
||||
|
@ -321,4 +328,71 @@ public interface Team {
|
|||
*/
|
||||
FOR_OWN_TEAM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @return component API access
|
||||
*/
|
||||
@NotNull
|
||||
Components components();
|
||||
|
||||
/**
|
||||
* Access to API revolving around {@link BaseComponent BaseComponents}.
|
||||
*
|
||||
* @see Team#components()
|
||||
*/
|
||||
interface Components {
|
||||
|
||||
/**
|
||||
* Gets the name displayed to players on this team.
|
||||
*
|
||||
* @return the display name
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
*/
|
||||
@NotNull
|
||||
BaseComponent getDisplayName();
|
||||
|
||||
/**
|
||||
* Sets the name displayed to players on this team.
|
||||
*
|
||||
* @param displayName the new display name
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
*/
|
||||
void setDisplayName(@NotNull BaseComponent displayName);
|
||||
|
||||
/**
|
||||
* Gets the prefix prepended to the display of entries on this team.
|
||||
*
|
||||
* @return the prefix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
*/
|
||||
@NotNull
|
||||
BaseComponent getPrefix();
|
||||
|
||||
/**
|
||||
* Sets the prefix prepended to the display of entries on this team.
|
||||
*
|
||||
* @param prefix the new prefix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
*/
|
||||
void setPrefix(@NotNull BaseComponent prefix);
|
||||
|
||||
/**
|
||||
* Gets the suffix appended to the display of entries on this team.
|
||||
*
|
||||
* @return the suffix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
*/
|
||||
@NotNull
|
||||
BaseComponent getSuffix();
|
||||
|
||||
/**
|
||||
* Sets the suffix appended to the display of entries on this team.
|
||||
*
|
||||
* @param suffix the new suffix
|
||||
* @throws IllegalStateException if this team has been unregistered
|
||||
*/
|
||||
void setSuffix(@NotNull BaseComponent suffix);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue