Move some things around a bit

This commit is contained in:
Luck 2019-11-14 19:43:57 +00:00
parent 79c10c986e
commit 81cbe02a9c
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
11 changed files with 22 additions and 28 deletions

View File

@ -30,7 +30,6 @@ import com.google.common.base.Strings;
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator;
import me.lucko.luckperms.common.cacheddata.type.MetaCache;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
import me.lucko.luckperms.common.model.Group;
@ -38,6 +37,7 @@ import me.lucko.luckperms.common.model.PermissionHolder;
import me.lucko.luckperms.common.node.types.Meta;
import me.lucko.luckperms.common.node.types.Prefix;
import me.lucko.luckperms.common.node.types.Suffix;
import me.lucko.luckperms.common.util.TextUtils;
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
import net.luckperms.api.context.DefaultContextKeys;
@ -255,8 +255,8 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
}
private void logMsg(String format, Object... args) {
this.plugin.getLogger().info("[VAULT-CHAT] " + String.format(format, args)
.replace(CommandManager.SECTION_CHAR, '$')
.replace(CommandManager.AMPERSAND_CHAR, '$')
.replace(TextUtils.SECTION_CHAR, '$')
.replace(TextUtils.AMPERSAND_CHAR, '$')
);
}

View File

@ -32,7 +32,6 @@ import me.lucko.luckperms.bukkit.context.BukkitContextManager;
import me.lucko.luckperms.common.cacheddata.type.PermissionCache;
import me.lucko.luckperms.common.calculator.processor.MapProcessor;
import me.lucko.luckperms.common.calculator.result.TristateResult;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.model.HolderType;
@ -41,6 +40,7 @@ import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.model.manager.group.GroupManager;
import me.lucko.luckperms.common.node.factory.NodeBuilders;
import me.lucko.luckperms.common.node.types.Inheritance;
import me.lucko.luckperms.common.util.TextUtils;
import me.lucko.luckperms.common.util.Uuids;
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
@ -374,8 +374,8 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
}
private void logMsg(String format, Object... args) {
this.plugin.getLogger().info("[VAULT-PERMS] " + String.format(format, args)
.replace(CommandManager.SECTION_CHAR, '$')
.replace(CommandManager.AMPERSAND_CHAR, '$')
.replace(TextUtils.SECTION_CHAR, '$')
.replace(TextUtils.AMPERSAND_CHAR, '$')
);
}

View File

@ -84,9 +84,6 @@ import java.util.stream.Collectors;
public class CommandManager {
public static final Pattern COMMAND_SEPARATOR_PATTERN = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
public static final char SECTION_CHAR = '\u00A7'; // §
public static final char AMPERSAND_CHAR = '&';
private final LuckPermsPlugin plugin;
// the default executor to run commands on
@ -276,7 +273,7 @@ public class CommandManager {
.forEach(c -> {
String permission = c.getPermission().map(CommandPermission::getPermission).orElse("None");
TextComponent component = TextUtils.fromLegacy("&3> &a" + String.format(c.getUsage(), label), AMPERSAND_CHAR)
TextComponent component = TextUtils.fromLegacy("&3> &a" + String.format(c.getUsage(), label), TextUtils.AMPERSAND_CHAR)
.toBuilder().applyDeep(comp -> {
comp.hoverEvent(HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline(
"&bCommand: &2" + c.getName(),
@ -285,7 +282,7 @@ public class CommandManager {
"&bPermission: &2" + permission,
" ",
"&7Click to auto-complete."
), AMPERSAND_CHAR)));
), TextUtils.AMPERSAND_CHAR)));
comp.clickEvent(ClickEvent.suggestCommand(String.format(c.getUsage(), label)));
}).build();
sender.sendMessage(component);

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.common.commands.generic.parent;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.CommandResult;
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
@ -119,7 +118,7 @@ public class ParentInfo extends SharedSubCommand {
s += "\n&2 expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiry().getEpochSecond());
}
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build();
TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build();
sender.sendMessage(message);
}
@ -141,7 +140,7 @@ public class ParentInfo extends SharedSubCommand {
"&3> &f" + node.getGroupName(),
" ",
"&7Click to remove this parent from " + holder.getFormattedDisplayName()
), CommandManager.AMPERSAND_CHAR));
), TextUtils.AMPERSAND_CHAR));
String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName();
boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty();

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.common.commands.generic.permission;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.CommandResult;
import me.lucko.luckperms.common.command.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
@ -119,7 +118,7 @@ public class PermissionInfo extends SharedSubCommand {
s += "\n&2- expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiry().getEpochSecond());
}
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build();
TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build();
sender.sendMessage(message);
}

View File

@ -30,7 +30,6 @@ import com.google.common.collect.Maps;
import me.lucko.luckperms.common.bulkupdate.comparison.Constraint;
import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison;
import me.lucko.luckperms.common.cache.LoadingMap;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.CommandResult;
import me.lucko.luckperms.common.command.abstraction.SubCommand;
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
@ -148,7 +147,7 @@ public class GroupListMembers extends SubCommand<Group> {
for (Map.Entry<String, HeldNode<T>> ent : mappedContent) {
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().getNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), ent.getValue().getNode());
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build();
TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build();
sender.sendMessage(message);
}
}
@ -166,7 +165,7 @@ public class GroupListMembers extends SubCommand<Group> {
"&3> &b" + ((InheritanceNode) perm.getNode()).getGroupName(),
" ",
"&7Click to remove this parent from " + holderName
), CommandManager.AMPERSAND_CHAR));
), TextUtils.AMPERSAND_CHAR));
boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty();
String command = "/" + label + " " + NodeCommandFactory.generateCommand(perm.getNode(), holderName, holderType, false, explicitGlobalContext);

View File

@ -31,7 +31,6 @@ import me.lucko.luckperms.common.bulkupdate.comparison.Comparison;
import me.lucko.luckperms.common.bulkupdate.comparison.Constraint;
import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison;
import me.lucko.luckperms.common.cache.LoadingMap;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.CommandResult;
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
import me.lucko.luckperms.common.command.access.CommandPermission;
@ -156,7 +155,7 @@ public class SearchCommand extends SingleCommand {
}
String s = "&3> &b" + ent.getKey() + permission + "&7 - " + (ent.getValue().getNode().getValue() ? "&a" : "&c") + ent.getValue().getNode().getValue() + getNodeExpiryString(ent.getValue().getNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), ent.getValue().getNode());
TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build();
TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build();
sender.sendMessage(message);
}
}
@ -174,7 +173,7 @@ public class SearchCommand extends SingleCommand {
"&3> " + (perm.getNode().getValue() ? "&a" : "&c") + perm.getNode().getKey(),
" ",
"&7Click to remove this node from " + holderName
), CommandManager.AMPERSAND_CHAR));
), TextUtils.AMPERSAND_CHAR));
boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty();
String command = "/" + label + " " + NodeCommandFactory.generateCommand(perm.getNode(), holderName, holderType, false, explicitGlobalContext);

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.common.locale.message;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.util.TextUtils;
@ -517,7 +516,7 @@ public enum Message {
}
public TextComponent asComponent(@Nullable LocaleManager localeManager, Object... objects) {
return TextUtils.fromLegacy(format(localeManager, objects), CommandManager.AMPERSAND_CHAR);
return TextUtils.fromLegacy(format(localeManager, objects), TextUtils.AMPERSAND_CHAR);
}
public void send(Sender sender, Object... objects) {

View File

@ -25,10 +25,10 @@
package me.lucko.luckperms.common.sender;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.access.CommandPermission;
import me.lucko.luckperms.common.context.ContextManager;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.util.TextUtils;
import net.kyori.text.Component;
import net.luckperms.api.context.DefaultContextKeys;
@ -112,7 +112,7 @@ public interface Sender {
/**
* Send a message to the Sender.
*
* <p>Supports {@link CommandManager#SECTION_CHAR} for message formatting.</p>
* <p>Supports {@link TextUtils#SECTION_CHAR} for message formatting.</p>
*
* @param message the message to send.
*/

View File

@ -36,6 +36,9 @@ import java.util.stream.Stream;
public final class TextUtils {
private TextUtils() {}
public static final char SECTION_CHAR = '\u00A7'; // §
public static final char AMPERSAND_CHAR = '&';
public static String joinNewline(String... strings) {
return joinNewline(Arrays.stream(strings));
}

View File

@ -28,7 +28,6 @@ package me.lucko.luckperms.common.verbose;
import com.google.gson.JsonObject;
import me.lucko.luckperms.common.calculator.result.TristateResult;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.utils.MessageUtils;
import me.lucko.luckperms.common.locale.message.Message;
import me.lucko.luckperms.common.sender.Sender;
@ -232,7 +231,7 @@ public class VerboseListener {
}
// send the message
HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline(hover.stream()), CommandManager.AMPERSAND_CHAR));
HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline(hover.stream()), TextUtils.AMPERSAND_CHAR));
TextComponent text = textComponent.toBuilder().applyDeep(comp -> comp.hoverEvent(hoverEvent)).build();
this.notifiedSender.sendMessage(text);
}