Add option to pull server setting from the server.properties file

This commit is contained in:
Luck 2017-12-11 19:40:39 +00:00
parent a765be0a6f
commit e5ce64266f
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
7 changed files with 34 additions and 7 deletions

View File

@ -434,7 +434,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
}
@Override
public String getServerName() {
public String getServerBrand() {
return getServer().getName();
}
@ -443,6 +443,11 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
return getServer().getVersion() + " - " + getServer().getBukkitVersion();
}
@Override
public String getServerName() {
return getServer().getServerName();
}
@Override
public File getDataDirectory() {
return super.getDataFolder();

View File

@ -70,6 +70,10 @@ use-server-uuids: true
# in the LuckPerms cache.
use-server-uuid-cache: false
# If LuckPerms should use the "server-name" property from the "server.properties"
# file as the "server" option within LuckPerms.
use-server-properties-name: false
# If set to true, LuckPerms will allow usernames with non alphanumeric characters.
#
# Note that due to the design of the storage implementation, usernames must still be

View File

@ -266,7 +266,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
}
@Override
public String getServerName() {
public String getServerBrand() {
return getProxy().getName();
}

View File

@ -55,7 +55,7 @@ public class InfoCommand extends SingleCommand {
Message.INFO_TOP.send(sender,
plugin.getVersion(),
plugin.getServerType().getFriendlyName(),
plugin.getServerName(),
plugin.getServerBrand(),
plugin.getServerVersion()
);

View File

@ -68,7 +68,16 @@ public class ConfigKeys {
/**
* The name of the server
*/
public static final ConfigKey<String> SERVER = LowercaseStringKey.of("server", "global");
public static final ConfigKey<String> SERVER = AbstractKey.of(c -> {
if (c.getBoolean("use-server-properties-name", false)) {
String serverName = c.getPlugin().getServerName();
if (serverName != null && !serverName.equals("Unknown Server")) {
return serverName.toLowerCase();
}
}
return c.getString("server", "global").toLowerCase();
});
/**
* How many minutes to wait between syncs. A value <= 0 will disable syncing.

View File

@ -230,7 +230,7 @@ public interface LuckPermsPlugin {
*
* @return the server brand
*/
String getServerName();
String getServerBrand();
/**
* Gets the version of the running platform
@ -239,6 +239,15 @@ public interface LuckPermsPlugin {
*/
String getServerVersion();
/**
* Gets the name associated with this server
*
* @return the server name
*/
default String getServerName() {
return null;
}
/**
* Gets the time when the plugin first started in millis.
*
@ -394,7 +403,7 @@ public interface LuckPermsPlugin {
sender.sendMessage(CommandUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
sender.sendMessage(CommandUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
sender.sendMessage(CommandUtils.color(" "));
sender.sendMessage(CommandUtils.color("&2 Loading version &bv" + plugin.getVersion() + "&2 on " + plugin.getServerType().getFriendlyName() + " - " + plugin.getServerName()));
sender.sendMessage(CommandUtils.color("&2 Loading version &bv" + plugin.getVersion() + "&2 on " + plugin.getServerType().getFriendlyName() + " - " + plugin.getServerBrand()));
sender.sendMessage(CommandUtils.color("&8 Running on server version " + plugin.getServerVersion()));
sender.sendMessage(CommandUtils.color(" "));
}

View File

@ -411,7 +411,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
}
@Override
public String getServerName() {
public String getServerBrand() {
return getGame().getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getName();
}