Replaced inconsistent `ReloadConfig` usage with `reloadConfig` across the codebase for better naming consistency. Introduced `ServerName` utility to standardize server name retrieval and improve maintainability. Added logging enhancements for better debugging of muted users and blocked messages.
42 lines
1.2 KiB
Java
42 lines
1.2 KiB
Java
package com.alttd.chat.util;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.util.Properties;
|
|
|
|
public class ServerName {
|
|
|
|
private static final String serverName = loadServerName();
|
|
|
|
private static String loadServerName() {
|
|
String serverName = "unknown";
|
|
try {
|
|
File serverPropertiesFile = new File(Bukkit.getWorldContainer().getParentFile(), "server.properties");
|
|
if (!serverPropertiesFile.exists()) {
|
|
ALogger.warn(String.format("server.properties file not found in %s!", serverPropertiesFile.getAbsolutePath()));
|
|
return serverName;
|
|
}
|
|
|
|
Properties properties = new Properties();
|
|
FileInputStream fis = new FileInputStream(serverPropertiesFile);
|
|
properties.load(fis);
|
|
fis.close();
|
|
|
|
serverName = properties.getProperty("server-name", serverName);
|
|
|
|
ALogger.info(String.format("Found server name [%s]", serverName));
|
|
} catch (IOException e) {
|
|
ALogger.error("Failed to read server.properties", e);
|
|
}
|
|
return serverName;
|
|
}
|
|
|
|
public static String getServerName() {
|
|
return serverName;
|
|
}
|
|
|
|
}
|