Class ComponentWrapper<T,B extends io.papermc.paper.datacomponent.DataComponentBuilder<T>>
java.lang.Object
org.skriptlang.skript.bukkit.itemcomponents.ComponentWrapper<T,B>
- Type Parameters:
T- The type of componentB- The builder type ofComponentWrapper
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
EquippableWrapper
public abstract class ComponentWrapper<T,B extends io.papermc.paper.datacomponent.DataComponentBuilder<T>>
extends Object
implements Cloneable
A wrapper that allows access and modification of a specific component from an
ItemStack
or a stand-alone component.-
Constructor Summary
ConstructorsConstructorDescriptionComponentWrapper(B builder) Constructs aComponentWrapperthat only references to a built component.ComponentWrapper(ItemSource<?> itemSource) Constructs aComponentWrapperwith the givenItemSource.ComponentWrapper(org.bukkit.inventory.ItemStack itemStack) ComponentWrapper(T component) Constructs aComponentWrapperthat only references to a component. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyBuilder(B builder) Apply a newbuilderto theitemSource.voidApply the currentcomponentto theitemSource.voidapplyComponent(T component) Apply a newcomponentorcomponentto theitemSource.abstract ComponentWrapper<T, B> clone()Returns a clone of thisComponentWrapper.voideditBuilder(Consumer<B> consumer) Edit theComponentWrappercomponent of thisComponentWrapperand have changes applied.booleanReturns the builder of the current component If thisComponentWrapperwas constructed with anItemSource, the builder is retrieved from the component of the stored item.protected abstract BgetBuilder(org.bukkit.inventory.ItemStack itemStack) Returns theComponentWrapperbuilder of the component fromitemStack.protected abstract BgetBuilder(T component) Convertcomponentto a builder.Returns the current component.protected abstract TgetComponent(org.bukkit.inventory.ItemStack itemStack) Returns theComponentWrappercomponent fromitemStack.abstract io.papermc.paper.datacomponent.DataComponentType.Valued<T> Returns theDataComponentTypeof thisComponentWrapper.@Nullable ItemSource<?> Returns theItemSourcetheItemStackis sourced from.@Nullable org.bukkit.inventory.ItemStackReturns theItemStackassociated with thisComponentWrapper, if available.abstract BReturns a new builderComponentWrapper.abstract TReturns a new componentComponentWrapper.abstract ComponentWrapper<T, B> Returns a newComponentWrapper.protected voidsetBuilder(org.bukkit.inventory.ItemStack itemStack, B builder) Sets theComponentWrapperbuilder component onitemStack.protected abstract voidsetComponent(org.bukkit.inventory.ItemStack itemStack, T component) Sets theComponentWrappercomponent onitemStack.toString()
-
Constructor Details
-
ComponentWrapper
public ComponentWrapper(org.bukkit.inventory.ItemStack itemStack) - Parameters:
itemStack- The originalItemStack.- See Also:
-
ComponentWrapper
Constructs aComponentWrapperwith the givenItemSource. Ensures up-to-date component data retrieval and modification on theItemStackof theItemSource.- Parameters:
itemSource- TheItemSourcerepresenting the original source of theItemStack.
-
ComponentWrapper
Constructs aComponentWrapperthat only references to a component. -
ComponentWrapper
Constructs aComponentWrapperthat only references to a built component.
-
-
Method Details
-
getComponent
Returns the current component. If thisComponentWrapperwas constructed with anItemSource, the component is retrieved from the stored item. Otherwise, the storedcomponent. -
getBuilder
Returns the builder of the current component If thisComponentWrapperwas constructed with anItemSource, the builder is retrieved from the component of the stored item. Otherwise, the storedcomponent. -
getItemStack
@Nullable public @Nullable org.bukkit.inventory.ItemStack getItemStack()Returns theItemStackassociated with thisComponentWrapper, if available. -
getItemSource
Returns theItemSourcetheItemStackis sourced from. -
getDataComponentType
Returns theDataComponentTypeof thisComponentWrapper. -
getComponent
Returns theComponentWrappercomponent fromitemStack. -
getBuilder
Returns theComponentWrapperbuilder of the component fromitemStack. -
setComponent
Sets theComponentWrappercomponent onitemStack. -
setBuilder
Sets theComponentWrapperbuilder component onitemStack. -
applyComponent
public void applyComponent()Apply the currentcomponentto theitemSource. -
applyComponent
Apply a newcomponentorcomponentto theitemSource. -
applyBuilder
Apply a newbuilderto theitemSource. -
editBuilder
Edit theComponentWrappercomponent of thisComponentWrapperand have changes applied. -
getBuilder
Convertcomponentto a builder.- Parameters:
component- The component.- Returns:
- The builder.
-
clone
Returns a clone of thisComponentWrapper. -
newComponent
Returns a new componentComponentWrapper. -
newBuilder
Returns a new builderComponentWrapper. -
newWrapper
Returns a newComponentWrapper. -
equals
-
toString
-