Class JSONStorage

    • Field Detail

      • GSON

        protected static final com.google.gson.Gson GSON
      • PARSER

        protected static final com.google.gson.JsonParser PARSER
    • Constructor Detail

      • JSONStorage

        public JSONStorage()
    • Method Detail

      • initialize

        public boolean initialize()
        Description copied from interface: DataStorage
        在插件加载存储源时执行。
        Specified by:
        initialize in interface DataStorage
        Returns:
        是否初始化成功
      • shutdown

        public void shutdown()
        Description copied from interface: DataStorage
        在插件被卸载时执行。
        Specified by:
        shutdown in interface DataStorage
      • 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:
        loadData in interface DataStorage
        Parameters:
        uuid - 用户UUID
        Throws:
        java.lang.Exception - 当出现任何错误时抛出
      • saveUserData

        public void saveUserData​(@NotNull
                                 @NotNull UserData data)
                          throws java.lang.Exception
        Description copied from interface: DataStorage
        用于保存用户数据的方法。 该方法将会被异步运行!
        该方法一般无需自行执行,见 UserManager.saveData(UserData)
        Specified by:
        saveUserData in interface DataStorage
        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)