Skip to content

Configuration with Annotations

Dawson edited this page May 29, 2019 · 1 revision

This is a feature that will allow you to have inline calls to get from the config when the scanner is run.

Important Things to Know

  • This utility only works for the default Bukkit config.yml file using its system.
  • This does not actively update the field when there are changes in the config.yml. You must run the scanner again to update any changes register by Bukkit.
  • It is recommended you treat fields using this as though they're labeled with a final modifier.
  • Modifying to the field does not make it write the changes to the config.

@ConfigSettings Annotation Properties

Parameter Example Usage
path() "beans.jelly", "beans.natural" Defines the section where the config settings would be.
value()

Example

package cc.funkemunky.anticheat.api.data.logging;

# TODO: Finish

import cc.funkemunky.anticheat.Kauri;
import cc.funkemunky.anticheat.api.checks.Check;
import cc.funkemunky.api.Atlas;
import cc.funkemunky.api.database.Database;
import cc.funkemunky.api.database.DatabaseType;
import cc.funkemunky.api.utils.ConfigSetting;
import cc.funkemunky.api.utils.Init;
import cc.funkemunky.api.utils.Priority;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

@Init(priority = Priority.HIGH)
public class LoggerManager {
    @Getter
    private Map<UUID, Map<String, Integer>> violations = new ConcurrentHashMap<>();
    ;

    @ConfigSetting(path = "data.logging", name = "type")
    public String type = "FLATFILE";

    public LoggerManager() {
        Atlas.getInstance().getDatabaseManager().createDatabase("KauriLogs", DatabaseType.valueOf(type));
    }
}