From 54695b8046449e1a5abc83cce7b89f652fd98125 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 23 Oct 2017 23:37:55 +0100 Subject: [PATCH] Form more descriptive console & import usernames --- .../main/java/me/lucko/luckperms/api/LPConfiguration.java | 2 +- .../java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java | 3 ++- .../java/me/lucko/luckperms/bungee/BungeeSenderFactory.java | 3 ++- .../me/lucko/luckperms/common/backup/ImporterSender.java | 3 ++- .../java/me/lucko/luckperms/common/constants/Constants.java | 5 +++-- .../main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java | 2 +- .../java/me/lucko/luckperms/sponge/SpongeSenderFactory.java | 3 ++- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java index 91748e69..0da6c0e8 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java +++ b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java @@ -204,7 +204,7 @@ public interface LPConfiguration { *

This method is nested under {@link Unsafe} because the keys * and return types may change between versions without warning.

* - * @param key the key, as defined as a parameter name in + * @param key the key, as defined as a field name in * the "ConfigKeys" class. * @return the corresponding object, if one is present * @throws IllegalArgumentException if the key isn't known diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java index a4f889b3..d2663045 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.bukkit; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.bukkit.compat.MessageHandler; import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -52,7 +53,7 @@ public class BukkitSenderFactory extends SenderFactory { if (sender instanceof Player) { return sender.getName(); } - return Constants.CONSOLE_NAME; + return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER)); } @Override diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java index 1ef0fc31..812bc67e 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.bungee; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.bungee.event.TristateCheckEvent; import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; @@ -50,7 +51,7 @@ public class BungeeSenderFactory extends SenderFactory { if (sender instanceof ProxiedPlayer) { return sender.getName(); } - return Constants.CONSOLE_NAME; + return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/ImporterSender.java b/common/src/main/java/me/lucko/luckperms/common/backup/ImporterSender.java index ed133d55..098b1085 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/ImporterSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/ImporterSender.java @@ -29,6 +29,7 @@ import lombok.AllArgsConstructor; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.CommandPermission; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -51,7 +52,7 @@ public abstract class ImporterSender implements Sender { @Override public String getName() { - return Constants.IMPORT_NAME; + return Constants.IMPORT_NAME.apply(plugin.getConfiguration().get(ConfigKeys.SERVER)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/constants/Constants.java b/common/src/main/java/me/lucko/luckperms/common/constants/Constants.java index 767db34d..3c879ac0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/constants/Constants.java +++ b/common/src/main/java/me/lucko/luckperms/common/constants/Constants.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.common.constants; import lombok.experimental.UtilityClass; import java.util.UUID; +import java.util.function.Function; /** * Random constants used throughout the plugin implementation. @@ -36,10 +37,10 @@ import java.util.UUID; public class Constants { public static final UUID CONSOLE_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); - public static final String CONSOLE_NAME = "Console"; + public static final Function CONSOLE_NAME = s -> s == null || s.equalsIgnoreCase("global") ? "Console" : "console@" + s; public static final UUID IMPORT_UUID = UUID.fromString("11111111-1111-1111-1111-111111111111"); - public static final String IMPORT_NAME = "Import"; + public static final Function IMPORT_NAME = s -> s == null || s.equalsIgnoreCase("global") ? "Import" : "import@" + s; public static final char COLOR_CHAR = '\u00A7'; public static final char FORMAT_CHAR = '&'; 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 27833fcc..8380a0dc 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -454,7 +454,7 @@ public class LPSpongePlugin implements LuckPermsPlugin { @Override public String getName() { - return Constants.CONSOLE_NAME; + return Constants.CONSOLE_NAME.apply(getConfiguration().get(ConfigKeys.SERVER)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java index 3dc875cf..e325c36c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.sponge; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; @@ -51,7 +52,7 @@ public class SpongeSenderFactory extends SenderFactory { if (source instanceof Player) { return source.getName(); } - return Constants.CONSOLE_NAME; + return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER)); } @Override