Specify explicit global context in generated LP commands when default contexts have been set (#1062)

This commit is contained in:
Luck 2018-06-26 14:39:18 +01:00
parent b4ff54ffc8
commit ee13540d78
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
16 changed files with 51 additions and 44 deletions

View File

@ -130,7 +130,7 @@ public class Exporter implements Runnable {
write(writer, "# Export group: " + group.getName()); write(writer, "# Export group: " + group.getName());
for (Node node : group.enduringData().immutable().values()) { for (Node node : group.enduringData().immutable().values()) {
write(writer, "/lp " + NodeFactory.nodeAsCommand(node, group.getName(), HolderType.GROUP, true)); write(writer, "/lp " + NodeFactory.nodeAsCommand(node, group.getName(), HolderType.GROUP, true, false));
} }
write(writer, ""); write(writer, "");
this.log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet()); this.log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet());
@ -225,7 +225,7 @@ public class Exporter implements Runnable {
continue; continue;
} }
output.add("/lp " + NodeFactory.nodeAsCommand(node, user.getUuid().toString(), HolderType.USER, true)); output.add("/lp " + NodeFactory.nodeAsCommand(node, user.getUuid().toString(), HolderType.USER, true, false));
} }
if (!user.getPrimaryGroup().getStoredValue().orElse(NodeFactory.DEFAULT_GROUP_NAME).equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) { if (!user.getPrimaryGroup().getStoredValue().orElse(NodeFactory.DEFAULT_GROUP_NAME).equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {

View File

@ -99,9 +99,9 @@ public abstract class SharedSubCommand {
public void sendUsage(Sender sender) { public void sendUsage(Sender sender) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (getArgs() != null) { if (getArgs() != null) {
sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlatform().getLocaleManager())); sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlugin().getLocaleManager()));
for (Argument arg : getArgs()) { for (Argument arg : getArgs()) {
sb.append(arg.asPrettyString(sender.getPlatform().getLocaleManager())).append(" "); sb.append(arg.asPrettyString(sender.getPlugin().getLocaleManager())).append(" ");
} }
} }
@ -114,7 +114,7 @@ public abstract class SharedSubCommand {
if (getArgs() != null) { if (getArgs() != null) {
Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender); Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender);
for (Argument arg : getArgs()) { for (Argument arg : getArgs()) {
Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlatform().getLocaleManager()), arg.getDescription()); Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlugin().getLocaleManager()), arg.getDescription());
} }
} }
} }

View File

@ -56,9 +56,9 @@ public abstract class SingleCommand extends Command<Void, Void> {
public void sendUsage(Sender sender, String label) { public void sendUsage(Sender sender, String label) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (getArgs().isPresent()) { if (getArgs().isPresent()) {
sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlatform().getLocaleManager())); sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlugin().getLocaleManager()));
for (Argument arg : getArgs().get()) { for (Argument arg : getArgs().get()) {
sb.append(arg.asPrettyString(sender.getPlatform().getLocaleManager())).append(" "); sb.append(arg.asPrettyString(sender.getPlugin().getLocaleManager())).append(" ");
} }
} }
@ -72,7 +72,7 @@ public abstract class SingleCommand extends Command<Void, Void> {
if (getArgs().isPresent()) { if (getArgs().isPresent()) {
Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender); Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender);
for (Argument arg : getArgs().get()) { for (Argument arg : getArgs().get()) {
Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlatform().getLocaleManager()), arg.getDescription()); Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlugin().getLocaleManager()), arg.getDescription());
} }
} }
} }

View File

@ -51,9 +51,9 @@ public abstract class SubCommand<T> extends Command<T, Void> {
public void sendUsage(Sender sender, String label) { public void sendUsage(Sender sender, String label) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (getArgs().isPresent()) { if (getArgs().isPresent()) {
sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlatform().getLocaleManager())); sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlugin().getLocaleManager()));
for (Argument arg : getArgs().get()) { for (Argument arg : getArgs().get()) {
sb.append(arg.asPrettyString(sender.getPlatform().getLocaleManager())).append(" "); sb.append(arg.asPrettyString(sender.getPlugin().getLocaleManager())).append(" ");
} }
} }
@ -67,7 +67,7 @@ public abstract class SubCommand<T> extends Command<T, Void> {
if (getArgs().isPresent()) { if (getArgs().isPresent()) {
Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender); Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender);
for (Argument arg : getArgs().get()) { for (Argument arg : getArgs().get()) {
Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlatform().getLocaleManager()), arg.getDescription()); Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlugin().getLocaleManager()), arg.getDescription());
} }
} }
} }

View File

@ -46,7 +46,7 @@ public final class MessageUtils {
* @param message the message content * @param message the message content
*/ */
public static void sendPluginMessage(Sender sender, String message) { public static void sendPluginMessage(Sender sender, String message) {
String prefix = Message.PREFIX.asString(sender.getPlatform().getLocaleManager()); String prefix = Message.PREFIX.asString(sender.getPlugin().getLocaleManager());
sender.sendMessage(Message.colorize(prefix + message)); sender.sendMessage(Message.colorize(prefix + message));
} }

View File

@ -123,12 +123,12 @@ public class MetaInfo extends SharedSubCommand {
for (LocalizedNode m : meta) { for (LocalizedNode m : meta) {
String location = processLocation(m, holder); String location = processLocation(m, holder);
if (m.hasSpecificContext()) { if (m.hasSpecificContext()) {
String context = MessageUtils.getAppendableNodeContextString(sender.getPlatform().getLocaleManager(), m); String context = MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), m);
TextComponent.Builder builder = Message.META_ENTRY_WITH_CONTEXT.asComponent(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context).toBuilder(); TextComponent.Builder builder = Message.META_ENTRY_WITH_CONTEXT.asComponent(sender.getPlugin().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context).toBuilder();
builder.applyDeep(makeFancy(holder, label, m)); builder.applyDeep(makeFancy(holder, label, m));
sender.sendMessage(builder.build()); sender.sendMessage(builder.build());
} else { } else {
TextComponent.Builder builder = Message.META_ENTRY.asComponent(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location).toBuilder(); TextComponent.Builder builder = Message.META_ENTRY.asComponent(sender.getPlugin().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location).toBuilder();
builder.applyDeep(makeFancy(holder, label, m)); builder.applyDeep(makeFancy(holder, label, m));
sender.sendMessage(builder.build()); sender.sendMessage(builder.build());
} }
@ -139,12 +139,12 @@ public class MetaInfo extends SharedSubCommand {
for (Map.Entry<Integer, LocalizedNode> e : meta) { for (Map.Entry<Integer, LocalizedNode> e : meta) {
String location = processLocation(e.getValue(), holder); String location = processLocation(e.getValue(), holder);
if (e.getValue().hasSpecificContext()) { if (e.getValue().hasSpecificContext()) {
String context = MessageUtils.getAppendableNodeContextString(sender.getPlatform().getLocaleManager(), e.getValue()); String context = MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), e.getValue());
TextComponent.Builder builder = Message.CHAT_META_ENTRY_WITH_CONTEXT.asComponent(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context).toBuilder(); TextComponent.Builder builder = Message.CHAT_META_ENTRY_WITH_CONTEXT.asComponent(sender.getPlugin().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context).toBuilder();
builder.applyDeep(makeFancy(type, holder, label, e.getValue())); builder.applyDeep(makeFancy(type, holder, label, e.getValue()));
sender.sendMessage(builder.build()); sender.sendMessage(builder.build());
} else { } else {
TextComponent.Builder builder = Message.CHAT_META_ENTRY.asComponent(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location).toBuilder(); TextComponent.Builder builder = Message.CHAT_META_ENTRY.asComponent(sender.getPlugin().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location).toBuilder();
builder.applyDeep(makeFancy(type, holder, label, e.getValue())); builder.applyDeep(makeFancy(type, holder, label, e.getValue()));
sender.sendMessage(builder.build()); sender.sendMessage(builder.build());
} }
@ -166,7 +166,7 @@ public class MetaInfo extends SharedSubCommand {
"¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFriendlyName() "¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFriendlyName()
), '¥')); ), '¥'));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false); String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty());
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> { return component -> {
@ -190,7 +190,7 @@ public class MetaInfo extends SharedSubCommand {
"¥7Click to remove this meta pair from " + holder.getFriendlyName() "¥7Click to remove this meta pair from " + holder.getFriendlyName()
), '¥')); ), '¥'));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false); String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty());
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> { return component -> {

View File

@ -141,7 +141,7 @@ public class ParentInfo extends SharedSubCommand {
"&7Click to remove this parent from " + holder.getFriendlyName() "&7Click to remove this parent from " + holder.getFriendlyName()
), CommandManager.AMPERSAND_CHAR)); ), CommandManager.AMPERSAND_CHAR));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false); String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty());
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> { return component -> {

View File

@ -143,7 +143,7 @@ public class PermissionInfo extends SharedSubCommand {
"¥7Click to remove this node from " + holder.getFriendlyName() "¥7Click to remove this node from " + holder.getFriendlyName()
), '¥')); ), '¥'));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false); String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty());
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> { return component -> {

View File

@ -142,8 +142,8 @@ public class GroupListMembers extends SubCommand<Group> {
headerMessage.send(sender, page, pages.size(), results.size()); headerMessage.send(sender, page, pages.size(), results.size());
for (Map.Entry<String, HeldPermission<T>> ent : mappedContent) { for (Map.Entry<String, HeldPermission<T>> ent : mappedContent) {
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlatform().getLocaleManager(), ent.getValue().asNode()); String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), ent.getValue().asNode());
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue())).build(); TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build();
sender.sendMessage(message); sender.sendMessage(message);
} }
} }
@ -156,14 +156,14 @@ public class GroupListMembers extends SubCommand<Group> {
return " &8(&7expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiryUnixTime()) + "&8)"; return " &8(&7expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiryUnixTime()) + "&8)";
} }
private static Consumer<BuildableComponent.Builder<? ,?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm) { private static Consumer<BuildableComponent.Builder<? ,?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm, LuckPermsPlugin plugin) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline( HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
"&3> &b" + perm.asNode().getGroupName(), "&3> &b" + perm.asNode().getGroupName(),
" ", " ",
"&7Click to remove this parent from " + holderName "&7Click to remove this parent from " + holderName
), CommandManager.AMPERSAND_CHAR)); ), CommandManager.AMPERSAND_CHAR));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, holderType, false); String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, holderType, false, !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty());
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> { return component -> {

View File

@ -157,8 +157,8 @@ public class SearchCommand extends SingleCommand {
permission = "&7 - (" + ent.getValue().getPermission() + ")"; permission = "&7 - (" + ent.getValue().getPermission() + ")";
} }
String s = "&3> &b" + ent.getKey() + permission + "&7 - " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlatform().getLocaleManager(), ent.getValue().asNode()); String s = "&3> &b" + ent.getKey() + permission + "&7 - " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), ent.getValue().asNode());
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue())).build(); TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build();
sender.sendMessage(message); sender.sendMessage(message);
} }
} }
@ -171,14 +171,14 @@ public class SearchCommand extends SingleCommand {
return " &8(&7expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiryUnixTime()) + "&8)"; return " &8(&7expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiryUnixTime()) + "&8)";
} }
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm) { private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm, LuckPermsPlugin plugin) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline( HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
"&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getPermission(), "&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getPermission(),
" ", " ",
"&7Click to remove this node from " + holderName "&7Click to remove this node from " + holderName
), CommandManager.AMPERSAND_CHAR)); ), CommandManager.AMPERSAND_CHAR));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, holderType, false); String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, holderType, false, !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty());
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> { return component -> {

View File

@ -503,7 +503,7 @@ public enum Message {
} }
public void send(Sender sender, Object... objects) { public void send(Sender sender, Object... objects) {
sender.sendMessage(asString(sender.getPlatform().getLocaleManager(), objects)); sender.sendMessage(asString(sender.getPlugin().getLocaleManager(), objects));
} }
private static String format(String s, Object... objects) { private static String format(String s, Object... objects) {

View File

@ -188,7 +188,7 @@ public final class NodeFactory {
return make(groupNode(group.getName()), server, world, temporary); return make(groupNode(group.getName()), server, world, temporary);
} }
public static String nodeAsCommand(Node node, String id, HolderType type, boolean set) { public static String nodeAsCommand(Node node, String id, HolderType type, boolean set, boolean explicitGlobalContext) {
StringBuilder sb = new StringBuilder(32); StringBuilder sb = new StringBuilder(32);
sb.append(type.toString()).append(" ").append(id).append(" "); sb.append(type.toString()).append(" ").append(id).append(" ");
@ -211,7 +211,7 @@ public final class NodeFactory {
sb.append(" ").append(node.getExpiryUnixTime()); sb.append(" ").append(node.getExpiryUnixTime());
} }
return appendContextToCommand(sb, node).toString(); return appendContextToCommand(sb, node, explicitGlobalContext).toString();
} }
if (node.getValue() && (node.isPrefix() || node.isSuffix())) { if (node.getValue() && (node.isPrefix() || node.isSuffix())) {
@ -246,7 +246,7 @@ public final class NodeFactory {
sb.append(" ").append(node.getExpiryUnixTime()); sb.append(" ").append(node.getExpiryUnixTime());
} }
return appendContextToCommand(sb, node).toString(); return appendContextToCommand(sb, node, explicitGlobalContext).toString();
} }
if (node.getValue() && node.isMeta()) { if (node.getValue() && node.isMeta()) {
@ -287,7 +287,7 @@ public final class NodeFactory {
} }
} }
return appendContextToCommand(sb, node).toString(); return appendContextToCommand(sb, node, explicitGlobalContext).toString();
} }
sb.append("permission "); sb.append("permission ");
@ -318,10 +318,17 @@ public final class NodeFactory {
} }
} }
return appendContextToCommand(sb, node).toString(); return appendContextToCommand(sb, node, explicitGlobalContext).toString();
} }
private static StringBuilder appendContextToCommand(StringBuilder sb, Node node) { private static StringBuilder appendContextToCommand(StringBuilder sb, Node node, boolean explicitGlobalContext) {
if (node.getFullContexts().isEmpty()) {
if (explicitGlobalContext) {
sb.append(" global");
}
return sb;
}
if (node.getServer().isPresent()) { if (node.getServer().isPresent()) {
sb.append(" server=").append(node.getServer().get()); sb.append(" server=").append(node.getServer().get());
} }

View File

@ -61,7 +61,7 @@ public final class AbstractSender<T> implements Sender {
} }
@Override @Override
public LuckPermsPlugin getPlatform() { public LuckPermsPlugin getPlugin() {
return this.platform; return this.platform;
} }

View File

@ -74,7 +74,7 @@ public abstract class DummySender implements Sender {
} }
@Override @Override
public LuckPermsPlugin getPlatform() { public LuckPermsPlugin getPlugin() {
return this.platform; return this.platform;
} }

View File

@ -42,11 +42,11 @@ import java.util.UUID;
public interface Sender { public interface Sender {
/** /**
* Gets the platform where the sender is from. * Gets the plugin instance the sender is from.
* *
* @return the plugin * @return the plugin
*/ */
LuckPermsPlugin getPlatform(); LuckPermsPlugin getPlugin();
/** /**
* Gets the sender's username * Gets the sender's username
@ -64,7 +64,7 @@ public interface Sender {
default String getNameWithLocation() { default String getNameWithLocation() {
String name = getName(); String name = getName();
ContextManager<?> contextManager = getPlatform().getContextManager(); ContextManager<?> contextManager = getPlugin().getContextManager();
if (contextManager == null) { if (contextManager == null) {
return name; return name;
} }

View File

@ -148,7 +148,7 @@ public class VerboseListener {
} }
// form a hoverevent from the check trace // form a hoverevent from the check trace
TextComponent textComponent = Message.VERBOSE_LOG.asComponent(this.notifiedSender.getPlatform().getLocaleManager(), TextComponent textComponent = Message.VERBOSE_LOG.asComponent(this.notifiedSender.getPlugin().getLocaleManager(),
data.getCheckTarget(), data.getCheckTarget(),
data.getPermission(), data.getPermission(),
getTristateColor(data.getResult()), getTristateColor(data.getResult()),
@ -158,7 +158,7 @@ public class VerboseListener {
// build the text // build the text
List<String> hover = new ArrayList<>(); List<String> hover = new ArrayList<>();
hover.add("&bOrigin: &2" + data.getCheckOrigin().name()); hover.add("&bOrigin: &2" + data.getCheckOrigin().name());
hover.add("&bContext: &r" + MessageUtils.contextSetToString(this.notifiedSender.getPlatform().getLocaleManager(), data.getCheckContext())); hover.add("&bContext: &r" + MessageUtils.contextSetToString(this.notifiedSender.getPlugin().getLocaleManager(), data.getCheckContext()));
hover.add("&bTrace: &r"); hover.add("&bTrace: &r");
Consumer<StackTraceElement> printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str)); Consumer<StackTraceElement> printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str));