1
0

re-add clicking message to message someone

This commit is contained in:
Lee
2024-03-28 19:36:04 +00:00
parent 74deffbf82
commit 6d166befa2
3 changed files with 75 additions and 6 deletions

View File

@ -0,0 +1,69 @@
package cc.fascinated.config;
import cc.fascinated.Aetheria;
import lombok.Getter;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.HashMap;
import java.util.List;
@Getter
public enum Config {
INFLUXDB_URL("influxdb.url"),
INFLUXDB_TOKEN("influxdb.token"),
INFLUXDB_ORG("influxdb.org"),
INFLUXDB_BUCKET("influxdb.bucket");
/**
* The path of the lang in the lang.yml file.
*/
private final String path;
Config(String path) {
this.path = path;
}
/**
* Cache of the config values.
*/
private final HashMap<String, Object> cache = new HashMap<>();
/**
* The configuration.
*/
private final cc.fascinated.utils.io.Config config = new cc.fascinated.utils.io.Config(Aetheria.INSTANCE, "config.yml", null);
/**
* Gets as an object.
*
* @return the string
*/
public Object get() {
return cache.computeIfAbsent(path, key -> {
FileConfiguration configuration = config.getFileConfiguration();
if (configuration.get(path) == null) {
throw new IllegalArgumentException("Path " + path + " does not exist in the config.yml file.");
}
return configuration.get(path);
});
}
/**
* Gets as a string.
*
* @return the string
*/
public String getAsString() {
return (String) get();
}
/**
* Gets as a string list.
*
* @return the string list
*/
public List<String> getAsStringList() {
return (List<String>) get();
}
}

View File

@ -1,6 +1,7 @@
package cc.fascinated.metrics; package cc.fascinated.metrics;
import cc.fascinated.Aetheria; import cc.fascinated.Aetheria;
import cc.fascinated.config.Config;
import cc.fascinated.metrics.impl.server.*; import cc.fascinated.metrics.impl.server.*;
import cc.fascinated.metrics.impl.system.CpuUsageMetric; import cc.fascinated.metrics.impl.system.CpuUsageMetric;
import cc.fascinated.metrics.impl.world.WorldSizeMetric; import cc.fascinated.metrics.impl.world.WorldSizeMetric;
@ -31,11 +32,10 @@ public class MetricManager implements Listener {
private static final List<Metric> metrics = new ArrayList<>(); private static final List<Metric> metrics = new ArrayList<>();
public MetricManager() { public MetricManager() {
FileConfiguration config = Aetheria.INSTANCE.getConfig(); String url = Config.INFLUXDB_URL.getAsString();
String url = config.getString("influxdb.url"); String token = Config.INFLUXDB_TOKEN.getAsString();
String token = config.getString("influxdb.token"); String org = Config.INFLUXDB_ORG.getAsString();
String org = config.getString("influxdb.org"); String bucket = Config.INFLUXDB_BUCKET.getAsString();
String bucket = config.getString("influxdb.bucket");
if (url == null || token == null || org == null || bucket == null) { if (url == null || token == null || org == null || bucket == null) {
log.error("InfluxDB configuration is missing"); log.error("InfluxDB configuration is missing");

View File

@ -1,7 +1,7 @@
prefix: "<gold><bold>AETHERIA</bold></gold> <gray>»</gray> <white>" prefix: "<gold><bold>AETHERIA</bold></gold> <gray>»</gray> <white>"
admin-prefix: "<grey>[</grey><bold><red>ADMIN</red></bold><grey>]</grey> <white>" admin-prefix: "<grey>[</grey><bold><red>ADMIN</red></bold><grey>]</grey> <white>"
chat-format: "<<%chatcolor%>%name%</%chatcolor%>> <white>%message%" chat-format: "<<%chatcolor%>%name%</%chatcolor%>> <hover:show_text:Click to message %name%><click:suggest_command:/msg %name% ><white>%message%"
blocked-message: "<prefix><red>Your message has been blocked." blocked-message: "<prefix><red>Your message has been blocked."
blocked-message-alert: "<admin-prefix><red>%player% <grey>tried to send a blocked message: <white>%message%" blocked-message-alert: "<admin-prefix><red>%player% <grey>tried to send a blocked message: <white>%message%"