Remove configurate
This commit is contained in:
parent
0583968f67
commit
d0e8cfe3f8
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
package me.ryanhamshire.GriefPrevention;
|
package me.ryanhamshire.GriefPrevention;
|
||||||
|
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.config.AlttdConfig;
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
||||||
import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent;
|
import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
@ -95,7 +95,7 @@ class CleanupUnusedClaimTask implements Runnable
|
||||||
//make a copy of this player's claim list
|
//make a copy of this player's claim list
|
||||||
Vector<Claim> claims = new Vector<>(ownerData.getClaims());
|
Vector<Claim> claims = new Vector<>(ownerData.getClaims());
|
||||||
// Alternative logic for deleting claims
|
// Alternative logic for deleting claims
|
||||||
if(AlttdConfig.alternativeClaimExpiring) {
|
if(Config.alternativeClaimExpiring) {
|
||||||
for (Claim claim : claims)
|
for (Claim claim : claims)
|
||||||
{
|
{
|
||||||
// remove all subclaims a claim has
|
// remove all subclaims a claim has
|
||||||
|
|
@ -109,7 +109,7 @@ class CleanupUnusedClaimTask implements Runnable
|
||||||
claim.setPermission("public", ClaimPermission.Build);
|
claim.setPermission("public", ClaimPermission.Build);
|
||||||
// make the claim an (expiring) admin claim
|
// make the claim an (expiring) admin claim
|
||||||
GriefPrevention.instance.dataStore.changeClaimOwner(claim, null);
|
GriefPrevention.instance.dataStore.changeClaimOwner(claim, null);
|
||||||
AlttdConfig.addExpiringClaim(claim.id);
|
Config.addExpiringClaim(claim.id);
|
||||||
}
|
}
|
||||||
GriefPrevention.AddLogEntry(" All of " + claim.getOwnerName() + "'s claims have expired and converted to a temp claim.", CustomLogEntryTypes.AdminActivity);
|
GriefPrevention.AddLogEntry(" All of " + claim.getOwnerName() + "'s claims have expired and converted to a temp claim.", CustomLogEntryTypes.AdminActivity);
|
||||||
GriefPrevention.AddLogEntry("earliestPermissibleLastLogin#getTime: " + earliestPermissibleLastLogin.getTime(), CustomLogEntryTypes.Debug, true);
|
GriefPrevention.AddLogEntry("earliestPermissibleLastLogin#getTime: " + earliestPermissibleLastLogin.getTime(), CustomLogEntryTypes.Debug, true);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,175 @@
|
||||||
|
package me.ryanhamshire.GriefPrevention.alttd.config;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
|
import me.ryanhamshire.GriefPrevention.alttd.util.Logger;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "SameParameterValue"})
|
||||||
|
abstract class AbstractConfig {
|
||||||
|
File file;
|
||||||
|
YamlConfiguration yaml;
|
||||||
|
File configPath;
|
||||||
|
|
||||||
|
AbstractConfig(String filename) {
|
||||||
|
this.configPath = GriefPrevention.instance.getDataFolder();
|
||||||
|
this.file = new File(configPath, filename);
|
||||||
|
this.yaml = new YamlConfiguration();
|
||||||
|
if (!this.file.getParentFile().exists()) {
|
||||||
|
if(!this.file.getParentFile().mkdirs()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
yaml.load(file);
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
} catch (InvalidConfigurationException ex) {
|
||||||
|
Logger.severe(String.format("Could not load %s, please correct your syntax errors", filename));
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
yaml.options().copyDefaults(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void readConfig(Class<?> clazz, Object instance) {
|
||||||
|
for (Method method : clazz.getDeclaredMethods()) {
|
||||||
|
if (Modifier.isPrivate(method.getModifiers())) {
|
||||||
|
if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
|
||||||
|
try {
|
||||||
|
method.setAccessible(true);
|
||||||
|
method.invoke(instance);
|
||||||
|
} catch (InvocationTargetException ex) {
|
||||||
|
throw new RuntimeException(ex.getCause());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.severe("Error invoking " + method);
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
yaml.save(file);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Logger.severe("Could not save " + file);
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(String path, Object val) {
|
||||||
|
yaml.addDefault(path, val);
|
||||||
|
yaml.addDefault(path, val);
|
||||||
|
yaml.set(path, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getString(String path, String def) {
|
||||||
|
yaml.addDefault(path, def);
|
||||||
|
return yaml.getString(path, yaml.getString(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getBoolean(String path, boolean def) {
|
||||||
|
yaml.addDefault(path, def);
|
||||||
|
return yaml.getBoolean(path, yaml.getBoolean(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
int getInt(String path, int def) {
|
||||||
|
yaml.addDefault(path, def);
|
||||||
|
return yaml.getInt(path, yaml.getInt(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
double getDouble(String path, double def) {
|
||||||
|
yaml.addDefault(path, def);
|
||||||
|
return yaml.getDouble(path, yaml.getDouble(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
<T> List<?> getList(String path, T def) {
|
||||||
|
yaml.addDefault(path, def);
|
||||||
|
return yaml.getList(path, yaml.getList(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
<T> Map<String, T> getMap(final @NonNull String path, final @Nullable Map<String, T> def) {
|
||||||
|
final ImmutableMap.Builder<String, T> builder = ImmutableMap.builder();
|
||||||
|
if (def != null && yaml.getConfigurationSection(path) == null) {
|
||||||
|
yaml.addDefault(path, def.isEmpty() ? new HashMap<>() : def);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
final ConfigurationSection section = yaml.getConfigurationSection(path);
|
||||||
|
if (section != null) {
|
||||||
|
for (String key : section.getKeys(false)) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final T val = (T) section.get(key);
|
||||||
|
if (val != null) {
|
||||||
|
builder.put(key, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack getItemStack(String path, ItemStack def) {
|
||||||
|
yaml.addDefault(path, def);
|
||||||
|
return yaml.getItemStack(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLocations(String path, ArrayList<Location> locs) {
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
for(Location l : locs) {
|
||||||
|
String toSave = l.getWorld().getName() + ":" + l.getX() + ":" + l.getY() + ":" + l.getZ();
|
||||||
|
list.add(toSave);
|
||||||
|
}
|
||||||
|
yaml.set(path, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Location> getLocations(String path){
|
||||||
|
List<String> attempts = yaml.getStringList(path);
|
||||||
|
|
||||||
|
if (attempts == null || attempts.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<Location> locations = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String attempt : attempts) {
|
||||||
|
String[] parts = attempt.split(":");
|
||||||
|
locations.add(new Location(Bukkit.getWorld(parts[0]), Double.parseDouble(parts[1]), Double.parseDouble(parts[2]), Double.parseDouble(parts[3])));
|
||||||
|
}
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getColor(String path, Color def) {
|
||||||
|
yaml.addDefault(path, colorToHex(def));
|
||||||
|
return hexToColor(yaml.getString(path, yaml.getString(path)));
|
||||||
|
}
|
||||||
|
|
||||||
|
String colorToHex(final Color color) {
|
||||||
|
return Integer.toHexString(color.getRGB() & 0x00FFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color hexToColor(final String hex) {
|
||||||
|
if (hex == null) {
|
||||||
|
return Color.RED;
|
||||||
|
}
|
||||||
|
String stripped = hex.replace("#", "");
|
||||||
|
int rgb = (int) Long.parseLong(stripped, 16);
|
||||||
|
return new Color(rgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,66 +1,29 @@
|
||||||
package me.ryanhamshire.GriefPrevention.alttd.config;
|
package me.ryanhamshire.GriefPrevention.alttd.config;
|
||||||
|
|
||||||
import com.alttd.galaxy.configuration.AbstractConfiguration;
|
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.util.Logger;
|
import me.ryanhamshire.GriefPrevention.alttd.util.Logger;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class AlttdConfig extends AbstractConfiguration
|
public class Config extends AbstractConfig {
|
||||||
{
|
|
||||||
|
|
||||||
private AlttdConfig() {
|
private Config() {
|
||||||
super(GriefPrevention.instance.getDataFolder(),"alttdconfig.yml");
|
super("alttdconfig.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
static AlttdConfig config;
|
static Config config;
|
||||||
static int version;
|
static int version;
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
config = new AlttdConfig();
|
config = new Config();
|
||||||
|
|
||||||
version = config.getInt("config-version", 1);
|
version = config.getInt("config-version", 1);
|
||||||
config.set("config-version", 1);
|
config.set("config-version", 1);
|
||||||
|
|
||||||
config.readConfig(AlttdConfig.class, null);
|
config.readConfig(Config.class, null);
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<Long, Long> getMap(String path, HashMap<Long, Long> def) {
|
|
||||||
set(path, def);
|
|
||||||
ConfigurationNode node = config.getNode(path);
|
|
||||||
HashMap<Long, Long> map = new HashMap<>();
|
|
||||||
for (Map.Entry<Object, ? extends ConfigurationNode> entry : node.childrenMap().entrySet()) {
|
|
||||||
try {
|
|
||||||
map.put(Long.parseLong(entry.getKey().toString()), Long.parseLong(entry.getValue().getString()));
|
|
||||||
} catch (NumberFormatException exception) {
|
|
||||||
// handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getColor(String path, Color def) {
|
|
||||||
config.set(path, colorToHex(def));
|
|
||||||
return hexToColor(config.getString(path, colorToHex(def)));
|
|
||||||
}
|
|
||||||
|
|
||||||
String colorToHex(final Color color) {
|
|
||||||
return Integer.toHexString(color.getRGB() & 0x00FFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
Color hexToColor(final String hex) {
|
|
||||||
if (hex == null) {
|
|
||||||
return Color.RED;
|
|
||||||
}
|
|
||||||
String stripped = hex.replace("#", "");
|
|
||||||
int rgb = (int) Long.parseLong(stripped, 16);
|
|
||||||
return new Color(rgb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean DEBUG_MODE = false;
|
public static boolean DEBUG_MODE = false;
|
||||||
|
|
@ -76,18 +39,23 @@ public class AlttdConfig extends AbstractConfiguration
|
||||||
expireCheckRate = config.getInt(node + ".expire-check-rate", expireCheckRate);
|
expireCheckRate = config.getInt(node + ".expire-check-rate", expireCheckRate);
|
||||||
// todo create an alternative way of loading these in
|
// todo create an alternative way of loading these in
|
||||||
expiringClaims.clear();
|
expiringClaims.clear();
|
||||||
config.getMap(node + ".claims", new HashMap<>())
|
config.getMap(node + ".claims", new HashMap<String, Long>())
|
||||||
.forEach((key, value) -> {
|
.forEach((key, value) -> {
|
||||||
try {
|
try {
|
||||||
expiringClaims.put(Long.parseLong(key.toString()), value);
|
expiringClaims.put(Long.parseLong(key), value);
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addExpiringClaim(Long id) {
|
public static void addExpiringClaim(Long id) {
|
||||||
expiringClaims.put(id, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(alternativeClaimExpireDays));
|
expiringClaims.put(id, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(alternativeClaimExpireDays));
|
||||||
config.set("alternative-claim-expiring.claims", expiringClaims);
|
config.set("alternative-claim-expiring.claims", expiringClaims);
|
||||||
config.saveConfig();
|
try {
|
||||||
|
config.yaml.save(config.file);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Logger.severe("Could not save " + config.file.getName());
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String CONTROL_LABEL = "GriefPrevention";
|
public static String CONTROL_LABEL = "GriefPrevention";
|
||||||
|
|
@ -103,7 +71,7 @@ public class AlttdConfig extends AbstractConfiguration
|
||||||
public static Color FILL_COLOR = Color.GREEN;
|
public static Color FILL_COLOR = Color.GREEN;
|
||||||
public static double FILL_OPACITY = 0.2D;
|
public static double FILL_OPACITY = 0.2D;
|
||||||
|
|
||||||
public static Color ADMIN_STROKE_COLOR = Color.BLUE;
|
public static Color ADMIN_STROKE_COLOR = Color.BLUE;
|
||||||
public static int ADMIN_STROKE_WEIGHT = 1;
|
public static int ADMIN_STROKE_WEIGHT = 1;
|
||||||
public static double ADMIN_STROKE_OPACITY = 1.0D;
|
public static double ADMIN_STROKE_OPACITY = 1.0D;
|
||||||
public static Color ADMIN_FILL_COLOR = Color.BLUE;
|
public static Color ADMIN_FILL_COLOR = Color.BLUE;
|
||||||
|
|
@ -168,10 +136,9 @@ public class AlttdConfig extends AbstractConfiguration
|
||||||
public static int ignoreClaimWarningDelay = 20 * 600;
|
public static int ignoreClaimWarningDelay = 20 * 600;
|
||||||
public static String ignoreClaimWarningMessage = "<player> has had ignore claims on since <time>.";
|
public static String ignoreClaimWarningMessage = "<player> has had ignore claims on since <time>.";
|
||||||
public static String ignoreClaimWarningPermission = "griefprevention.ignoreclaimwarnings";
|
public static String ignoreClaimWarningPermission = "griefprevention.ignoreclaimwarnings";
|
||||||
public static void ignoreClaimSettings() {
|
public static void miscSettings() {
|
||||||
ignoreClaimWarningDelay = config.getInt("settings.ignore-claim-warning-delay", ignoreClaimWarningDelay);
|
ignoreClaimWarningDelay = config.getInt("settings.ignore-claim-warning-delay", ignoreClaimWarningDelay);
|
||||||
ignoreClaimWarningMessage = config.getString("settings.ignore-claim-warning-message", ignoreClaimWarningMessage);
|
ignoreClaimWarningMessage = config.getString("settings.ignore-claim-warning-message", ignoreClaimWarningMessage);
|
||||||
ignoreClaimWarningPermission = config.getString("settings.ignore-claim-warning-permission", ignoreClaimWarningPermission);
|
ignoreClaimWarningPermission = config.getString("settings.ignore-claim-warning-permission", ignoreClaimWarningPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package me.ryanhamshire.GriefPrevention.alttd.hook;
|
package me.ryanhamshire.GriefPrevention.alttd.hook;
|
||||||
|
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.config.AlttdConfig;
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.tasks.Pl3xMapTask;
|
import me.ryanhamshire.GriefPrevention.alttd.tasks.Pl3xMapTask;
|
||||||
import net.pl3x.map.api.Key;
|
import net.pl3x.map.api.Key;
|
||||||
import net.pl3x.map.api.Pl3xMapProvider;
|
import net.pl3x.map.api.Pl3xMapProvider;
|
||||||
|
|
@ -19,13 +19,13 @@ public class Pl3xMapHook {
|
||||||
Pl3xMapProvider.get().mapWorlds().forEach(world -> {
|
Pl3xMapProvider.get().mapWorlds().forEach(world -> {
|
||||||
if (GPHook.isWorldEnabled(world.uuid())) {
|
if (GPHook.isWorldEnabled(world.uuid())) {
|
||||||
SimpleLayerProvider provider = SimpleLayerProvider
|
SimpleLayerProvider provider = SimpleLayerProvider
|
||||||
.builder(AlttdConfig.CONTROL_LABEL)
|
.builder(Config.CONTROL_LABEL)
|
||||||
.showControls(AlttdConfig.CONTROL_SHOW)
|
.showControls(Config.CONTROL_SHOW)
|
||||||
.defaultHidden(AlttdConfig.CONTROL_HIDE)
|
.defaultHidden(Config.CONTROL_HIDE)
|
||||||
.build();
|
.build();
|
||||||
world.layerRegistry().register(Key.of("griefprevention_" + world.uuid()), provider);
|
world.layerRegistry().register(Key.of("griefprevention_" + world.uuid()), provider);
|
||||||
Pl3xMapTask task = new Pl3xMapTask(world, provider);
|
Pl3xMapTask task = new Pl3xMapTask(world, provider);
|
||||||
task.runTaskTimerAsynchronously(plugin, 0, 20L * AlttdConfig.UPDATE_INTERVAL);
|
task.runTaskTimerAsynchronously(plugin, 0, 20L * Config.UPDATE_INTERVAL);
|
||||||
this.provider.put(world.uuid(), task);
|
this.provider.put(world.uuid(), task);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
||||||
|
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.config.AlttdConfig;
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
@ -18,14 +18,14 @@ public class ClaimExpireTask extends BukkitRunnable
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
runTaskTimer(plugin, 0, AlttdConfig.expireCheckRate);
|
runTaskTimer(plugin, 0, Config.expireCheckRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
//Config.expiringClaims.entrySet().removeIf(entry -> System.currentTimeMillis() >= entry.getValue());
|
//Config.expiringClaims.entrySet().removeIf(entry -> System.currentTimeMillis() >= entry.getValue());
|
||||||
for(Iterator<Map.Entry<Long, Long>> it = AlttdConfig.expiringClaims.entrySet().iterator(); it.hasNext(); ) {
|
for(Iterator<Map.Entry<Long, Long>> it = Config.expiringClaims.entrySet().iterator(); it.hasNext(); ) {
|
||||||
Map.Entry<Long, Long> entry = it.next();
|
Map.Entry<Long, Long> entry = it.next();
|
||||||
if(System.currentTimeMillis() >= entry.getValue()) {
|
if(System.currentTimeMillis() >= entry.getValue()) {
|
||||||
it.remove();
|
it.remove();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
||||||
|
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.config.AlttdConfig;
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
import net.kyori.adventure.text.minimessage.template.TemplateResolver;
|
import net.kyori.adventure.text.minimessage.template.TemplateResolver;
|
||||||
|
|
@ -32,7 +32,7 @@ public class IgnoreClaimWarningTask extends BukkitRunnable
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
runTaskLater(plugin, AlttdConfig.ignoreClaimWarningDelay);
|
runTaskLater(plugin, Config.ignoreClaimWarningDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -44,7 +44,7 @@ public class IgnoreClaimWarningTask extends BukkitRunnable
|
||||||
Template.template("player", player.displayName()),
|
Template.template("player", player.displayName()),
|
||||||
Template.template("time", time)
|
Template.template("time", time)
|
||||||
));
|
));
|
||||||
Bukkit.broadcast(MiniMessage.miniMessage().deserialize(AlttdConfig.ignoreClaimWarningMessage, TemplateResolver.templates(templates)), AlttdConfig.ignoreClaimWarningPermission);
|
Bukkit.broadcast(MiniMessage.miniMessage().deserialize(Config.ignoreClaimWarningMessage, TemplateResolver.templates(templates)), Config.ignoreClaimWarningPermission);
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
||||||
|
|
||||||
import me.ryanhamshire.GriefPrevention.Claim;
|
import me.ryanhamshire.GriefPrevention.Claim;
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.config.AlttdConfig;
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
||||||
import me.ryanhamshire.GriefPrevention.alttd.hook.GPHook;
|
import me.ryanhamshire.GriefPrevention.alttd.hook.GPHook;
|
||||||
import net.pl3x.map.api.Key;
|
import net.pl3x.map.api.Key;
|
||||||
import net.pl3x.map.api.MapWorld;
|
import net.pl3x.map.api.MapWorld;
|
||||||
|
|
@ -64,14 +64,14 @@ public class Pl3xMapTask extends BukkitRunnable {
|
||||||
claim.getPermissions(builders, containers, accessors, managers);
|
claim.getPermissions(builders, containers, accessors, managers);
|
||||||
|
|
||||||
String worldName = min.getWorld().getName();
|
String worldName = min.getWorld().getName();
|
||||||
String toolTip = AlttdConfig.CLAIM_TOOLTIP;
|
String toolTip = Config.CLAIM_TOOLTIP;
|
||||||
MarkerOptions.Builder options = MarkerOptions.builder()
|
MarkerOptions.Builder options = MarkerOptions.builder()
|
||||||
.strokeColor(AlttdConfig.STROKE_COLOR)
|
.strokeColor(Config.STROKE_COLOR)
|
||||||
.strokeWeight(AlttdConfig.STROKE_WEIGHT)
|
.strokeWeight(Config.STROKE_WEIGHT)
|
||||||
.strokeOpacity(AlttdConfig.STROKE_OPACITY)
|
.strokeOpacity(Config.STROKE_OPACITY)
|
||||||
.fillColor(AlttdConfig.FILL_COLOR)
|
.fillColor(Config.FILL_COLOR)
|
||||||
.fillOpacity(AlttdConfig.FILL_OPACITY)
|
.fillOpacity(Config.FILL_OPACITY)
|
||||||
.clickTooltip((claim.isAdminClaim() ? (AlttdConfig.expiringClaims.containsKey(claim.getID()) ? AlttdConfig.EXPIRING_CLAIM_TOOLTIP : AlttdConfig.ADMIN_CLAIM_TOOLTIP) : AlttdConfig.CLAIM_TOOLTIP)
|
.clickTooltip((claim.isAdminClaim() ? (Config.expiringClaims.containsKey(claim.getID()) ? Config.EXPIRING_CLAIM_TOOLTIP : Config.ADMIN_CLAIM_TOOLTIP) : Config.CLAIM_TOOLTIP)
|
||||||
.replace("{world}", worldName)
|
.replace("{world}", worldName)
|
||||||
.replace("{id}", Long.toString(claim.getID()))
|
.replace("{id}", Long.toString(claim.getID()))
|
||||||
.replace("{owner}", claim.getOwnerName())
|
.replace("{owner}", claim.getOwnerName())
|
||||||
|
|
@ -86,18 +86,18 @@ public class Pl3xMapTask extends BukkitRunnable {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (claim.isAdminClaim()) {
|
if (claim.isAdminClaim()) {
|
||||||
if (AlttdConfig.expiringClaims.containsKey(claim.getID())) {
|
if (Config.expiringClaims.containsKey(claim.getID())) {
|
||||||
options.strokeColor(AlttdConfig.EXPIRING_STROKE_COLOR)
|
options.strokeColor(Config.EXPIRING_STROKE_COLOR)
|
||||||
.strokeWeight(AlttdConfig.EXPIRING_STROKE_WEIGHT)
|
.strokeWeight(Config.EXPIRING_STROKE_WEIGHT)
|
||||||
.strokeOpacity(AlttdConfig.EXPIRING_STROKE_OPACITY)
|
.strokeOpacity(Config.EXPIRING_STROKE_OPACITY)
|
||||||
.fillColor(AlttdConfig.EXPIRING_FILL_COLOR)
|
.fillColor(Config.EXPIRING_FILL_COLOR)
|
||||||
.fillOpacity(AlttdConfig.EXPIRING_FILL_OPACITY);
|
.fillOpacity(Config.EXPIRING_FILL_OPACITY);
|
||||||
} else {
|
} else {
|
||||||
options.strokeColor(AlttdConfig.ADMIN_STROKE_COLOR)
|
options.strokeColor(Config.ADMIN_STROKE_COLOR)
|
||||||
.strokeWeight(AlttdConfig.ADMIN_STROKE_WEIGHT)
|
.strokeWeight(Config.ADMIN_STROKE_WEIGHT)
|
||||||
.strokeOpacity(AlttdConfig.ADMIN_STROKE_OPACITY)
|
.strokeOpacity(Config.ADMIN_STROKE_OPACITY)
|
||||||
.fillColor(AlttdConfig.ADMIN_FILL_COLOR)
|
.fillColor(Config.ADMIN_FILL_COLOR)
|
||||||
.fillOpacity(AlttdConfig.ADMIN_FILL_OPACITY);
|
.fillOpacity(Config.ADMIN_FILL_OPACITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,8 +118,8 @@ public class Pl3xMapTask extends BukkitRunnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseExpireTime(Long claimId) {
|
private String parseExpireTime(Long claimId) {
|
||||||
if(AlttdConfig.expiringClaims.containsKey(claimId)) {
|
if(Config.expiringClaims.containsKey(claimId)) {
|
||||||
return DateFormat.getInstance().format(AlttdConfig.expiringClaims.get(claimId));
|
return DateFormat.getInstance().format(Config.expiringClaims.get(claimId));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user