mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-25 14:34:47 +00:00
Cleanup & multiple small fixes
This commit is contained in:
1 parent
1870893fe1
commit
a413c0a50a
53 files changed
+452
-371
No files matched your search
@@ -1,13 +1,71 @@
|
||||
package me.lucko.luckperms.utils;
|
||||
|
||||
public interface LPConfiguration {
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
|
||||
String getServer();
|
||||
int getSyncTime();
|
||||
String getDefaultGroupNode();
|
||||
String getDefaultGroupName();
|
||||
boolean getIncludeGlobalPerms();
|
||||
String getDatabaseValue(String value);
|
||||
String getStorageMethod();
|
||||
public abstract class LPConfiguration<T extends LuckPermsPlugin> {
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final T plugin;
|
||||
|
||||
private final String defaultServerName;
|
||||
private final boolean defaultIncludeGlobal;
|
||||
private final String defaultStorage;
|
||||
|
||||
public LPConfiguration(T plugin, String defaultServerName, boolean defaultIncludeGlobal, String defaultStorage) {
|
||||
this.plugin = plugin;
|
||||
this.defaultServerName = defaultServerName;
|
||||
this.defaultIncludeGlobal = defaultIncludeGlobal;
|
||||
this.defaultStorage = defaultStorage;
|
||||
init();
|
||||
|
||||
if (Patterns.NON_ALPHA_NUMERIC.matcher(getServer()).find()) {
|
||||
plugin.getLogger().severe("Server name defined in config.yml contains invalid characters. Server names can " +
|
||||
"only contain alphanumeric characters.\nDefined server name '" + getServer() + "' will be replaced with '" +
|
||||
defaultServerName + "' (the default)");
|
||||
set("server", defaultServerName);
|
||||
}
|
||||
|
||||
if (Patterns.NON_ALPHA_NUMERIC.matcher(getDefaultGroupName()).find()) {
|
||||
plugin.getLogger().severe("Default group defined in config.yml contains invalid characters. Group names can " +
|
||||
"only contain alphanumeric characters.\nDefined default group name '" + getDefaultGroupName() +
|
||||
"' will be replaced with 'default' (the default)");
|
||||
set("default-group", "default");
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void init();
|
||||
protected abstract void set(String path, Object value);
|
||||
protected abstract String getString(String path, String def);
|
||||
protected abstract int getInt(String path, int def);
|
||||
protected abstract boolean getBoolean(String path, boolean def);
|
||||
|
||||
public String getServer() {
|
||||
return getString("server", defaultServerName);
|
||||
}
|
||||
|
||||
public int getSyncTime() {
|
||||
return getInt("sql.sync-minutes", 3);
|
||||
}
|
||||
|
||||
public String getDefaultGroupNode() {
|
||||
return "group." + getDefaultGroupName();
|
||||
}
|
||||
|
||||
public String getDefaultGroupName() {
|
||||
return getString("default-group", "default");
|
||||
}
|
||||
|
||||
public boolean getIncludeGlobalPerms() {
|
||||
return getBoolean("include-global", defaultIncludeGlobal);
|
||||
}
|
||||
|
||||
public String getDatabaseValue(String value) {
|
||||
return getString("sql." + value, null);
|
||||
}
|
||||
|
||||
public String getStorageMethod() {
|
||||
return getString("storage-method", defaultStorage);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user