Package xyz.srnyx.annoyingapi.data
Class EntityData
- java.lang.Object
-
- xyz.srnyx.javautilities.parents.Stringable
-
- xyz.srnyx.annoyingapi.data.Data<java.lang.String>
-
- xyz.srnyx.annoyingapi.data.StringData
-
- xyz.srnyx.annoyingapi.data.EntityData
-
- All Implemented Interfaces:
Annoyable
public class EntityData extends StringData
Utility class for adding and getting data from entities
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull java.lang.StringTABLE_NAMEThe name of the table in the database to store entity data-
Fields inherited from class xyz.srnyx.annoyingapi.data.StringData
TARGET_COLUMN, useCache
-
-
Constructor Summary
Constructors Constructor Description EntityData(@NotNull AnnoyingPlugin plugin, @NotNull org.bukkit.entity.Entity entity)Construct a newEntityDatafor the given entity
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable java.util.Map<java.lang.String,java.lang.String>convertOldData()@Nullable java.util.Map<java.lang.String,java.lang.String>convertOldData(boolean onlyTryOnce)@Nullable java.util.Map<java.lang.String,java.lang.String>convertOldData(boolean onlyTryOnce, @NotNull java.lang.String... keys)CallsconvertOldData(boolean, Collection)with the given keys@Nullable java.util.Map<java.lang.String,java.lang.String>convertOldData(boolean onlyTryOnce, @Nullable java.util.Collection<java.lang.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)@Nullable java.util.Map<java.lang.String,java.lang.String>convertOldData(@NotNull java.lang.String... keys)@Nullable java.util.Map<java.lang.String,java.lang.String>convertOldData(@NotNull java.util.Collection<java.lang.String> keys)-
Methods inherited from class xyz.srnyx.annoyingapi.data.StringData
get, remove, set, useCache
-
Methods inherited from class xyz.srnyx.annoyingapi.data.Data
get, getAnnoyingPlugin, getOptional, has, removeChain, sendError, set, setChain
-
-
-
-
Field Detail
-
TABLE_NAME
@NotNull public static final @NotNull java.lang.String TABLE_NAME
The name of the table in the database to store entity data- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
convertOldData
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.String> convertOldData(boolean onlyTryOnce, @Nullable @Nullable java.util.Collection<java.lang.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 java.util.Map<java.lang.String,java.lang.String> convertOldData(boolean onlyTryOnce, @NotNull @NotNull java.lang.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(boolean, Collection)
-
convertOldData
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.String> convertOldData(@NotNull @NotNull java.util.Collection<java.lang.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(boolean, Collection)
-
convertOldData
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.String> convertOldData(@NotNull @NotNull java.lang.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(boolean, Collection)
-
convertOldData
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.String> convertOldData(boolean onlyTryOnce)
- 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(boolean, Collection)
-
convertOldData
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.String> convertOldData()
- Returns:
- a map of keys that failed to convert (key, value) or
nullif an error occurred (only returnsnullif 1.14+ fails) - See Also:
convertOldData(boolean, Collection)
-
-