|
|
|
|
@@ -1,8 +1,8 @@
|
|
|
|
|
package de.oliver.fancyholograms;
|
|
|
|
|
|
|
|
|
|
import com.fancyinnovations.config.ConfigHelper;
|
|
|
|
|
import de.oliver.fancyholograms.api.FancyHologramsPlugin;
|
|
|
|
|
import de.oliver.fancyholograms.api.HologramConfiguration;
|
|
|
|
|
import de.oliver.fancylib.ConfigHelper;
|
|
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
|
|
@@ -17,65 +17,17 @@ import java.util.Map;
|
|
|
|
|
*/
|
|
|
|
|
public final class FancyHologramsConfiguration implements HologramConfiguration {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether autosave is enabled.
|
|
|
|
|
*/
|
|
|
|
|
private boolean autosaveEnabled;
|
|
|
|
|
private static final String CONFIG_AUTOSAVE_ENABLED = "saving.autosave.enabled";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The interval at which autosave is performed.
|
|
|
|
|
*/
|
|
|
|
|
private int autosaveInterval;
|
|
|
|
|
private static final String CONFIG_AUTOSAVE_INTERVAL = "saving.autosave.interval";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether the plugin should save holograms when they are changed.
|
|
|
|
|
*/
|
|
|
|
|
private boolean saveOnChangedEnabled;
|
|
|
|
|
private static final String CONFIG_SAVE_ON_CHANGED = "saving.save_on_changed";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The log level for the plugin.
|
|
|
|
|
*/
|
|
|
|
|
private String logLevel;
|
|
|
|
|
private static final String CONFIG_LOG_LEVEL = "logging.log_level";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether hologram loading should be logged on world loading.
|
|
|
|
|
*/
|
|
|
|
|
private boolean hologramLoadLogging;
|
|
|
|
|
private static final String CONFIG_LOG_ON_WORLD_LOAD = "logging.log_on_world_load";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether version notifications are enabled or disabled.
|
|
|
|
|
*/
|
|
|
|
|
private boolean versionNotifs;
|
|
|
|
|
private static final String CONFIG_VERSION_NOTIFICATIONS = "logging.version_notifications";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The default visibility distance for holograms.
|
|
|
|
|
*/
|
|
|
|
|
private int defaultVisibilityDistance;
|
|
|
|
|
private static final String CONFIG_VISIBILITY_DISTANCE = "visibility_distance";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether commands should be registered.
|
|
|
|
|
* <p>
|
|
|
|
|
* This is useful for users who want to use the plugin's API only.
|
|
|
|
|
*/
|
|
|
|
|
private boolean registerCommands;
|
|
|
|
|
private static final String CONFIG_REGISTER_COMMANDS = "register_commands";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The interval at which hologram visibility is updated.
|
|
|
|
|
*/
|
|
|
|
|
private int updateVisibilityInterval;
|
|
|
|
|
private static final String CONFIG_UPDATE_VISIBILITY_INTERVAL = "update_visibility_interval";
|
|
|
|
|
|
|
|
|
|
private static final String CONFIG_REPORT_ERRORS_TO_SENTRY = "report_errors_to_sentry";
|
|
|
|
|
private static final String CONFIG_VERSION = "config_version";
|
|
|
|
|
|
|
|
|
|
private static final Map<String, List<String>> CONFIG_COMMENTS = Map.of(
|
|
|
|
|
CONFIG_VERSION, List.of("Config version, do not modify."),
|
|
|
|
|
CONFIG_AUTOSAVE_ENABLED, List.of("Whether autosave is enabled."),
|
|
|
|
|
@@ -88,12 +40,50 @@ public final class FancyHologramsConfiguration implements HologramConfiguration
|
|
|
|
|
CONFIG_REGISTER_COMMANDS, List.of("Whether the plugin should register its commands."),
|
|
|
|
|
CONFIG_UPDATE_VISIBILITY_INTERVAL, List.of("The interval at which hologram visibility is updated in ticks.")
|
|
|
|
|
);
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether autosave is enabled.
|
|
|
|
|
*/
|
|
|
|
|
private boolean autosaveEnabled;
|
|
|
|
|
/**
|
|
|
|
|
* The interval at which autosave is performed.
|
|
|
|
|
*/
|
|
|
|
|
private int autosaveInterval;
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether the plugin should save holograms when they are changed.
|
|
|
|
|
*/
|
|
|
|
|
private boolean saveOnChangedEnabled;
|
|
|
|
|
/**
|
|
|
|
|
* The log level for the plugin.
|
|
|
|
|
*/
|
|
|
|
|
private String logLevel;
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether hologram loading should be logged on world loading.
|
|
|
|
|
*/
|
|
|
|
|
private boolean hologramLoadLogging;
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether version notifications are enabled or disabled.
|
|
|
|
|
*/
|
|
|
|
|
private boolean versionNotifs;
|
|
|
|
|
/**
|
|
|
|
|
* The default visibility distance for holograms.
|
|
|
|
|
*/
|
|
|
|
|
private int defaultVisibilityDistance;
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether commands should be registered.
|
|
|
|
|
* <p>
|
|
|
|
|
* This is useful for users who want to use the plugin's API only.
|
|
|
|
|
*/
|
|
|
|
|
private boolean registerCommands;
|
|
|
|
|
/**
|
|
|
|
|
* The interval at which hologram visibility is updated.
|
|
|
|
|
*/
|
|
|
|
|
private int updateVisibilityInterval;
|
|
|
|
|
|
|
|
|
|
private void updateChecker(@NotNull FancyHolograms plugin, @NotNull FileConfiguration config) {
|
|
|
|
|
final int latestVersion = 1;
|
|
|
|
|
int configVersion = (int) ConfigHelper.getOrDefault(config, CONFIG_VERSION, 0);
|
|
|
|
|
|
|
|
|
|
if (configVersion >= latestVersion ) {
|
|
|
|
|
if (configVersion >= latestVersion) {
|
|
|
|
|
setOptions(config);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|