Package xyz.srnyx.annoyingapi.data
Class EntityData
java.lang.Object
xyz.srnyx.javautilities.parents.Stringable
xyz.srnyx.annoyingapi.data.Data<String>
xyz.srnyx.annoyingapi.data.StringData
xyz.srnyx.annoyingapi.data.EntityData
- All Implemented Interfaces:
Annoyable
Utility class for adding and getting data from entities
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull StringThe name of the table in the database to store entity dataFields inherited from class xyz.srnyx.annoyingapi.data.StringData
TARGET_COLUMN, useCache -
Constructor Summary
ConstructorsConstructorDescriptionEntityData(@NotNull AnnoyingPlugin plugin, @NotNull org.bukkit.entity.Entity entity) Construct a newEntityDatafor the given entity -
Method Summary
Modifier and TypeMethodDescriptionconvertOldData(boolean onlyTryOnce) convertOldData(boolean onlyTryOnce, @NotNull String... keys) CallsconvertOldData(boolean, Collection)with the given keysconvertOldData(boolean onlyTryOnce, @Nullable Collection<String> keys) Convert all data from the old data storage system (PDC/file) to the new one (SQL)
This does not run automatically, you must call this method manually (for example, onPlayerJoinEvent)!
For 1.14+ (PDC), the entity will receive theCONVERTED_KEYkey which indicates that the data has been converted, this will avoid duplicate conversion checks
All old data (PDC/file) will be removed after conversion (to avoid duplicate/overwriting data)convertOldData(@NotNull String... keys) convertOldData(@NotNull Collection<String> keys) Methods inherited from class xyz.srnyx.annoyingapi.data.StringData
get, remove, set, useCacheMethods inherited from class xyz.srnyx.annoyingapi.data.Data
get, getAnnoyingPlugin, getOptional, has, removeChain, sendError, set, setChainMethods inherited from class xyz.srnyx.javautilities.parents.Stringable
toString, toString, toString, toString, toString
-
Field Details
-
TABLE_NAME
The name of the table in the database to store entity data- See Also:
-
-
Constructor Details
-
EntityData
public EntityData(@NotNull @NotNull AnnoyingPlugin plugin, @NotNull @NotNull org.bukkit.entity.Entity entity) Construct a newEntityDatafor the given entity- Parameters:
plugin-Data.pluginentity-entityandData.target(uses entity UUID)
-
-
Method Details
-
convertOldData
@Nullable public @Nullable Map<String,String> convertOldData(boolean onlyTryOnce, @Nullable @Nullable Collection<String> keys) Convert all data from the old data storage system (PDC/file) to the new one (SQL)
This does not run automatically, you must call this method manually (for example, onPlayerJoinEvent)!
For 1.14+ (PDC), the entity will receive theCONVERTED_KEYkey which indicates that the data has been converted, this will avoid duplicate conversion checks
All old data (PDC/file) will be removed after conversion (to avoid duplicate/overwriting data)- Parameters:
onlyTryOnce- 1.14+ only |trueto only try once to convert the data, even if it fails (so if run again, nothing will happen). Iffalse, the conversion failed previously, and this is run again, it will try to convert again. If the data is successfully converted, this option doesn't matterkeys- only applicable for 1.14-1.16, otherwise it will convert all keys (no matter what is provided)- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails)
-
convertOldData
@Nullable public @Nullable Map<String,String> convertOldData(boolean onlyTryOnce, @NotNull @NotNull String... keys) CallsconvertOldData(boolean, Collection)with the given keys- Parameters:
onlyTryOnce- 1.14+ only |trueto only try once to convert the data, even if it fails (so if run again, nothing will happen). Iffalse, the conversion failed previously, and this is run again, it will try to convert again. If the data is successfully converted, this option doesn't matterkeys- only applicable for 1.14-1.16, otherwise it will convert all keys (no matter what is provided)- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails) - See Also:
-
convertOldData
@Nullable public @Nullable Map<String,String> convertOldData(@NotNull @NotNull Collection<String> keys) - Parameters:
keys- only applicable for 1.14-1.16, otherwise it will convert all keys (no matter what is provided)- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails) - See Also:
-
convertOldData
- Parameters:
keys- only applicable for 1.14-1.16, otherwise it will convert all keys (no matter what is provided)- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails) - See Also:
-
convertOldData
- Parameters:
onlyTryOnce- 1.14+ only |trueto only try once to convert the data, even if it fails (so if run again, nothing will happen). Iffalse, the conversion failed previously, and this is run again, it will try to convert again. If the data is successfully converted, this option doesn't matter- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails) - See Also:
-
convertOldData
- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails) - See Also:
-