Search in sources :

Example 6 with StatType

use of com.gmail.stefvanschiedev.buildinggame.utils.stats.StatType in project buildinggame by stefvanschie.

the class TopStatHologram method load.

/**
 * Loads a single top stat hologram from a json reader. It is assumed the json reader is directly before the first
 * opening brace of the object.
 *
 * @param reader the json reader to read from
 * @since 6.2.0
 */
@Contract("null -> fail")
public static void load(@NotNull JsonReader reader) throws IOException {
    reader.beginObject();
    String name = null;
    StatType type = null;
    var values = 0;
    Location location = null;
    while (reader.hasNext()) {
        switch(reader.nextName()) {
            case "name":
                name = reader.nextString();
                break;
            case "type":
                type = StatType.valueOf(reader.nextString());
                break;
            case "values":
                values = reader.nextInt();
                break;
            case "location":
                location = JsonReaderUtil.parseLocation(reader);
                break;
            default:
                break;
        }
    }
    new TopStatHologram(name, type, values, location).register();
    reader.endObject();
}
Also used : StatType(com.gmail.stefvanschiedev.buildinggame.utils.stats.StatType) Location(org.bukkit.Location) Contract(org.jetbrains.annotations.Contract)

Aggregations

StatType (com.gmail.stefvanschiedev.buildinggame.utils.stats.StatType)6 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)5 OfflinePlayer (org.bukkit.OfflinePlayer)3 Contract (org.jetbrains.annotations.Contract)3 Main (com.gmail.stefvanschiedev.buildinggame.Main)2 SettingsManager (com.gmail.stefvanschiedev.buildinggame.managers.files.SettingsManager)2 Achievement (com.gmail.stefvanschiedev.buildinggame.utils.Achievement)2 TopStatHologram (com.gmail.stefvanschiedev.buildinggame.utils.TopStatHologram)2 Stat (com.gmail.stefvanschiedev.buildinggame.utils.stats.Stat)2 java.util (java.util)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Bukkit (org.bukkit.Bukkit)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 Location (org.bukkit.Location)1 EventHandler (org.bukkit.event.EventHandler)1