diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUser.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUser.java index 0ea0c6662..1b5635391 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUser.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiUser.java @@ -35,7 +35,6 @@ import me.lucko.luckperms.common.verbose.event.MetaCheckEvent; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; import net.luckperms.api.node.NodeEqualityPredicate; -import net.luckperms.api.query.QueryOptions; import org.checkerframework.checker.nullness.qual.NonNull; @@ -72,10 +71,7 @@ public class ApiUser extends ApiPermissionHolder implements net.luckperms.api.mo @Override public @NonNull String getPrimaryGroup() { - QueryOptions queryOptions = this.handle.getPlugin().getQueryOptionsForUser(this.handle) - .orElseGet(() -> this.handle.getPlugin().getContextManager().getStaticQueryOptions()); - - String value = this.handle.getCachedData().getMetaData(queryOptions).getPrimaryGroup(MetaCheckEvent.Origin.LUCKPERMS_API); + String value = this.handle.getCachedData().getMetaData(this.handle.getQueryOptions()).getPrimaryGroup(MetaCheckEvent.Origin.LUCKPERMS_API); Objects.requireNonNull(value, "value"); // assert nonnull return value; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java index fb327a227..7ed8001c7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java @@ -70,7 +70,7 @@ public class CheckCommand extends SingleCommand { return CommandResult.STATE_ERROR; } - Tristate tristate = user.getCachedData().getPermissionData(plugin.getQueryOptionsForUser(user).orElse(plugin.getContextManager().getStaticQueryOptions())).checkPermission(permission, PermissionCheckEvent.Origin.INTERNAL).result(); + Tristate tristate = user.getCachedData().getPermissionData(user.getQueryOptions()).checkPermission(permission, PermissionCheckEvent.Origin.INTERNAL).result(); Message.CHECK_RESULT.send(sender, user.getFormattedDisplayName(), permission, MessageUtils.formatTristate(tristate)); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java index 43b1b8207..bf094f6a6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java @@ -92,7 +92,7 @@ public class TreeCommand extends SingleCommand { } Message.TREE_UPLOAD_START.send(sender); - PermissionCache permissionData = user == null ? null : user.getCachedData().getPermissionData(plugin.getQueryOptionsForUser(user).orElse(plugin.getContextManager().getStaticQueryOptions())); + PermissionCache permissionData = user == null ? null : user.getCachedData().getPermissionData(user.getQueryOptions()); String id; try { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java index 065299c59..39e102dd7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java @@ -50,7 +50,6 @@ import net.luckperms.api.query.QueryOptions; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.stream.Collectors; public class UserInfo extends ChildCommand { @@ -65,19 +64,12 @@ public class UserInfo extends ChildCommand { return CommandResult.NO_PERMISSION; } - Optional queryOptions = plugin.getQueryOptionsForUser(user); - Message status = plugin.getBootstrap().isPlayerOnline(user.getUniqueId()) ? Message.PLAYER_ONLINE : Message.PLAYER_OFFLINE; - - String primaryGroup = user.getCachedData().getMetaData(queryOptions.orElseGet(() -> plugin.getContextManager().getStaticQueryOptions())) - .getPrimaryGroup(MetaCheckEvent.Origin.INTERNAL); - Message.USER_INFO_GENERAL.send(sender, user.getUsername().orElse("Unknown"), user.getUniqueId(), user.getUniqueId().version() == 4 ? "&2mojang" : "&8offline", - status.asString(plugin.getLocaleManager()), - primaryGroup + status.asString(plugin.getLocaleManager()) ); List parents = user.normalData().inheritanceAsSortedSet().stream() @@ -105,39 +97,46 @@ public class UserInfo extends ChildCommand { } } + QueryOptions queryOptions = plugin.getQueryOptionsForUser(user).orElse(null); + boolean active = true; + + if (queryOptions == null) { + active = false; + queryOptions = plugin.getContextManager().getStaticQueryOptions(); + } + String context = "&bNone"; String prefix = "&bNone"; String suffix = "&bNone"; String meta = "&bNone"; - if (queryOptions.isPresent()) { - ContextSet contextSet = queryOptions.get().context(); - if (!contextSet.isEmpty()) { - context = contextSet.toSet().stream() - .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) - .collect(Collectors.joining(" ")); - } - - MetaCache data = user.getCachedData().getMetaData(queryOptions.get()); - String prefixValue = data.getPrefix(MetaCheckEvent.Origin.INTERNAL); - if (prefixValue != null) { - prefix = "&f\"" + prefixValue + "&f\""; - } - String sussexValue = data.getSuffix(MetaCheckEvent.Origin.INTERNAL); - if (sussexValue != null) { - suffix = "&f\"" + sussexValue + "&f\""; - } - - Map> metaMap = data.getMeta(MetaCheckEvent.Origin.INTERNAL); - if (!metaMap.isEmpty()) { - meta = metaMap.entrySet().stream() - .flatMap(entry -> entry.getValue().stream().map(value -> Maps.immutableEntry(entry.getKey(), value))) - .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) - .collect(Collectors.joining(" ")); - } + ContextSet contextSet = queryOptions.context(); + if (!contextSet.isEmpty()) { + context = contextSet.toSet().stream() + .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) + .collect(Collectors.joining(" ")); } - Message.USER_INFO_DATA.send(sender, MessageUtils.formatBoolean(queryOptions != null), context, prefix, suffix, meta); + MetaCache data = user.getCachedData().getMetaData(queryOptions); + String prefixValue = data.getPrefix(MetaCheckEvent.Origin.INTERNAL); + if (prefixValue != null) { + prefix = "&f\"" + prefixValue + "&f\""; + } + String sussexValue = data.getSuffix(MetaCheckEvent.Origin.INTERNAL); + if (sussexValue != null) { + suffix = "&f\"" + sussexValue + "&f\""; + } + String primaryGroup = user.getCachedData().getMetaData(queryOptions).getPrimaryGroup(MetaCheckEvent.Origin.INTERNAL); + + Map> metaMap = data.getMeta(MetaCheckEvent.Origin.INTERNAL); + if (!metaMap.isEmpty()) { + meta = metaMap.entrySet().stream() + .flatMap(entry -> entry.getValue().stream().map(value -> Maps.immutableEntry(entry.getKey(), value))) + .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) + .collect(Collectors.joining(" ")); + } + + Message.USER_INFO_DATA.send(sender, active ? "&2active player" : "&8server", context, prefix, suffix, primaryGroup, meta); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java index f0313639e..ff7be6adb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java @@ -211,28 +211,28 @@ public enum Message { "{PREFIX}&f- &3Platform: &f{}" + "\n" + "{PREFIX}&f- &3Server Brand: &f{}" + "\n" + "{PREFIX}&f- &3Server Version:" + "\n" + - "{PREFIX}&f- {}", + "{PREFIX} &f{}", false ), INFO_STORAGE( "{PREFIX}&f- &bStorage:" + "\n" + - "{PREFIX}&f- &3Type: &f{}", + "{PREFIX} &3Type: &f{}", false ), - INFO_STORAGE_META("&f- &3{}: {}", true), + INFO_STORAGE_META(" &3{}: {}", true), INFO_EXTENSIONS("{PREFIX}&f- &bExtensions:", true), - INFO_EXTENSION_ENTRY("&f- &3{}", true), + INFO_EXTENSION_ENTRY(" &3{}", true), INFO_MIDDLE( "{PREFIX}&f- &bMessaging: &f{}" + "\n" + "{PREFIX}&f- &bInstance:" + "\n" + - "{PREFIX}&f- &3Static contexts: &f{}" + "\n" + - "{PREFIX}&f- &3Online Players: &a{} &7(&a{}&7 unique)" + "\n" + - "{PREFIX}&f- &3Uptime: &7{}" + "\n" + - "{PREFIX}&f- &3Local Data: &a{} &7users, &a{} &7groups, &a{} &7tracks", + "{PREFIX} &3Static contexts: &f{}" + "\n" + + "{PREFIX} &3Online Players: &a{} &7(&a{}&7 unique)" + "\n" + + "{PREFIX} &3Uptime: &7{}" + "\n" + + "{PREFIX} &3Local Data: &a{} &7users, &a{} &7groups, &a{} &7tracks", false ), @@ -355,26 +355,27 @@ public enum Message { USER_INFO_GENERAL( "{PREFIX}&b&l> &bUser Info: &f{}" + "\n" + - "{PREFIX}&f- &3UUID: &f{} &7(type: {}&7)" + "\n" + - "{PREFIX}&f- &3Status: {}" + "\n" + - "{PREFIX}&f- &3Primary Group: &f{}", + "{PREFIX}&f- &3UUID: &f{}" + "\n" + + "{PREFIX}&f &7(type: {}&7)" + "\n" + + "{PREFIX}&f- &3Status: {}", false ), USER_INFO_DATA( "{PREFIX}&f- &aContextual Data:" + "\n" + - "{PREFIX}&f- &3Has contextual data: {}" + "\n" + - "{PREFIX}&f- &3Applicable contexts: {}" + "\n" + - "{PREFIX}&f- &3Prefix: {}" + "\n" + - "{PREFIX}&f- &3Suffix: {}" + "\n" + - "{PREFIX}&f- &3Meta: {}", + "{PREFIX} &3Type: {}" + "\n" + + "{PREFIX} &3Contexts: {}" + "\n" + + "{PREFIX} &3Prefix: {}" + "\n" + + "{PREFIX} &3Suffix: {}" + "\n" + + "{PREFIX} &3Primary Group: &f{}" + "\n" + + "{PREFIX} &3Meta: {}", false ), INFO_PARENT_HEADER("&f- &aParent Groups:", true), INFO_TEMP_PARENT_HEADER("&f- &aTemporary Parent Groups:", true), - INFO_PARENT_ENTRY("&f- &3> &f{}{}", true), - INFO_PARENT_ENTRY_EXPIRY("&f- &2- expires in {}", true), + INFO_PARENT_ENTRY(" &3> &f{}{}", true), + INFO_PARENT_ENTRY_EXPIRY(" &2- expires in {}", true), USER_REMOVEGROUP_ERROR_PRIMARY("&aYou cannot remove a user from their primary group.", true), USER_PRIMARYGROUP_SUCCESS("&b{}&a's primary group was set to &b{}&a.", true), USER_PRIMARYGROUP_WARN_OPTION("&aWarning: The primary group calculation method being used by this server &7({}) &amay not reflect this change.", true),