Update /lp info output
This commit is contained in:
parent
400f3a9156
commit
3c44388883
@ -44,6 +44,7 @@ import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.core.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ -82,4 +83,16 @@ public class BukkitCalculatorFactory extends AbstractCalculatorFactory {
|
||||
|
||||
return registerCalculator(new PermissionCalculator(plugin, user.getFriendlyName(), processors.build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveProcessors() {
|
||||
ImmutableList.Builder<String> ret = ImmutableList.builder();
|
||||
ret.add("Map");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_CHILD_PERMISSIONS)) ret.add("Child");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_ATTACHMENT_PERMISSIONS)) ret.add("Attachment");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ret.add("Regex");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) ret.add("Wildcard");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) ret.add("Defaults");
|
||||
return ret.build();
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,8 @@ public class BukkitListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getUniqueConnections().add(e.getUniqueId());
|
||||
|
||||
/* Actually process the login for the connection.
|
||||
We do this here to delay the login until the data is ready.
|
||||
If the login gets cancelled later on, then this will be cleaned up.
|
||||
|
@ -107,6 +107,8 @@ import java.util.stream.Collectors;
|
||||
@Getter
|
||||
public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
private Set<UUID> ignoringLogs;
|
||||
private Set<UUID> uniqueConnections;
|
||||
private long startTime;
|
||||
private LPBukkitScheduler scheduler;
|
||||
private BukkitCommand commandManager;
|
||||
private VaultHook vaultHook = null;
|
||||
@ -159,9 +161,11 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
}
|
||||
|
||||
private void enable() {
|
||||
startTime = System.currentTimeMillis();
|
||||
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
||||
|
||||
ignoringLogs = ConcurrentHashMap.newKeySet();
|
||||
uniqueConnections = ConcurrentHashMap.newKeySet();
|
||||
verboseHandler = new VerboseHandler(scheduler.getAsyncBukkitExecutor(), getVersion());
|
||||
permissionVault = new PermissionVault(scheduler.getAsyncBukkitExecutor());
|
||||
|
||||
@ -349,7 +353,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
});
|
||||
}
|
||||
|
||||
getLog().info("Successfully enabled.");
|
||||
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - startTime) + "ms)");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -642,16 +646,8 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
public LinkedHashMap<String, Object> getExtraInfo() {
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("Vault Enabled", vaultHook != null);
|
||||
map.put("Vault Server", configuration.get(ConfigKeys.VAULT_SERVER));
|
||||
map.put("Bukkit Defaults count", defaultsProvider.size());
|
||||
map.put("Bukkit Child Permissions count", childPermissionProvider.getPermissions().size());
|
||||
map.put("Vault Including Global", configuration.get(ConfigKeys.VAULT_INCLUDING_GLOBAL));
|
||||
map.put("Vault Ignoring World", configuration.get(ConfigKeys.VAULT_IGNORE_WORLD));
|
||||
map.put("Vault Primary Group Overrides", configuration.get(ConfigKeys.VAULT_PRIMARY_GROUP_OVERRIDES));
|
||||
map.put("Vault Debug", configuration.get(ConfigKeys.VAULT_DEBUG));
|
||||
map.put("OPs Enabled", configuration.get(ConfigKeys.OPS_ENABLED));
|
||||
map.put("Auto OP", configuration.get(ConfigKeys.AUTO_OP));
|
||||
map.put("Commands Allow OPs", configuration.get(ConfigKeys.COMMANDS_ALLOW_OP));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.core.model.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class BungeeCalculatorFactory extends AbstractCalculatorFactory {
|
||||
private final LPBungeePlugin plugin;
|
||||
@ -59,4 +61,13 @@ public class BungeeCalculatorFactory extends AbstractCalculatorFactory {
|
||||
|
||||
return registerCalculator(new PermissionCalculator(plugin, user.getFriendlyName(), processors.build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveProcessors() {
|
||||
ImmutableList.Builder<String> ret = ImmutableList.builder();
|
||||
ret.add("Map");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ret.add("Regex");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) ret.add("Wildcards");
|
||||
return ret.build();
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,8 @@ public class BungeeListener implements Listener {
|
||||
|
||||
|
||||
plugin.doAsync(() -> {
|
||||
plugin.getUniqueConnections().add(c.getUniqueId());
|
||||
|
||||
/* Actually process the login for the connection.
|
||||
We do this here to delay the login until the data is ready.
|
||||
If the login gets cancelled later on, then this will be cleaned up.
|
||||
|
@ -91,6 +91,8 @@ import java.util.stream.Collectors;
|
||||
@Getter
|
||||
public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
|
||||
private Set<UUID> uniqueConnections = ConcurrentHashMap.newKeySet();
|
||||
private long startTime;
|
||||
private LuckPermsScheduler scheduler;
|
||||
private CommandManager commandManager;
|
||||
private LuckPermsConfiguration configuration;
|
||||
@ -125,6 +127,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
startTime = System.currentTimeMillis();
|
||||
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
||||
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
||||
permissionVault = new PermissionVault(scheduler.async());
|
||||
@ -256,7 +259,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||
scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
|
||||
|
||||
getLog().info("Successfully enabled.");
|
||||
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - startTime) + "ms)");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,6 +28,8 @@ package me.lucko.luckperms.common.calculators;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.common.core.model.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a calculator instance given a set of contexts
|
||||
*/
|
||||
@ -42,6 +44,13 @@ public interface CalculatorFactory {
|
||||
*/
|
||||
PermissionCalculator build(Contexts contexts, User user);
|
||||
|
||||
/**
|
||||
* Gets the processors which are currently being added to built calculators
|
||||
*
|
||||
* @return a list of processors
|
||||
*/
|
||||
List<String> getActiveProcessors();
|
||||
|
||||
/**
|
||||
* Invalidates all calculators build by this factory
|
||||
*/
|
||||
|
@ -37,13 +37,13 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.messaging.NoopMessagingService;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.lucko.luckperms.common.commands.utils.Util.formatBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InfoCommand extends SingleCommand {
|
||||
public InfoCommand(LocaleManager locale) {
|
||||
@ -53,31 +53,34 @@ public class InfoCommand extends SingleCommand {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
final LuckPermsConfiguration c = plugin.getConfiguration();
|
||||
Message.INFO.send(sender,
|
||||
|
||||
Message.INFO_TOP.send(sender,
|
||||
plugin.getVersion(),
|
||||
plugin.getServerType().getFriendlyName(),
|
||||
plugin.getStorage().getName(),
|
||||
c.get(ConfigKeys.SERVER),
|
||||
c.get(ConfigKeys.SYNC_TIME),
|
||||
plugin.getServerName(),
|
||||
plugin.getServerVersion()
|
||||
);
|
||||
|
||||
Map<String, String> storageInfo = plugin.getStorage().getMeta();
|
||||
|
||||
Message.EMPTY.send(sender, "&f- &bStorage:");
|
||||
Message.EMPTY.send(sender, "&f- &3Type: &f" + plugin.getStorage().getName());
|
||||
for (Map.Entry<String, String> e : storageInfo.entrySet()) {
|
||||
Message.EMPTY.send(sender, "&f- &3" + e.getKey() + ": " + formatValue(e.getValue()));
|
||||
}
|
||||
|
||||
Message.INFO_MIDDLE.send(sender,
|
||||
plugin.getMessagingService() instanceof NoopMessagingService ? "None" : plugin.getMessagingService().getName(),
|
||||
c.get(ConfigKeys.SERVER),
|
||||
plugin.getPlayerCount(),
|
||||
plugin.getUniqueConnections().size(),
|
||||
DateUtil.formatTime((System.currentTimeMillis() - plugin.getStartTime()) / 1000L),
|
||||
plugin.getUserManager().getAll().size(),
|
||||
plugin.getGroupManager().getAll().size(),
|
||||
plugin.getTrackManager().getAll().size(),
|
||||
plugin.getStorage().getLog().join().getContent().size(),
|
||||
plugin.getUuidCache().getSize(),
|
||||
plugin.getLocaleManager().getSize(),
|
||||
plugin.getPreProcessContexts(false).size(),
|
||||
plugin.getContextManager().getCalculatorsSize(),
|
||||
plugin.getPermissionVault().getSize(),
|
||||
formatBoolean(c.get(ConfigKeys.USE_SERVER_UUIDS)),
|
||||
formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_PERMS)),
|
||||
formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS)),
|
||||
formatBoolean(c.get(ConfigKeys.APPLYING_GLOBAL_GROUPS)),
|
||||
formatBoolean(c.get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS)),
|
||||
formatBoolean(c.get(ConfigKeys.APPLYING_WILDCARDS)),
|
||||
formatBoolean(c.get(ConfigKeys.APPLYING_REGEX)),
|
||||
formatBoolean(c.get(ConfigKeys.APPLYING_SHORTHAND))
|
||||
plugin.getCalculatorFactory().getActiveProcessors().stream().collect(Collectors.joining(", "))
|
||||
);
|
||||
|
||||
LinkedHashMap<String, Object> platformInfo = plugin.getExtraInfo();
|
||||
|
@ -172,34 +172,24 @@ public enum Message {
|
||||
UPDATE_TASK_PUSH_FAILURE("&cError whilst pushing changes to other servers.", true),
|
||||
UPDATE_TASK_PUSH_FAILURE_NOT_SETUP("&cError whilst pushing changes to other servers. A messaging service has not been configured.", true),
|
||||
RELOAD_CONFIG_SUCCESS("&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted.)", true),
|
||||
INFO(
|
||||
INFO_TOP(
|
||||
"{PREFIX}&2Running &bLuckPerms v{0}&2 by &bLuck&2." + "\n" +
|
||||
"{PREFIX}&f- &3Platform: &f{1}" + "\n" +
|
||||
"{PREFIX}&f- &3Storage Method: &f{2}" + "\n" +
|
||||
"{PREFIX}&f- &3Server Name: &f{3}" + "\n" +
|
||||
"{PREFIX}&f- &3Sync Interval: &a{4} &fminutes" + "\n" +
|
||||
"{PREFIX}&f- &3Messaging Service: &f{5}" + "\n" +
|
||||
"{PREFIX}&f- &bCounts:" + "\n" +
|
||||
"{PREFIX}&f- &3Online Players: &a{6}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Users: &a{7}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Groups: &a{8}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Tracks: &a{9}" + "\n" +
|
||||
"{PREFIX}&f- &3Log size: &a{10}" + "\n" +
|
||||
"{PREFIX}&f- &3UUID Cache size: &a{11}" + "\n" +
|
||||
"{PREFIX}&f- &3Translations loaded: &a{12}" + "\n" +
|
||||
"{PREFIX}&f- &3Pre-process contexts: &a{13}" + "\n" +
|
||||
"{PREFIX}&f- &3Context Calculators: &a{14}" + "\n" +
|
||||
"{PREFIX}&f- &3Unique permissions: &a{15}" + "\n" +
|
||||
"{PREFIX}&f- &bConfiguration:" + "\n" +
|
||||
"{PREFIX}&f- &3Use Server UUIDs: {16}" + "\n" +
|
||||
"{PREFIX}&f- &bPermission Calculation:" + "\n" +
|
||||
"{PREFIX}&f- &3Including Global: {17}" + "\n" +
|
||||
"{PREFIX}&f- &3Including Global World: {18}" + "\n" +
|
||||
"{PREFIX}&f- &3Applying Global Groups: {19}" + "\n" +
|
||||
"{PREFIX}&f- &3Applying Global World Groups: {20}" + "\n" +
|
||||
"{PREFIX}&f- &3Applying Wildcards: {21}" + "\n" +
|
||||
"{PREFIX}&f- &3Applying Regex: {22}" + "\n" +
|
||||
"{PREFIX}&f- &3Applying Shorthand: {23}",
|
||||
"{PREFIX}&f- &3Server Brand: &f{2}" + "\n" +
|
||||
"{PREFIX}&f- &3Server Version: &f{3}",
|
||||
false
|
||||
),
|
||||
INFO_MIDDLE(
|
||||
"{PREFIX}&f- &bMessaging Type: &f{0}" + "\n" +
|
||||
"{PREFIX}&f- &bInstance:" + "\n" +
|
||||
"{PREFIX}&f- &3Server Name: &f{1}" + "\n" +
|
||||
"{PREFIX}&f- &3Online Players: &a{2}" + "\n" +
|
||||
"{PREFIX}&f- &3Unique Connections: &a{3}" + "\n" +
|
||||
"{PREFIX}&f- &3Uptime: &7{4}" + "\n" +
|
||||
"{PREFIX}&f- &3Local Data: &a{5} &7users, &a{6} &7groups, &a{7} &7tracks" + "\n" +
|
||||
"{PREFIX}&f- &3Context Calculators: &a{8}" + "\n" +
|
||||
"{PREFIX}&f- &3Known permissions: &a{9}" + "\n" +
|
||||
"{PREFIX}&f- &3Active processors: &7{10}",
|
||||
false
|
||||
),
|
||||
CREATE_GROUP_ERROR("There was an error whilst creating the group.", true),
|
||||
|
@ -222,6 +222,13 @@ public interface LuckPermsPlugin {
|
||||
*/
|
||||
String getServerVersion();
|
||||
|
||||
/**
|
||||
* Gets the time when the plugin first started in millis.
|
||||
*
|
||||
* @return the enable time
|
||||
*/
|
||||
long getStartTime();
|
||||
|
||||
/**
|
||||
* Gets the file watcher running on the platform, or null if it's not enabled.
|
||||
*
|
||||
@ -345,6 +352,13 @@ public interface LuckPermsPlugin {
|
||||
*/
|
||||
Sender getConsoleSender();
|
||||
|
||||
/**
|
||||
* Gets the unique players which have connected to the server since it started.
|
||||
*
|
||||
* @return the unique connections
|
||||
*/
|
||||
Set<UUID> getUniqueConnections();
|
||||
|
||||
/**
|
||||
* Gets a set of Contexts that should be pre-processed in advance
|
||||
*
|
||||
|
@ -46,6 +46,7 @@ import me.lucko.luckperms.common.storage.wrappings.BufferedOutputStorage;
|
||||
import me.lucko.luckperms.common.storage.wrappings.PhasedStorage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -258,5 +259,6 @@ public class AbstractStorage implements Storage {
|
||||
void setAcceptingLogins(boolean b);
|
||||
void init();
|
||||
void shutdown();
|
||||
Map<String, String> getMeta();
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import me.lucko.luckperms.common.data.Log;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.storage.backing.AbstractBacking;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -70,6 +71,16 @@ public class SplitBacking extends AbstractBacking {
|
||||
backing.values().forEach(AbstractBacking::shutdown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
ret.put("Types", types.toString());
|
||||
for (AbstractBacking backing : backing.values()) {
|
||||
ret.putAll(backing.getMeta());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) {
|
||||
return backing.get(types.get("log")).logAction(entry);
|
||||
|
@ -37,6 +37,7 @@ import me.lucko.luckperms.common.core.model.User;
|
||||
import me.lucko.luckperms.common.data.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -60,6 +61,8 @@ public interface Storage {
|
||||
|
||||
void shutdown();
|
||||
|
||||
Map<String, String> getMeta();
|
||||
|
||||
CompletableFuture<Boolean> logAction(LogEntry entry);
|
||||
|
||||
CompletableFuture<Log> getLog();
|
||||
|
@ -39,7 +39,9 @@ import me.lucko.luckperms.common.core.model.User;
|
||||
import me.lucko.luckperms.common.data.Log;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -60,6 +62,10 @@ public abstract class AbstractBacking {
|
||||
|
||||
public abstract void shutdown();
|
||||
|
||||
public Map<String, String> getMeta() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public abstract boolean logAction(LogEntry entry);
|
||||
|
||||
public abstract Log getLog();
|
||||
|
@ -60,6 +60,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -182,6 +183,29 @@ public class MongoDBBacking extends AbstractBacking {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
boolean success = true;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
database.runCommand(new Document("ping", 1));
|
||||
} catch (Exception e) {
|
||||
success = false;
|
||||
}
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
|
||||
if (success) {
|
||||
ret.put("Ping", "&a" + duration + "ms");
|
||||
ret.put("Connected", "true");
|
||||
} else {
|
||||
ret.put("Connected", "false");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) {
|
||||
return call(() -> {
|
||||
|
@ -208,6 +208,11 @@ public class SQLBacking extends AbstractBacking {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
return provider.getMeta();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) {
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -29,11 +29,13 @@ import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
abstract class FlatfileProvider extends SQLProvider {
|
||||
protected static final DecimalFormat DF = new DecimalFormat("#.00");
|
||||
|
||||
private final File file;
|
||||
protected final File file;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private WrappedConnection connection;
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
package me.lucko.luckperms.common.storage.backing.sqlprovider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class H2Provider extends FlatfileProvider {
|
||||
public H2Provider(File file) {
|
||||
@ -38,6 +40,20 @@ public class H2Provider extends FlatfileProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
|
||||
File databaseFile = new File(super.file.getParent(), "luckperms-h2.mv.db");
|
||||
if (databaseFile.exists()) {
|
||||
ret.put("File Size", DF.format(databaseFile.length() / 1048576) + "MB");
|
||||
} else {
|
||||
ret.put("File Size", "0MB");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverClass() {
|
||||
return "org.h2.Driver";
|
||||
|
@ -32,6 +32,9 @@ import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MySQLProvider extends SQLProvider {
|
||||
@ -113,6 +116,31 @@ public class MySQLProvider extends SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
boolean success = true;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
try (Connection c = hikari.getConnection()) {
|
||||
try (Statement s = c.createStatement()) {
|
||||
s.execute("/* ping */ SELECT 1");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
success = false;
|
||||
}
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
|
||||
if (success) {
|
||||
ret.put("Ping", "&a" + duration + "ms");
|
||||
ret.put("Connected", "true");
|
||||
} else {
|
||||
ret.put("Connected", "false");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedConnection getConnection() throws SQLException {
|
||||
Connection connection = hikari.getConnection();
|
||||
|
@ -32,6 +32,9 @@ import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PostgreSQLProvider extends SQLProvider {
|
||||
@ -87,6 +90,31 @@ public class PostgreSQLProvider extends SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
boolean success = true;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
try (Connection c = hikari.getConnection()) {
|
||||
try (Statement s = c.createStatement()) {
|
||||
s.execute("/* ping */ SELECT 1");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
success = false;
|
||||
}
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
|
||||
if (success) {
|
||||
ret.put("Ping", "&a" + duration + "ms");
|
||||
ret.put("Connected", "true");
|
||||
} else {
|
||||
ret.put("Connected", "false");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedConnection getConnection() throws SQLException {
|
||||
Connection connection = hikari.getConnection();
|
||||
|
@ -29,6 +29,8 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class SQLProvider {
|
||||
@ -40,6 +42,10 @@ public abstract class SQLProvider {
|
||||
|
||||
public abstract void shutdown() throws Exception;
|
||||
|
||||
public Map<String, String> getMeta() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public abstract WrappedConnection getConnection() throws SQLException;
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
package me.lucko.luckperms.common.storage.backing.sqlprovider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SQLiteProvider extends FlatfileProvider {
|
||||
public SQLiteProvider(File file) {
|
||||
@ -38,6 +40,20 @@ public class SQLiteProvider extends FlatfileProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
|
||||
File databaseFile = new File(super.file.getParent(), "luckperms-sqlite.db");
|
||||
if (databaseFile.exists()) {
|
||||
ret.put("File Size", DF.format(databaseFile.length() / 1048576) + "MB");
|
||||
} else {
|
||||
ret.put("File Size", "0MB");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverClass() {
|
||||
return "org.sqlite.JDBC";
|
||||
|
@ -42,6 +42,7 @@ import me.lucko.luckperms.common.data.Log;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -306,5 +307,6 @@ public class PhasedStorage implements Storage {
|
||||
boolean isAcceptingLogins();
|
||||
void setAcceptingLogins(boolean b);
|
||||
void init();
|
||||
Map<String, String> getMeta();
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>spongeapi</artifactId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<version>7.0.0-20170716.103113-1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Lombok -->
|
||||
|
@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>spongeapi</artifactId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<version>7.0.0-20170716.103113-1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
@ -124,6 +124,7 @@ import java.util.stream.Collectors;
|
||||
public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
|
||||
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
|
||||
private Set<UUID> uniqueConnections = ConcurrentHashMap.newKeySet();
|
||||
|
||||
@Inject
|
||||
private Logger logger;
|
||||
@ -147,6 +148,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
|
||||
private LPTimings timings;
|
||||
private boolean lateLoad = false;
|
||||
private long startTime;
|
||||
|
||||
private LuckPermsScheduler scheduler;
|
||||
private SpongeCommand commandManager;
|
||||
@ -172,6 +174,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
|
||||
@Listener(order = Order.FIRST)
|
||||
public void onEnable(GamePreInitializationEvent event) {
|
||||
startTime = System.currentTimeMillis();
|
||||
scheduler = new LPSpongeScheduler(this);
|
||||
localeManager = new NoopLocaleManager();
|
||||
senderFactory = new SpongeSenderFactory(this);
|
||||
@ -315,7 +318,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
scheduler.asyncRepeating(new ServiceCacheHousekeepingTask(service), 2400L);
|
||||
// scheduler.asyncRepeating(() -> userManager.performCleanup(), 2400L);
|
||||
|
||||
getLog().info("Successfully enabled.");
|
||||
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - startTime) + "ms)");
|
||||
}
|
||||
|
||||
@Listener(order = Order.LATE)
|
||||
|
@ -41,6 +41,8 @@ import me.lucko.luckperms.common.core.model.User;
|
||||
import me.lucko.luckperms.sponge.calculators.DefaultsProcessor;
|
||||
import me.lucko.luckperms.sponge.calculators.SpongeWildcardProcessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SpongeCalculatorFactory extends AbstractCalculatorFactory {
|
||||
private final LPSpongePlugin plugin;
|
||||
@ -69,4 +71,15 @@ public class SpongeCalculatorFactory extends AbstractCalculatorFactory {
|
||||
|
||||
return registerCalculator(new PermissionCalculator(plugin, user.getFriendlyName(), processors.build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveProcessors() {
|
||||
ImmutableList.Builder<String> ret = ImmutableList.builder();
|
||||
ret.add("Map");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLY_SPONGE_IMPLICIT_WILDCARDS)) ret.add("SpongeWildcard");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ret.add("Regex");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) ret.add("Wildcards");
|
||||
if (plugin.getConfiguration().get(ConfigKeys.APPLY_SPONGE_DEFAULT_SUBJECTS)) ret.add("Defaults");
|
||||
return ret.build();
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ public class SpongeListener {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getUniqueConnections().add(p.getUniqueId());
|
||||
|
||||
/* Actually process the login for the connection.
|
||||
We do this here to delay the login until the data is ready.
|
||||
If the login gets cancelled later on, then this will be cleaned up.
|
||||
|
Loading…
Reference in New Issue
Block a user