Class JsonFile

java.lang.Object
org.bukkit.configuration.MemorySection
org.bukkit.configuration.MemoryConfiguration
org.bukkit.configuration.file.FileConfiguration
org.bukkit.configuration.file.YamlConfiguration
valorless.valorlessutils.file.FileStorage
valorless.valorlessutils.file.JsonFile
All Implemented Interfaces:
org.bukkit.configuration.Configuration, org.bukkit.configuration.ConfigurationSection

public class JsonFile extends FileStorage
  • Field Summary

    Fields inherited from class org.bukkit.configuration.file.YamlConfiguration

    BLANK_CONFIG, COMMENT_PREFIX

    Fields inherited from class org.bukkit.configuration.MemoryConfiguration

    defaults, options

    Fields inherited from class org.bukkit.configuration.MemorySection

    map
  • Constructor Summary

    Constructors
    Constructor
    Description
    JsonFile(org.bukkit.plugin.java.JavaPlugin plugin, File file)
    Constructor for JsonFile class.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    readObject(Class<T> clazz)
    Reads an object from the JSON file.
    void
    setGson(com.google.gson.Gson gson)
    Sets a custom Gson instance.
    void
    Writes an object to the JSON file.

    Methods inherited from class valorless.valorlessutils.file.FileStorage

    createFile, deleteFile, fileExists, getFile, loadConfiguration

    Methods inherited from class org.bukkit.configuration.file.YamlConfiguration

    loadConfiguration, loadFromString, options, saveToString

    Methods inherited from class org.bukkit.configuration.file.FileConfiguration

    buildHeader, load, load, load, save, save

    Methods inherited from class org.bukkit.configuration.MemoryConfiguration

    addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults

    Methods inherited from class org.bukkit.configuration.MemorySection

    contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, setComments, setInlineComments, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.configuration.ConfigurationSection

    contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, set, setComments, setInlineComments
  • Constructor Details

    • JsonFile

      public JsonFile(org.bukkit.plugin.java.JavaPlugin plugin, File file)
      Constructor for JsonFile class.
      Parameters:
      file - The File object representing the JSON file.
  • Method Details

    • setGson

      public void setGson(com.google.gson.Gson gson)
      Sets a custom Gson instance.
      Parameters:
      gson - The Gson instance to set.
    • writeObject

      public void writeObject(Object object)
      Writes an object to the JSON file.
      Parameters:
      object - The object to write.
    • readObject

      public <T> T readObject(Class<T> clazz)
      Reads an object from the JSON file.
      Type Parameters:
      T - The type of the object.
      Parameters:
      clazz - The class of the object to read.
      Returns:
      The read object or null if the file doesn't exist.