Class JSONStorage
- java.lang.Object
-
- cc.carm.plugin.ultradepository.storage.impl.JSONStorage
-
- All Implemented Interfaces:
DataStorage
- Direct Known Subclasses:
MySQLStorage
public class JSONStorage extends java.lang.Object implements DataStorage
-
-
Constructor Summary
Constructors Constructor Description JSONStorage()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FilegetDataContainer()booleaninitialize()在插件加载存储源时执行。@Nullable UserDataloadData(@NotNull java.util.UUID uuid)用于加载用户数据的方法。static voidloadDepositoriesInto(UserData data, com.google.gson.JsonElement depositoriesElement)static DepositoryDataparseContentsData(@NotNull Depository source, @NotNull UserData owner, @NotNull com.google.gson.JsonElement contentsElement)static DepositoryItemDataparseItemData(@NotNull DepositoryItem source, @NotNull DepositoryData owner, @NotNull com.google.gson.JsonElement itemElement)static com.google.gson.JsonElementsaveDepositoriesToJson(UserData data)voidsaveUserData(@NotNull UserData data)用于保存用户数据的方法。static java.lang.StringserializeDepositories(UserData data)voidshutdown()在插件被卸载时执行。
-
-
-
Method Detail
-
initialize
public boolean initialize()
Description copied from interface:DataStorage在插件加载存储源时执行。- Specified by:
initializein interfaceDataStorage- Returns:
- 是否初始化成功
-
shutdown
public void shutdown()
Description copied from interface:DataStorage在插件被卸载时执行。- Specified by:
shutdownin interfaceDataStorage
-
getDataContainer
public java.io.File getDataContainer()
-
loadData
@Nullable public @Nullable UserData loadData(@NotNull @NotNull java.util.UUID uuid) throws java.lang.Exception
Description copied from interface:DataStorage用于加载用户数据的方法。该方法将会被异步运行!
该方法一般无需自行执行,见UserManager.loadData(UUID)
若不存在该用户的数据,请返回 null 。
若加载出现任何错误,请抛出异常。- Specified by:
loadDatain interfaceDataStorage- Parameters:
uuid- 用户UUID- Throws:
java.lang.Exception- 当出现任何错误时抛出
-
saveUserData
public void saveUserData(@NotNull @NotNull UserData data) throws java.lang.ExceptionDescription copied from interface:DataStorage用于保存用户数据的方法。 该方法将会被异步运行!
该方法一般无需自行执行,见UserManager.saveData(UserData)- Specified by:
saveUserDatain interfaceDataStorage- Parameters:
data- 用户数据- Throws:
java.lang.Exception- 当出现任何错误时抛出
-
saveDepositoriesToJson
public static com.google.gson.JsonElement saveDepositoriesToJson(UserData data)
-
serializeDepositories
public static java.lang.String serializeDepositories(UserData data)
-
loadDepositoriesInto
public static void loadDepositoriesInto(UserData data, com.google.gson.JsonElement depositoriesElement)
-
parseContentsData
public static DepositoryData parseContentsData(@NotNull @NotNull Depository source, @NotNull @NotNull UserData owner, @NotNull @NotNull com.google.gson.JsonElement contentsElement)
-
parseItemData
public static DepositoryItemData parseItemData(@NotNull @NotNull DepositoryItem source, @NotNull @NotNull DepositoryData owner, @NotNull @NotNull com.google.gson.JsonElement itemElement)
-
-