diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java index d0fa3d54f..7e5379ab3 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -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(); diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 58c965ebb..ffb0047c8 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -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 diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java index 6cf07f465..7ec5bf6eb 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java @@ -266,7 +266,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { } @Override - public String getServerName() { + public String getServerBrand() { return getProxy().getName(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java index e5fc8c1fe..39681d13e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java @@ -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() ); diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java index aa84e02d3..e57c5de52 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java @@ -68,7 +68,16 @@ public class ConfigKeys { /** * The name of the server */ - public static final ConfigKey SERVER = LowercaseStringKey.of("server", "global"); + public static final ConfigKey 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. diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java index dc05397bb..d945cdd12 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java @@ -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(" ")); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index 7e568a1f9..636b3fe0c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -411,7 +411,7 @@ public class LPSpongePlugin implements LuckPermsPlugin { } @Override - public String getServerName() { + public String getServerBrand() { return getGame().getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getName(); }