HolographicDisplays/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/config/SettingsModel.java

132 lines
3.8 KiB
Java
Raw Normal View History

/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
2021-07-31 17:28:19 +02:00
package me.filoghost.holographicdisplays.plugin.config;
import me.filoghost.fcommons.config.Config;
import me.filoghost.fcommons.config.mapped.MappedConfig;
2021-06-20 12:41:52 +02:00
import me.filoghost.fcommons.config.mapped.Path;
2021-09-14 23:33:34 +02:00
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
2021-06-24 17:38:38 +02:00
public class SettingsModel implements MappedConfig {
2021-06-20 17:23:48 +02:00
2021-03-11 20:54:49 +01:00
@Path("space-between-lines")
double spaceBetweenLines = 0.02;
2021-06-20 17:23:48 +02:00
2022-11-13 16:29:25 +01:00
@Path("holograms-view-range")
int viewRange = 48;
2021-03-11 20:54:49 +01:00
@Path("quick-edit-commands")
boolean quickEditCommands = true;
2021-06-20 17:23:48 +02:00
@Path("placeholders.PlaceholderAPI.enabled")
boolean placeholderAPIEnabled = true;
@Path("placeholders.PlaceholderAPI.default-refresh-interval-ticks")
int placeholderAPIDefaultRefreshIntervalTicks = 200;
2021-07-11 11:49:41 +02:00
@Path("image-rendering.solid-pixel")
2022-12-04 15:06:40 +01:00
String imageRenderingSolidPixel = "\u2588";
2021-06-20 17:23:48 +02:00
2021-07-11 11:49:41 +02:00
@Path("image-rendering.transparent-pixel")
2022-12-04 15:06:40 +01:00
String imageRenderingTransparentPixel = "&7 \u23B9 ";
2021-06-20 17:23:48 +02:00
2021-03-11 20:54:49 +01:00
@Path("bungee.refresh-seconds")
int bungeeRefreshSeconds = 3;
2021-03-11 20:54:49 +01:00
@Path("bungee.use-RedisBungee")
boolean useRedisBungee = false;
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.enable")
boolean pingerEnable = false;
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.timeout")
int pingerTimeout = 500;
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.offline-motd")
String pingerOfflineMotd = "&cOffline, couldn't get the MOTD";
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.status.online")
String pingerStatusOnline = "&aOnline";
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.status.offline")
String pingerStatusOffline = "&cOffline";
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.motd-remove-leading-trailing-spaces")
boolean pingerTrimMotd = true;
2021-03-11 20:54:49 +01:00
@Path("bungee.pinger.servers")
List<String> pingerServers = Arrays.asList("hub: 127.0.0.1:25565", "games: 127.0.0.1:25566");
2021-03-11 20:54:49 +01:00
@Path("time.format")
String timeFormat = "H:mm";
2021-03-11 20:54:49 +01:00
@Path("time.zone")
String timeZone = "GMT+1";
2021-06-20 17:23:48 +02:00
2021-03-11 20:54:49 +01:00
@Path("update-notification")
boolean updateNotification = true;
2021-03-11 20:54:49 +01:00
@Path("debug")
boolean debug = false;
2021-06-20 17:23:48 +02:00
@Override
2021-09-14 23:33:34 +02:00
public @NotNull List<String> getHeader() {
return Arrays.asList(
"",
"Plugin page: https://dev.bukkit.org/projects/holographic-displays",
"",
"Created by filoghost.",
""
);
}
@Override
2021-07-11 11:49:41 +02:00
public boolean beforeLoad(Config rawConfig) {
boolean modified = false;
if (rawConfig.contains("images") && !rawConfig.contains("image-rendering")) {
String oldTransparencyColor = rawConfig.getString("images.transparency.color");
String oldTransparencySpace = rawConfig.getString("images.transparency.space");
String oldSolidSymbol = rawConfig.getString("images.symbol");
if (oldTransparencyColor != null && oldTransparencySpace != null) {
rawConfig.setString("image-rendering.transparent-pixel", oldTransparencyColor + oldTransparencySpace);
modified = true;
}
if (oldSolidSymbol != null) {
rawConfig.setString("image-rendering.solid-pixel", oldSolidSymbol);
modified = true;
}
}
List<String> pathsToRemove = Arrays.asList(
"vertical-spacing",
"time-format",
"bungee-refresh-seconds",
"using-RedisBungee",
"bungee-online-format",
"bungee-offline-format",
2021-07-10 16:11:32 +02:00
"precise-hologram-movement",
2021-07-11 11:49:41 +02:00
"images"
);
2021-06-20 17:23:48 +02:00
for (String path : pathsToRemove) {
2021-07-11 11:49:41 +02:00
if (rawConfig.contains(path)) {
rawConfig.remove(path);
modified = true;
}
}
2021-06-20 17:23:48 +02:00
return modified;
}
}