2022-02-14 09:18:03 +00:00
|
|
|
package me.ryanhamshire.GriefPrevention.alttd.config;
|
|
|
|
|
|
2022-02-15 13:07:31 +00:00
|
|
|
import me.ryanhamshire.GriefPrevention.alttd.util.Logger;
|
|
|
|
|
|
2022-02-15 14:26:23 +00:00
|
|
|
import java.awt.*;
|
2022-02-15 13:07:31 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
2022-02-14 09:18:03 +00:00
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
2022-02-15 15:41:32 +00:00
|
|
|
public class Config extends AbstractConfig {
|
2022-02-14 09:18:03 +00:00
|
|
|
|
2022-02-15 15:41:32 +00:00
|
|
|
private Config() {
|
|
|
|
|
super("alttdconfig.yml");
|
2022-02-14 09:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-15 15:41:32 +00:00
|
|
|
static Config config;
|
2022-02-14 09:18:03 +00:00
|
|
|
static int version;
|
|
|
|
|
|
|
|
|
|
public static void reload() {
|
2022-02-15 15:41:32 +00:00
|
|
|
config = new Config();
|
2022-02-14 09:18:03 +00:00
|
|
|
|
|
|
|
|
version = config.getInt("config-version", 1);
|
|
|
|
|
config.set("config-version", 1);
|
|
|
|
|
|
2022-02-15 15:41:32 +00:00
|
|
|
config.readConfig(Config.class, null);
|
2022-02-15 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-14 09:18:03 +00:00
|
|
|
public static boolean DEBUG_MODE = false;
|
2022-02-15 13:07:31 +00:00
|
|
|
public static boolean alternativeClaimExpiring = false;
|
|
|
|
|
public static int alternativeClaimExpireDays = 1;
|
|
|
|
|
public static int expireCheckRate = 1200;
|
|
|
|
|
public static HashMap<Long, Long> expiringClaims = new HashMap<>();
|
2022-02-14 09:18:03 +00:00
|
|
|
private static void settings() {
|
2022-02-15 13:07:31 +00:00
|
|
|
String node = "alternative-claim-expiring";
|
2022-02-14 09:18:03 +00:00
|
|
|
DEBUG_MODE = config.getBoolean("debug-mode", DEBUG_MODE);
|
2022-02-15 13:07:31 +00:00
|
|
|
alternativeClaimExpiring = config.getBoolean(node + ".enabled", alternativeClaimExpiring);
|
|
|
|
|
alternativeClaimExpireDays = config.getInt(node + ".days", alternativeClaimExpireDays);
|
|
|
|
|
expireCheckRate = config.getInt(node + ".expire-check-rate", expireCheckRate);
|
|
|
|
|
// todo create an alternative way of loading these in
|
|
|
|
|
expiringClaims.clear();
|
2022-02-15 15:41:32 +00:00
|
|
|
config.getMap(node + ".claims", new HashMap<String, Long>())
|
|
|
|
|
.forEach((key, value) -> {
|
|
|
|
|
try {
|
|
|
|
|
expiringClaims.put(Long.parseLong(key), value);
|
|
|
|
|
} catch (NumberFormatException ignored) {}
|
|
|
|
|
});
|
2022-02-15 13:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addExpiringClaim(Long id) {
|
|
|
|
|
expiringClaims.put(id, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(alternativeClaimExpireDays));
|
|
|
|
|
config.set("alternative-claim-expiring.claims", expiringClaims);
|
2022-02-15 15:41:32 +00:00
|
|
|
try {
|
|
|
|
|
config.yaml.save(config.file);
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
Logger.severe("Could not save " + config.file.getName());
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
2022-02-14 09:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-15 14:26:23 +00:00
|
|
|
public static String CONTROL_LABEL = "GriefPrevention";
|
|
|
|
|
public static boolean CONTROL_SHOW = true;
|
|
|
|
|
public static boolean CONTROL_HIDE = false;
|
|
|
|
|
public static String GRID_CONTROL_LABEL = "Gridlines";
|
|
|
|
|
public static boolean GRID_CONTROL_SHOW = true;
|
|
|
|
|
public static boolean GRID_CONTROL_HIDE = true;
|
|
|
|
|
public static int UPDATE_INTERVAL = 300;
|
|
|
|
|
public static Color STROKE_COLOR = Color.GREEN;
|
|
|
|
|
public static int STROKE_WEIGHT = 1;
|
|
|
|
|
public static double STROKE_OPACITY = 1.0D;
|
|
|
|
|
public static Color FILL_COLOR = Color.GREEN;
|
|
|
|
|
public static double FILL_OPACITY = 0.2D;
|
|
|
|
|
|
2022-02-15 15:41:32 +00:00
|
|
|
public static Color ADMIN_STROKE_COLOR = Color.BLUE;
|
2022-02-15 14:26:23 +00:00
|
|
|
public static int ADMIN_STROKE_WEIGHT = 1;
|
|
|
|
|
public static double ADMIN_STROKE_OPACITY = 1.0D;
|
|
|
|
|
public static Color ADMIN_FILL_COLOR = Color.BLUE;
|
|
|
|
|
public static double ADMIN_FILL_OPACITY = 0.2D;
|
|
|
|
|
|
|
|
|
|
public static Color EXPIRING_STROKE_COLOR = Color.PINK;
|
|
|
|
|
public static int EXPIRING_STROKE_WEIGHT = 1;
|
|
|
|
|
public static double EXPIRING_STROKE_OPACITY = 1.0D;
|
|
|
|
|
public static Color EXPIRING_FILL_COLOR = Color.PINK;
|
|
|
|
|
public static double EXPIRING_FILL_OPACITY = 0.2D;
|
|
|
|
|
|
|
|
|
|
public static String STRINGS_PUBLIC = "Public";
|
|
|
|
|
public static String CLAIM_TOOLTIP = "Claim Owner: <span style=\"font-weight:bold;\">{owner}</span><br/>" +
|
|
|
|
|
"Permission Trust: <span style=\"font-weight:bold;\">{managers}</span><br/>" +
|
|
|
|
|
"Trust: <span style=\"font-weight:bold;\">{builders}</span><br/>" +
|
|
|
|
|
"Container Trust: <span style=\"font-weight:bold;\">{containers}</span><br/>" +
|
|
|
|
|
"Access Trust: <span style=\"font-weight:bold;\">{accessors}</span>";
|
|
|
|
|
public static String ADMIN_CLAIM_TOOLTIP = "<span style=\"font-weight:bold;\">Administrator Claim</span><br/>" +
|
|
|
|
|
"Permission Trust: <span style=\"font-weight:bold;\">{managers}</span><br/>" +
|
|
|
|
|
"Trust: <span style=\"font-weight:bold;\">{builders}</span><br/>" +
|
|
|
|
|
"Container Trust: <span style=\"font-weight:bold;\">{containers}</span><br/>" +
|
|
|
|
|
"Access Trust: <span style=\"font-weight:bold;\">{accessors}</span>";
|
|
|
|
|
public static String EXPIRING_CLAIM_TOOLTIP = "<span style=\"font-weight:bold;\">Temporary Claim</span><br/>" +
|
|
|
|
|
"Permission Trust: <span style=\"font-weight:bold;\">{managers}</span><br/>" +
|
|
|
|
|
"Trust: <span style=\"font-weight:bold;\">{builders}</span><br/>" +
|
|
|
|
|
"Container Trust: <span style=\"font-weight:bold;\">{containers}</span><br/>" +
|
|
|
|
|
"Access Trust: <span style=\"font-weight:bold;\">{accessors}</span><br/>" +
|
|
|
|
|
"Expires: <span style=\"font-weight:bold;\">{expiretime}</span>" ;
|
|
|
|
|
private static void mapSettings() {
|
|
|
|
|
CONTROL_LABEL = config.getString("settings.control.label", CONTROL_LABEL);
|
|
|
|
|
CONTROL_SHOW = config.getBoolean("settings.control.show", CONTROL_SHOW);
|
|
|
|
|
CONTROL_HIDE = config.getBoolean("settings.control.hide-by-default", CONTROL_HIDE);
|
|
|
|
|
GRID_CONTROL_LABEL = config.getString("settings.grid.label", GRID_CONTROL_LABEL);
|
|
|
|
|
GRID_CONTROL_SHOW = config.getBoolean("settings.grid.show", GRID_CONTROL_SHOW);
|
|
|
|
|
GRID_CONTROL_HIDE = config.getBoolean("settings.grid.hide-by-default", GRID_CONTROL_HIDE);
|
|
|
|
|
UPDATE_INTERVAL = config.getInt("settings.update-interval", UPDATE_INTERVAL);
|
|
|
|
|
|
|
|
|
|
STROKE_COLOR = config.getColor("settings.style.regular-claim.stroke.color", STROKE_COLOR);
|
|
|
|
|
STROKE_WEIGHT = config.getInt("settings.style.regular-claim.stroke.weight", STROKE_WEIGHT);
|
|
|
|
|
STROKE_OPACITY = config.getDouble("settings.regular-claim.style.stroke.opacity", STROKE_OPACITY);
|
|
|
|
|
FILL_COLOR = config.getColor("settings.style.regular-claim.fill.color", FILL_COLOR);
|
|
|
|
|
FILL_OPACITY = config.getDouble("settings.style.regular-claim.fill.opacity", FILL_OPACITY);
|
|
|
|
|
|
|
|
|
|
ADMIN_STROKE_COLOR = config.getColor("settings.style.admin-claim.stroke.color", ADMIN_STROKE_COLOR);
|
|
|
|
|
ADMIN_STROKE_WEIGHT = config.getInt("settings.style.admin-claim.stroke.weight", ADMIN_STROKE_WEIGHT);
|
|
|
|
|
ADMIN_STROKE_OPACITY = config.getDouble("settings.admin-claim.style.stroke.opacity", ADMIN_STROKE_OPACITY);
|
|
|
|
|
ADMIN_FILL_COLOR = config.getColor("settings.style.admin-claim.fill.color", ADMIN_FILL_COLOR);
|
|
|
|
|
ADMIN_FILL_OPACITY = config.getDouble("settings.style.admin-claim.fill.opacity", ADMIN_FILL_OPACITY);
|
|
|
|
|
|
|
|
|
|
EXPIRING_STROKE_COLOR = config.getColor("settings.style.expiring-claim.stroke.color", EXPIRING_STROKE_COLOR);
|
|
|
|
|
EXPIRING_STROKE_WEIGHT = config.getInt("settings.style.expiring-claim.stroke.weight", EXPIRING_STROKE_WEIGHT);
|
|
|
|
|
EXPIRING_STROKE_OPACITY = config.getDouble("settings.expiring-claim.style.stroke.opacity", EXPIRING_STROKE_OPACITY);
|
|
|
|
|
EXPIRING_FILL_COLOR = config.getColor("settings.style.expiring-claim.fill.color", EXPIRING_FILL_COLOR);
|
|
|
|
|
EXPIRING_FILL_OPACITY = config.getDouble("settings.style.expiring-claim.fill.opacity", EXPIRING_FILL_OPACITY);
|
|
|
|
|
|
|
|
|
|
STRINGS_PUBLIC = config.getString("settings.strings.public", STRINGS_PUBLIC);
|
|
|
|
|
CLAIM_TOOLTIP = config.getString("settings.region.tooltip.regular-claim", CLAIM_TOOLTIP);
|
|
|
|
|
ADMIN_CLAIM_TOOLTIP = config.getString("settings.region.tooltip.admin-claim", ADMIN_CLAIM_TOOLTIP);
|
|
|
|
|
EXPIRING_CLAIM_TOOLTIP = config.getString("settings.region.tooltip.expiring-claim", EXPIRING_CLAIM_TOOLTIP);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-15 14:31:04 +00:00
|
|
|
public static int ignoreClaimWarningDelay = 20 * 600;
|
|
|
|
|
public static String ignoreClaimWarningMessage = "<player> has had ignore claims on since <time>.";
|
|
|
|
|
public static String ignoreClaimWarningPermission = "griefprevention.ignoreclaimwarnings";
|
2022-02-15 19:41:45 +00:00
|
|
|
private static void miscSettings() {
|
2022-02-15 14:31:04 +00:00
|
|
|
ignoreClaimWarningDelay = config.getInt("settings.ignore-claim-warning-delay", ignoreClaimWarningDelay);
|
|
|
|
|
ignoreClaimWarningMessage = config.getString("settings.ignore-claim-warning-message", ignoreClaimWarningMessage);
|
|
|
|
|
ignoreClaimWarningPermission = config.getString("settings.ignore-claim-warning-permission", ignoreClaimWarningPermission);
|
|
|
|
|
}
|
2022-02-15 19:41:45 +00:00
|
|
|
|
2022-02-15 20:13:15 +00:00
|
|
|
public static HashMap<Integer, Double> claimBlockPrices = new HashMap<>();
|
|
|
|
|
public static void claimBlockSettings() {
|
|
|
|
|
claimBlockPrices.clear();
|
|
|
|
|
config.getMap( "claimblock-prices", new HashMap<String, Double>(){{
|
|
|
|
|
put("0", .25);
|
|
|
|
|
put("501", .5);
|
|
|
|
|
put("10001", .75);
|
|
|
|
|
put("50001", 1.00);
|
|
|
|
|
put("300001", 2.00);
|
|
|
|
|
put("1000001", 5.00);
|
|
|
|
|
}})
|
|
|
|
|
.forEach((key, value) -> {
|
|
|
|
|
try {
|
|
|
|
|
claimBlockPrices.put(Integer.parseInt(key), value);
|
|
|
|
|
} catch (NumberFormatException ignored) {}
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-02-14 09:18:03 +00:00
|
|
|
}
|