Replace ItemTag API with new API that also expands to Tiles and Entities

By: Bjarne Koll <LynxPlay101@gmail.com>
This commit is contained in:
Bukkit/Spigot
2019-04-25 14:24:05 +10:00
parent 3209bcbf56
commit ddfd4b10c4
30 changed files with 416 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a banner.
*/
public interface Banner extends BlockState {
public interface Banner extends TileState {
/**
* Returns the base color for this banner

View File

@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a beacon.
*/
public interface Beacon extends BlockState, Lockable, Nameable {
public interface Beacon extends TileState, Lockable, Nameable {
/**
* Returns the list of players within the beacon's range of effect.

View File

@@ -7,4 +7,4 @@ import org.bukkit.material.Colorable;
* @deprecated does not provide useful information beyond the material itself
*/
@Deprecated
public interface Bed extends BlockState, Colorable { }
public interface Bed extends TileState, Colorable { }

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of Bell.
*/
public interface Bell extends BlockState { }
public interface Bell extends TileState { }

View File

@@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a campfire.
*/
public interface Campfire extends BlockState {
public interface Campfire extends TileState {
/**
* @see Inventory#getSize()

View File

@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a command block.
*/
public interface CommandBlock extends BlockState {
public interface CommandBlock extends TileState {
/**
* Gets the command that this CommandBlock will run when powered.

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of an on / off comparator.
*/
public interface Comparator extends BlockState { }
public interface Comparator extends TileState { }

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of a conduit.
*/
public interface Conduit extends BlockState { }
public interface Conduit extends TileState { }

View File

@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a container block.
*/
public interface Container extends BlockState, BlockInventoryHolder, Lockable, Nameable {
public interface Container extends TileState, BlockInventoryHolder, Lockable, Nameable {
/**
* Gets the inventory of the block represented by this block state.

View File

@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a creature spawner.
*/
public interface CreatureSpawner extends BlockState {
public interface CreatureSpawner extends TileState {
/**
* Get the spawner's creature type.

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of a (possibly inverted) daylight detector.
*/
public interface DaylightDetector extends BlockState { }
public interface DaylightDetector extends TileState { }

View File

@@ -5,4 +5,4 @@ import org.bukkit.Nameable;
/**
* Represents a captured state of an enchanting table.
*/
public interface EnchantingTable extends BlockState, Nameable { }
public interface EnchantingTable extends TileState, Nameable { }

View File

@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of an end gateway.
*/
public interface EndGateway extends BlockState {
public interface EndGateway extends TileState {
/**
* Gets the location that entities are teleported to when

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of an ender chest.
*/
public interface EnderChest extends BlockState { }
public interface EnderChest extends TileState { }

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of a jigsaw.
*/
public interface Jigsaw extends BlockState { }
public interface Jigsaw extends TileState { }

View File

@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a jukebox.
*/
public interface Jukebox extends BlockState {
public interface Jukebox extends TileState {
/**
* Gets the record inserted into the jukebox.

View File

@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a lectern.
*/
public interface Lectern extends BlockState, BlockInventoryHolder {
public interface Lectern extends TileState, BlockInventoryHolder {
/**
* Get the current lectern page.

View File

@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of either a SignPost or a WallSign.
*/
public interface Sign extends BlockState {
public interface Sign extends TileState {
/**
* Gets all the lines of text currently on this sign.

View File

@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a skull block.
*/
public interface Skull extends BlockState {
public interface Skull extends TileState {
/**
* Checks to see if the skull has an owner

View File

@@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
* Represents a structure block that can save and load blocks from a file. They
* can only be used by OPs, and are not obtainable in survival.
*/
public interface Structure extends BlockState {
public interface Structure extends TileState {
/**
* The name of this structure.

View File

@@ -0,0 +1,39 @@
package org.bukkit.block;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataHolder;
import org.jetbrains.annotations.NotNull;
/**
* Represents a block state that also hosts a tile entity at the given location.
*
* This interface alone is merely a marker that does not provide any data.
*
* Data about the tile entities is provided by the respective interface for each
* tile entity type.
*
* After modifying the data provided by a TileState, {@link #update()} needs to
* be called to store the data.
*/
public interface TileState extends BlockState, PersistentDataHolder {
/**
* Returns a custom tag container capable of storing tags on the object.
*
* Note that the tags stored on this container are all stored under their
* own custom namespace therefore modifying default tags using this
* {@link PersistentDataHolder} is impossible.
* <p>
* This {@link PersistentDataHolder} is only linked to the snapshot instance
* stored by the {@link BlockState}.
*
* When storing changes on the {@link PersistentDataHolder}, the updated
* content will only be applied to the actual tile entity after one of the
* {@link #update()} methods is called.
*
* @return the custom tag container
*/
@NotNull
@Override
PersistentDataContainer getPersistentDataContainer();
}