Package net.tnemc.item.platform
Class ItemPlatform<I extends AbstractItemStack<S>,S,U>
java.lang.Object
net.tnemc.item.platform.ItemPlatform<I,S,U>
- Type Parameters:
I
- The implementation's instance ofAbstractItemStack
S
- The implementation's instance of item stacks.U
- The implementation's instace of inventories.
- Direct Known Subclasses:
BukkitItemPlatform
,PaperItemPlatform
ItemPlatform
- Since:
- 0.2.0.0
- Author:
- creatorfromhell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addApplicator
(@NotNull ItemApplicator<I, S> applicator) void
abstract void
Adds default configurations or settings to be used by the implementing class.void
addEffect
(@NotNull ComponentEffect effect) Adds a ReviveEffect to the reviveEffects map.void
addItemProvider
(ItemProvider<S> provider) Adds an ItemProvider to the ItemPlatform.void
Used to add an object that is capable of being dual/tri purpose as a check, applicator and/or deserializer.void
addPersistentDataType
(String identifier, @NotNull Class<? extends PersistentDataType<?>> type) Adds a persistent data type to the item platform.void
addSerializer
(@NotNull ItemSerializer<I, S> serializer) Applies all enabled applicators to the given item.abstract CalculationsProvider
<I, S, U> Provides access to the calculations provider for performing various platform-specific operations.boolean
Used to check if two serialized stacks are comparable.boolean
Used to check if two locale stacks are comparable.boolean
checkOrder
(I original, I check, @NotNull String... order) Used to check if two serialized stacks are comparable based on a specific order of checks.boolean
checkOrder
(S original, S check, @NotNull String... order) Used to check if two locale stacks are comparable based on a specific order of checks.static String
componentString
(@NotNull net.kyori.adventure.text.Component component) Retrieves the platform converter associated with the current item platform.abstract I
createStack
(String material) Creates a new stack based on the given material.abstract @NotNull ItemProvider
<S> Retrieves the default provider for the item stack comparison.abstract @NotNull String
Retrieves the identifier of the default provider for the item stack comparison.Map
<String, Class<? extends ComponentEffect>> effects()
Map
<String, Class<? extends PersistentDataType<?>>> initSerialized
(org.json.simple.JSONObject object) Initializes and returns an AbstractItemStack object by deserializing the provided JSON object.abstract I
Converts the given locale stack to an instance ofAbstractItemStack
Retrieves the item provider for the given itemProvider name, or returns the default provider if not found.boolean
providerApplies
(AbstractItemStack<? extends S> serialized, S item) Checks if any of the registered item providers are applicable to the given serialized item and item.serializer
(S item, I serialized) Applies all enabled serializers to the given item.abstract String
version()
-
Constructor Details
-
ItemPlatform
public ItemPlatform() -
ItemPlatform
-
-
Method Details
-
createStack
Creates a new stack based on the given material.- Parameters:
material
- The material used for creating the stack.- Returns:
- The newly created stack.
- Since:
- 0.2.0.0
-
version
- Returns:
- the version that is being used currently
- Since:
- 0.2.0.0
-
addDefaults
Adds default configurations or settings to be used by the implementing class.- Since:
- 0.2.0.0
-
converter
Retrieves the platform converter associated with the current item platform.- Returns:
- The
PlatformConverter
instance used by the item platform. - Since:
- 0.2.0.0
-
defaultProvider
Retrieves the default provider for the item stack comparison.- Returns:
- the default provider for the item stack comparison.
- Since:
- 0.2.0.0
-
defaultProviderIdentifier
Retrieves the identifier of the default provider for the item stack comparison.- Returns:
- The identifier of the default provider for the item stack comparison.
- Since:
- 0.2.0.0
-
calculations
Provides access to the calculations provider for performing various platform-specific operations.- Returns:
- An instance of
CalculationsProvider
that handles calculations related to the item platform. - Since:
- 0.2.0.0
-
providerApplies
Checks if any of the registered item providers are applicable to the given serialized item and item.- Parameters:
serialized
- The serialized item stack to check against.item
- The item to check for applicability.- Returns:
- True if an item provider is found that applies to the serialized item and item, otherwise false.
- Since:
- 0.2.0.0
-
provider
Retrieves the item provider for the given itemProvider name, or returns the default provider if not found.- Parameters:
itemProvider
- The name of the ItemProvider to retrieve.- Returns:
- The ItemProvider associated with the itemProvider name, or the default provider if not found.
- Since:
- 0.2.0.0
-
addItemProvider
Adds an ItemProvider to the ItemPlatform.- Parameters:
provider
- The ItemProvider to add to the platform- Since:
- 0.2.0.0
-
addPersistentDataType
public void addPersistentDataType(String identifier, @NotNull @NotNull Class<? extends PersistentDataType<?>> type) Adds a persistent data type to the item platform.- Parameters:
identifier
- The identifier for the persistent data type.type
- The class representing the persistent data type.- Since:
- 0.2.0.0
-
getClasses
-
addMulti
Used to add an object that is capable of being dual/tri purpose as a check, applicator and/or deserializer.- Parameters:
object
- the object to add.- Since:
- 0.2.0.0
-
locale
Converts the given locale stack to an instance ofAbstractItemStack
- Parameters:
locale
- the locale to convert- Returns:
- the converted locale of type I
- Since:
- 0.2.0.0
-
addCheck
- Parameters:
check
- thecheck
to add.- Since:
- 0.2.0.0
-
addApplicator
- Parameters:
applicator
- the applicator to add- Since:
- 0.2.0.0
-
addSerializer
- Parameters:
serializer
- the deserializer to add- Since:
- 0.2.0.0
-
addEffect
Adds a ReviveEffect to the reviveEffects map.- Parameters:
effect
- The ReviveEffect instance to add. Must not be null.- Since:
- 0.2.0.0
-
check
public boolean check(@NotNull S original, @NotNull S check, @NotNull @NotNull String... disabledChecks) Used to check if two locale stacks are comparable. How they are performed: - if a locale check applies, the check result is returned, true is the default return.- Parameters:
original
- the original stackcheck
- the stack to use for the checkdisabledChecks
- theIdentifiable.identifier()
check identifiers that should be disabled for the check.- Returns:
- True if the check passes, otherwise false.
- Since:
- 0.2.0.0
-
checkOrder
Used to check if two locale stacks are comparable based on a specific order of checks.- Parameters:
original
- the original stackcheck
- the stack to use for the checkorder
- the order of the checks to run for the comparison- Returns:
- True if the check passes, otherwise false.
- Since:
- 0.2.0.0
-
check
Used to check if two serialized stacks are comparable.- Parameters:
original
- the original stackcheck
- the stack to use for the checkdisabledChecks
- theIdentifiable.identifier()
check identifiers that should be disabled for the check.- Returns:
- True if the check passes, otherwise false.
- Since:
- 0.2.0.0
-
checkOrder
Used to check if two serialized stacks are comparable based on a specific order of checks.- Parameters:
original
- the original stackcheck
- the stack to use for the checkorder
- the order of the checks to run for the comparison- Returns:
- True if the check passes, otherwise false.
- Since:
- 0.2.0.0
-
apply
Applies all enabled applicators to the given item.- Parameters:
serialized
- the serialized item stack to useitem
- the locale itemstack object to apply the applications to- Returns:
- the updated item stack after applying the applicators
- Since:
- 0.2.0.0
-
serializer
Applies all enabled serializers to the given item.- Parameters:
item
- the item that we should use to serialize.serialized
- the serialized item stack we should use to apply this serializer to- Returns:
- the updated serialized item.
- Since:
- 0.2.0.0
-
initSerialized
Initializes and returns an AbstractItemStack object by deserializing the provided JSON object.- Parameters:
object
- the JSON object to deserialize- Returns:
- an initialized AbstractItemStack object
- Since:
- 0.2.0.0
-
componentString
public static String componentString(@NotNull @NotNull net.kyori.adventure.text.Component component) -
effects
-