Some misc refactoring
This commit is contained in:
parent
9809e591ad
commit
90246afd03
@ -29,8 +29,8 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.bukkit.compat.BukkitJsonMessageHandler;
|
import me.lucko.luckperms.bukkit.compat.BukkitJsonMessageHandler;
|
||||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||||
import me.lucko.luckperms.bukkit.compat.SpigotJsonMessageHandler;
|
import me.lucko.luckperms.bukkit.compat.SpigotJsonMessageHandler;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.util.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return sender.getName();
|
return sender.getName();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,7 +67,7 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return ((Player) sender).getUniqueId();
|
return ((Player) sender).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,8 +27,8 @@ package me.lucko.luckperms.bungee;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.util.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class BungeeSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof ProxiedPlayer) {
|
if (sender instanceof ProxiedPlayer) {
|
||||||
return sender.getName();
|
return sender.getName();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,7 +58,7 @@ public class BungeeSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof ProxiedPlayer) {
|
if (sender instanceof ProxiedPlayer) {
|
||||||
return ((ProxiedPlayer) sender).getUniqueId();
|
return ((ProxiedPlayer) sender).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,7 +75,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@ -86,12 +85,6 @@ import java.util.stream.Collectors;
|
|||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
public static final Pattern COMMAND_SEPARATOR_PATTERN = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
public static final Pattern COMMAND_SEPARATOR_PATTERN = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
||||||
|
|
||||||
public static final UUID CONSOLE_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
|
||||||
public static final String CONSOLE_NAME = "Console";
|
|
||||||
|
|
||||||
public static final UUID IMPORT_UUID = UUID.fromString("11111111-1111-1111-1111-111111111111");
|
|
||||||
public static final String IMPORT_NAME = "Import";
|
|
||||||
|
|
||||||
public static final char SECTION_CHAR = '\u00A7'; // §
|
public static final char SECTION_CHAR = '\u00A7'; // §
|
||||||
public static final char AMPERSAND_CHAR = '&';
|
public static final char AMPERSAND_CHAR = '&';
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import me.lucko.luckperms.common.command.CommandResult;
|
|||||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||||
|
import me.lucko.luckperms.common.context.ContextSetFormatter;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
@ -62,7 +63,7 @@ public class InfoCommand extends SingleCommand {
|
|||||||
|
|
||||||
Message.INFO_MIDDLE.send(sender,
|
Message.INFO_MIDDLE.send(sender,
|
||||||
plugin.getMessagingService().map(InternalMessagingService::getName).orElse("None"),
|
plugin.getMessagingService().map(InternalMessagingService::getName).orElse("None"),
|
||||||
plugin.getContextManager().getStaticContextString().orElse("None"),
|
ContextSetFormatter.toMinimalString(plugin.getContextManager().getStaticContext()).orElse("None"),
|
||||||
plugin.getBootstrap().getPlayerCount(),
|
plugin.getBootstrap().getPlayerCount(),
|
||||||
plugin.getConnectionListener().getUniqueConnections().size(),
|
plugin.getConnectionListener().getUniqueConnections().size(),
|
||||||
DurationFormatter.CONCISE_LOW_ACCURACY.format((System.currentTimeMillis() - plugin.getBootstrap().getStartupTime()) / 1000L),
|
DurationFormatter.CONCISE_LOW_ACCURACY.format((System.currentTimeMillis() - plugin.getBootstrap().getStartupTime()) / 1000L),
|
||||||
|
@ -56,7 +56,6 @@ import java.util.EnumSet;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.config.ConfigKeyTypes.booleanKey;
|
import static me.lucko.luckperms.common.config.ConfigKeyTypes.booleanKey;
|
||||||
@ -535,12 +534,14 @@ public final class ConfigKeys {
|
|||||||
*/
|
*/
|
||||||
public static final ConfigKey<String> TREE_VIEWER_URL_PATTERN = stringKey("tree-viewer-url", "https://luckperms.github.io/treeview/");
|
public static final ConfigKey<String> TREE_VIEWER_URL_PATTERN = stringKey("tree-viewer-url", "https://luckperms.github.io/treeview/");
|
||||||
|
|
||||||
private static final AtomicInteger ORDINAL_COUNTER = new AtomicInteger(0);
|
|
||||||
private static final Map<String, ConfigKey<?>> KEYS;
|
private static final Map<String, ConfigKey<?>> KEYS;
|
||||||
|
private static final int SIZE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Map<String, ConfigKey<?>> keys = new LinkedHashMap<>();
|
Map<String, ConfigKey<?>> keys = new LinkedHashMap<>();
|
||||||
Field[] values = ConfigKeys.class.getFields();
|
Field[] values = ConfigKeys.class.getFields();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
for (Field f : values) {
|
for (Field f : values) {
|
||||||
// ignore non-static fields
|
// ignore non-static fields
|
||||||
if (!Modifier.isStatic(f.getModifiers())) {
|
if (!Modifier.isStatic(f.getModifiers())) {
|
||||||
@ -556,14 +557,16 @@ public final class ConfigKeys {
|
|||||||
// get the key instance
|
// get the key instance
|
||||||
ConfigKeyTypes.BaseConfigKey<?> key = (ConfigKeyTypes.BaseConfigKey<?>) f.get(null);
|
ConfigKeyTypes.BaseConfigKey<?> key = (ConfigKeyTypes.BaseConfigKey<?>) f.get(null);
|
||||||
// set the ordinal value of the key.
|
// set the ordinal value of the key.
|
||||||
key.ordinal = ORDINAL_COUNTER.getAndIncrement();
|
key.ordinal = i++;
|
||||||
// add the key to the return map
|
// add the key to the return map
|
||||||
keys.put(f.getName(), key);
|
keys.put(f.getName(), key);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Exception processing field: " + f, e);
|
throw new RuntimeException("Exception processing field: " + f, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KEYS = ImmutableMap.copyOf(keys);
|
KEYS = ImmutableMap.copyOf(keys);
|
||||||
|
SIZE = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -584,7 +587,7 @@ public final class ConfigKeys {
|
|||||||
* @return how many keys are defined in this class
|
* @return how many keys are defined in this class
|
||||||
*/
|
*/
|
||||||
public static int size() {
|
public static int size() {
|
||||||
return ORDINAL_COUNTER.get();
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigKeys() {}
|
private ConfigKeys() {}
|
||||||
|
@ -40,12 +40,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation of {@link ContextManager} which caches content lookups.
|
* Base implementation of {@link ContextManager} which caches content lookups.
|
||||||
@ -143,29 +139,6 @@ public abstract class ContextManager<T> {
|
|||||||
return this.staticLookupCache.get();
|
return this.staticLookupCache.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string form of the managers static context
|
|
||||||
*
|
|
||||||
* <p>Returns an empty optional if the set is empty.</p>
|
|
||||||
*
|
|
||||||
* @return a string representation of {@link #getStaticContext()}
|
|
||||||
*/
|
|
||||||
public Optional<String> getStaticContextString() {
|
|
||||||
Set<Map.Entry<String, String>> entries = getStaticContext().toSet();
|
|
||||||
if (entries.isEmpty()) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
// effectively: if entries contains any non-server keys
|
|
||||||
if (entries.stream().anyMatch(pair -> !pair.getKey().equals(Contexts.SERVER_KEY))) {
|
|
||||||
// return all entries in 'key=value' form
|
|
||||||
return Optional.of(entries.stream().map(pair -> pair.getKey() + "=" + pair.getValue()).collect(Collectors.joining(";")));
|
|
||||||
} else {
|
|
||||||
// just return the server ids, without the 'server='
|
|
||||||
return Optional.of(entries.stream().map(Map.Entry::getValue).collect(Collectors.joining(";")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.context;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public final class ContextSetFormatter {
|
||||||
|
private ContextSetFormatter() {}
|
||||||
|
|
||||||
|
public static Optional<String> toMinimalString(ContextSet contextSet) {
|
||||||
|
Set<Map.Entry<String, String>> entries = contextSet.toSet();
|
||||||
|
if (entries.isEmpty()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// effectively: if entries contains any non-server keys
|
||||||
|
if (entries.stream().anyMatch(pair -> !pair.getKey().equals(Contexts.SERVER_KEY))) {
|
||||||
|
// return all entries in 'key=value' form
|
||||||
|
return Optional.of(entries.stream().map(pair -> pair.getKey() + "=" + pair.getValue()).collect(Collectors.joining(";")));
|
||||||
|
} else {
|
||||||
|
// just return the server ids, without the 'server='
|
||||||
|
return Optional.of(entries.stream().map(Map.Entry::getValue).collect(Collectors.joining(";")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.model.manager.user;
|
package me.lucko.luckperms.common.model.manager.user;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableCollection;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.LocalizedNode;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
@ -167,25 +170,25 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSave(User user) {
|
public boolean shouldSave(User user) {
|
||||||
if (user.enduringData().immutable().size() != 1) {
|
ImmutableCollection<LocalizedNode> nodes = user.enduringData().immutable().values();
|
||||||
|
if (nodes.size() != 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Node node : user.enduringData().immutable().values()) {
|
LocalizedNode onlyNode = nodes.iterator().next();
|
||||||
// There's only one.
|
if (!onlyNode.isGroupNode()) {
|
||||||
if (!node.isGroupNode()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.isTemporary() || node.isServerSpecific() || node.isWorldSpecific()) {
|
if (onlyNode.isTemporary() || onlyNode.isServerSpecific() || onlyNode.isWorldSpecific()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node.getGroupName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
if (!onlyNode.getGroupName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
||||||
// The user's only node is not the default group one.
|
// The user's only node is not the default group one.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Not in the default primary group
|
// Not in the default primary group
|
||||||
return !user.getPrimaryGroup().getStoredValue().orElse(NodeFactory.DEFAULT_GROUP_NAME).equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME);
|
return !user.getPrimaryGroup().getStoredValue().orElse(NodeFactory.DEFAULT_GROUP_NAME).equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME);
|
||||||
|
@ -34,7 +34,9 @@ package me.lucko.luckperms.common.plugin.logging;
|
|||||||
public interface PluginLogger {
|
public interface PluginLogger {
|
||||||
|
|
||||||
void info(String s);
|
void info(String s);
|
||||||
|
|
||||||
void warn(String s);
|
void warn(String s);
|
||||||
|
|
||||||
void severe(String s);
|
void severe(String s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.common.sender;
|
package me.lucko.luckperms.common.sender;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.util.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ public abstract class DummySender implements Sender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DummySender(LuckPermsPlugin plugin) {
|
public DummySender(LuckPermsPlugin plugin) {
|
||||||
this(plugin, CommandManager.IMPORT_UUID, CommandManager.IMPORT_NAME);
|
this(plugin, Sender.IMPORT_UUID, Sender.IMPORT_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void consumeMessage(String s);
|
protected abstract void consumeMessage(String s);
|
||||||
|
@ -29,6 +29,7 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.context.ContextManager;
|
import me.lucko.luckperms.common.context.ContextManager;
|
||||||
|
import me.lucko.luckperms.common.context.ContextSetFormatter;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
@ -40,6 +41,15 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public interface Sender {
|
public interface Sender {
|
||||||
|
|
||||||
|
/** The uuid used by the console sender. */
|
||||||
|
UUID CONSOLE_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||||
|
/** The name used by the console sender. */
|
||||||
|
String CONSOLE_NAME = "Console";
|
||||||
|
/** The uuid used by the 'import' sender. */
|
||||||
|
UUID IMPORT_UUID = UUID.fromString("11111111-1111-1111-1111-111111111111");
|
||||||
|
/** The name used by the 'import' sender. */
|
||||||
|
String IMPORT_NAME = "Import";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the plugin instance the sender is from.
|
* Gets the plugin instance the sender is from.
|
||||||
*
|
*
|
||||||
@ -68,8 +78,7 @@ public interface Sender {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String location = ContextSetFormatter.toMinimalString(contextManager.getStaticContext()).orElse(null);
|
||||||
String location = contextManager.getStaticContextString().orElse(null);
|
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -82,16 +91,20 @@ public interface Sender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the sender's unique id. See {@link CommandManager#CONSOLE_UUID} for the console's UUID representation.
|
* Gets the sender's unique id.
|
||||||
|
*
|
||||||
|
* <p>See {@link #CONSOLE_UUID} for the console's UUID representation.</p>
|
||||||
*
|
*
|
||||||
* @return the sender's uuid
|
* @return the sender's uuid
|
||||||
*/
|
*/
|
||||||
UUID getUuid();
|
UUID getUuid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message back to the Sender
|
* Send a message to the Sender.
|
||||||
*
|
*
|
||||||
* @param message the message to send. Supports '§' for message formatting.
|
* <p>Supports {@link CommandManager#SECTION_CHAR} for message formatting.</p>
|
||||||
|
*
|
||||||
|
* @param message the message to send.
|
||||||
*/
|
*/
|
||||||
void sendMessage(String message);
|
void sendMessage(String message);
|
||||||
|
|
||||||
@ -134,7 +147,7 @@ public interface Sender {
|
|||||||
* @return if the sender is the console
|
* @return if the sender is the console
|
||||||
*/
|
*/
|
||||||
default boolean isConsole() {
|
default boolean isConsole() {
|
||||||
return CommandManager.CONSOLE_UUID.equals(getUuid()) || CommandManager.IMPORT_UUID.equals(getUuid());
|
return CONSOLE_UUID.equals(getUuid()) || IMPORT_UUID.equals(getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +156,7 @@ public interface Sender {
|
|||||||
* @return if the sender is an import process
|
* @return if the sender is an import process
|
||||||
*/
|
*/
|
||||||
default boolean isImport() {
|
default boolean isImport() {
|
||||||
return CommandManager.IMPORT_UUID.equals(getUuid());
|
return IMPORT_UUID.equals(getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package me.lucko.luckperms.nukkit;
|
package me.lucko.luckperms.nukkit;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.util.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class NukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return sender.getName();
|
return sender.getName();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,7 +57,7 @@ public class NukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return ((Player) sender).getUniqueId();
|
return ((Player) sender).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,6 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.calculator.CalculatorFactory;
|
import me.lucko.luckperms.common.calculator.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
@ -257,7 +256,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public Sender getConsoleSender() {
|
public Sender getConsoleSender() {
|
||||||
if (!this.bootstrap.getGame().isServerAvailable()) {
|
if (!this.bootstrap.getGame().isServerAvailable()) {
|
||||||
return new DummySender(this, CommandManager.CONSOLE_UUID, CommandManager.CONSOLE_NAME) {
|
return new DummySender(this, Sender.CONSOLE_UUID, Sender.CONSOLE_NAME) {
|
||||||
@Override
|
@Override
|
||||||
protected void consumeMessage(String s) {
|
protected void consumeMessage(String s) {
|
||||||
LPSpongePlugin.this.bootstrap.getPluginLogger().info(s);
|
LPSpongePlugin.this.bootstrap.getPluginLogger().info(s);
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package me.lucko.luckperms.sponge;
|
package me.lucko.luckperms.sponge;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.sponge.service.CompatibilityUtil;
|
import me.lucko.luckperms.sponge.service.CompatibilityUtil;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class SpongeSenderFactory extends SenderFactory<CommandSource> {
|
|||||||
if (source instanceof Player) {
|
if (source instanceof Player) {
|
||||||
return source.getName();
|
return source.getName();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,7 +58,7 @@ public class SpongeSenderFactory extends SenderFactory<CommandSource> {
|
|||||||
if (source instanceof Player) {
|
if (source instanceof Player) {
|
||||||
return ((Player) source).getUniqueId();
|
return ((Player) source).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,8 +29,8 @@ import com.velocitypowered.api.command.CommandSource;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.util.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
import me.lucko.luckperms.velocity.service.CompatibilityUtil;
|
import me.lucko.luckperms.velocity.service.CompatibilityUtil;
|
||||||
@ -49,7 +49,7 @@ public class VelocitySenderFactory extends SenderFactory<CommandSource> {
|
|||||||
if (source instanceof Player) {
|
if (source instanceof Player) {
|
||||||
return ((Player) source).getUsername();
|
return ((Player) source).getUsername();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,7 +57,7 @@ public class VelocitySenderFactory extends SenderFactory<CommandSource> {
|
|||||||
if (source instanceof Player) {
|
if (source instanceof Player) {
|
||||||
return ((Player) source).getUniqueId();
|
return ((Player) source).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user