Make logging messages a bit less obnoxious

* Removed the ascii text from the startup output
* Log messages (but not command output) is now sent through the standard server logger, and isn't colored
This commit is contained in:
Luck 2018-06-16 16:59:59 +01:00
parent 6baa472567
commit b8c06904ab
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
23 changed files with 275 additions and 160 deletions

View File

@ -44,14 +44,18 @@
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>me.lucko.luckperms:luckperms-common</include>
<include>me.lucko.luckperms:luckperms-api</include>
</includes>
</artifactSet>
<relocations>
<!-- shaded dependencies -->
<!-- relocated dependencies -->
<relocation>
<pattern>net.kyori.text</pattern>
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
</relocation>
<!-- relocated dependencies -->
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
@ -117,29 +121,6 @@
<scope>compile</scope>
</dependency>
<!-- jsr305 -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<!-- caffeine -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.6.2</version>
<scope>provided</scope>
</dependency>
<!-- HikariCP -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.2.0</version>
<scope>provided</scope>
</dependency>
<!-- Spigot -->
<dependency>
<groupId>org.spigotmc</groupId>

View File

@ -30,6 +30,8 @@ import me.lucko.luckperms.bukkit.compat.NullSafeConsoleCommandSender;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.JavaPluginLogger;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
@ -49,6 +51,11 @@ import java.util.stream.Stream;
*/
public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap {
/**
* The plugin logger
*/
private final PluginLogger logger;
/**
* A scheduler adapter for the platform
*/
@ -83,6 +90,7 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap
private boolean incompatibleVersion = false;
public LPBukkitBootstrap() {
this.logger = new JavaPluginLogger(getLogger());
this.schedulerAdapter = new BukkitSchedulerAdapter(this);
this.classLoader = new ReflectionClassLoader(this);
this.console = new NullSafeConsoleCommandSender(getServer());
@ -91,6 +99,11 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap
// provide adapters
@Override
public PluginLogger getPluginLogger() {
return this.logger;
}
@Override
public BukkitSchedulerAdapter getScheduler() {
return this.schedulerAdapter;

View File

@ -115,7 +115,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
}
@Override

View File

@ -44,14 +44,18 @@
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>me.lucko.luckperms:luckperms-common</include>
<include>me.lucko.luckperms:luckperms-api</include>
</includes>
</artifactSet>
<relocations>
<!-- shaded dependencies -->
<!-- relocated dependencies -->
<relocation>
<pattern>net.kyori.text</pattern>
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
</relocation>
<!-- relocated dependencies -->
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
@ -117,14 +121,6 @@
<scope>compile</scope>
</dependency>
<!-- jsr305 -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<!-- BungeeCord -->
<dependency>
<groupId>net.md-5</groupId>

View File

@ -30,6 +30,8 @@ import me.lucko.luckperms.bungee.util.RedisBungeeUtil;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.JavaPluginLogger;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -47,6 +49,11 @@ import java.util.stream.Stream;
*/
public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
/**
* The plugin logger
*/
private final PluginLogger logger;
/**
* A scheduler adapter for the platform
*/
@ -72,6 +79,7 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
private final CountDownLatch enableLatch = new CountDownLatch(1);
public LPBungeeBootstrap() {
this.logger = new JavaPluginLogger(getLogger());
this.schedulerAdapter = new BungeeSchedulerAdapter(this);
this.classLoader = new ReflectionClassLoader(this);
this.plugin = new LPBungeePlugin(this);
@ -79,6 +87,11 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
// provide adapters
@Override
public PluginLogger getPluginLogger() {
return this.logger;
}
@Override
public SchedulerAdapter getScheduler() {
return this.schedulerAdapter;

View File

@ -94,7 +94,7 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin {
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
}
@Override

View File

@ -41,7 +41,7 @@
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
<scope>compile</scope>
</dependency>
<!-- text -->
@ -76,35 +76,30 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
<scope>provided</scope>
</dependency>
<!-- guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<scope>provided</scope>
</dependency>
<!-- caffeine -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.6.2</version>
<scope>provided</scope>
</dependency>
<!-- okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
<scope>provided</scope>
</dependency>
<!-- okio -->
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.14.1</version>
<scope>provided</scope>
</dependency>
<!-- configurate -->
@ -112,7 +107,6 @@
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-core</artifactId>
<version>3.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
@ -125,7 +119,6 @@
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-yaml</artifactId>
<version>3.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.yaml</groupId>
@ -138,7 +131,6 @@
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-gson</artifactId>
<version>3.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
@ -151,14 +143,12 @@
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
<version>3.5</version>
<scope>provided</scope>
</dependency>
<!-- configurate toml -->
<dependency>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-toml</artifactId>
<version>3.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.moandjiezana.toml</groupId>
@ -171,28 +161,24 @@
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.2.0</version>
<scope>provided</scope>
</dependency>
<!-- Jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
<scope>provided</scope>
</dependency>
<!-- MongoDB -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.7.1</version>
<scope>provided</scope>
</dependency>
<!-- SnakeYAML -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -180,11 +180,6 @@ public final class ConfigKeys {
*/
public static final ConfigKey<Boolean> USE_ARGUMENT_BASED_COMMAND_PERMISSIONS = BooleanKey.of("argument-based-command-permissions", false);
/**
* If the plugin should log messages to the console in color.
*/
public static final ConfigKey<Boolean> USE_COLORED_LOGGER = BooleanKey.of("colored-logger", true);
/**
* If wildcards are being applied
*/

View File

@ -59,6 +59,13 @@ public enum Dependency {
"mmz3ltQbS8xXGA2scM0ZH6raISlt4nukjCiU2l9Jxfs="
),
TEXT(
"net{}kyori",
"text",
"1.11-1.4.0",
"drQpwf+oI1+DPrn0iCvEtoID+xXR3dpZK5ySaBrUiok=",
Relocation.of("text", "net{}kyori{}text")
),
CAFFEINE(
"com{}github{}ben-manes{}caffeine",
"caffeine",

View File

@ -60,9 +60,6 @@ public enum Message {
/*
* Logging
*/
LOG_INFO("&7&l[&bL&3P&7&l] &3{}", false),
LOG_WARN("&7&l[&bLuck&3Perms&7&l] &c[WARN] {}", false),
LOG_ERROR("&7&l[&bLuck&3Perms&7&l] &4[ERROR] {}", false),
LOG(
"{PREFIX}&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)" + "\n" +
"{PREFIX}&3LOG &3&l> &f{}",

View File

@ -46,7 +46,7 @@ import me.lucko.luckperms.common.inheritance.InheritanceHandler;
import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.messaging.InternalMessagingService;
import me.lucko.luckperms.common.messaging.MessagingFactory;
import me.lucko.luckperms.common.plugin.util.PluginLogger;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.StorageFactory;
@ -64,7 +64,6 @@ import java.util.concurrent.TimeUnit;
public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
// init during load
private PluginLogger logger;
private DependencyManager dependencyManager;
// init during enable
@ -86,13 +85,12 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
* Performs the initial actions to load the plugin
*/
public final void load() {
// load the sender factory instance and create a new logger for the plugin
setupSenderFactory();
this.logger = new PluginLogger(this, getConsoleSender());
// load dependencies
this.dependencyManager = new DependencyManager(this);
this.dependencyManager.loadDependencies(getGlobalDependencies());
// load the sender factory instance
setupSenderFactory();
}
public final void enable() {
@ -237,6 +235,11 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
protected void removePlatformHooks() {}
@Override
public PluginLogger getLogger() {
return getBootstrap().getPluginLogger();
}
@Override
public void setMessagingService(InternalMessagingService messagingService) {
if (this.messagingService == null) {
@ -244,11 +247,6 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
}
}
@Override
public PluginLogger getLogger() {
return this.logger;
}
@Override
public DependencyManager getDependencyManager() {
return this.dependencyManager;
@ -320,12 +318,9 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
}
private void displayBanner(Sender sender) {
sender.sendMessage(MessageUtils.color("&b __ &3 __ ___ __ __ "));
sender.sendMessage(MessageUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
sender.sendMessage(MessageUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
sender.sendMessage(MessageUtils.color(" "));
sender.sendMessage(MessageUtils.color("&2 Loading version &bv" + getBootstrap().getVersion() + "&2 on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand()));
sender.sendMessage(MessageUtils.color("&8 Running on server version " + getBootstrap().getServerVersion()));
sender.sendMessage(MessageUtils.color(" "));
sender.sendMessage(MessageUtils.color("&b &3 __ "));
sender.sendMessage(MessageUtils.color("&b | &3|__) " + "&2LuckPerms &bv" + getBootstrap().getVersion()));
sender.sendMessage(MessageUtils.color("&b |___ &3| " + "&8running on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand()));
sender.sendMessage("");
}
}

View File

@ -44,8 +44,8 @@ import me.lucko.luckperms.common.managers.user.UserManager;
import me.lucko.luckperms.common.messaging.InternalMessagingService;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
import me.lucko.luckperms.common.plugin.util.PluginLogger;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.dao.file.FileWatcher;

View File

@ -27,6 +27,7 @@ package me.lucko.luckperms.common.plugin.bootstrap;
import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
import java.io.InputStream;
@ -48,6 +49,13 @@ import javax.annotation.Nullable;
*/
public interface LuckPermsBootstrap {
/**
* Gets the plugin logger
*
* @return the logger
*/
PluginLogger getPluginLogger();
/**
* Gets an adapter for the platforms scheduler
*

View File

@ -0,0 +1,51 @@
/*
* 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.plugin.logging;
import java.util.logging.Logger;
public class JavaPluginLogger implements PluginLogger {
private final Logger logger;
public JavaPluginLogger(Logger logger) {
this.logger = logger;
}
@Override
public void info(String s) {
this.logger.info(s);
}
@Override
public void warn(String s) {
this.logger.warning(s);
}
@Override
public void severe(String s) {
this.logger.severe(s);
}
}

View File

@ -23,15 +23,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.plugin.util;
import me.lucko.luckperms.common.command.utils.MessageUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.locale.message.Message;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.sender.Sender;
import java.util.Objects;
package me.lucko.luckperms.common.plugin.logging;
/**
* Represents the logger instance being used by LuckPerms on the platform.
@ -39,32 +31,10 @@ import java.util.Objects;
* <p>Messages sent using the logger are sent prefixed with the LuckPerms tag,
* and on some implementations will be colored depending on the message type.</p>
*/
public class PluginLogger {
private final LuckPermsPlugin plugin;
private final Sender console;
public interface PluginLogger {
public PluginLogger(LuckPermsPlugin plugin, Sender console) {
this.plugin = plugin;
this.console = console;
}
void info(String s);
void warn(String s);
void severe(String s);
public void info(String s) {
msg(Message.LOG_INFO, Objects.requireNonNull(s));
}
public void warn(String s) {
msg(Message.LOG_WARN, Objects.requireNonNull(s));
}
public void severe(String s) {
msg(Message.LOG_ERROR, Objects.requireNonNull(s));
}
private void msg(Message message, String s) {
String msg = message.asString(this.plugin.getLocaleManager(), s);
if (this.plugin.getConfiguration() != null && !this.plugin.getConfiguration().get(ConfigKeys.USE_COLORED_LOGGER)) {
msg = MessageUtils.stripColor(msg);
}
this.console.sendMessage(msg);
}
}

View File

@ -0,0 +1,51 @@
/*
* 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.plugin.logging;
import org.slf4j.Logger;
public class Slf4jPluginLogger implements PluginLogger {
private final Logger logger;
public Slf4jPluginLogger(Logger logger) {
this.logger = logger;
}
@Override
public void info(String s) {
this.logger.info(s);
}
@Override
public void warn(String s) {
this.logger.warn(s);
}
@Override
public void severe(String s) {
this.logger.error(s);
}
}

View File

@ -44,14 +44,18 @@
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>me.lucko.luckperms:luckperms-common</include>
<include>me.lucko.luckperms:luckperms-api</include>
</includes>
</artifactSet>
<relocations>
<!-- shaded dependencies -->
<!-- relocated dependencies -->
<relocation>
<pattern>net.kyori.text</pattern>
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
</relocation>
<!-- relocated dependencies -->
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
@ -117,22 +121,6 @@
<scope>compile</scope>
</dependency>
<!-- jsr305 -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<!-- caffeine -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.6.2</version>
<scope>provided</scope>
</dependency>
<!-- Nukkit -->
<dependency>
<groupId>cn.nukkit</groupId>

View File

@ -29,6 +29,7 @@ import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import cn.nukkit.Player;
import cn.nukkit.plugin.PluginBase;
@ -45,6 +46,11 @@ import java.util.stream.Stream;
*/
public class LPNukkitBootstrap extends PluginBase implements LuckPermsBootstrap {
/**
* The plugin logger
*/
private final PluginLogger logger;
/**
* A scheduler adapter for the platform
*/
@ -70,6 +76,7 @@ public class LPNukkitBootstrap extends PluginBase implements LuckPermsBootstrap
private final CountDownLatch enableLatch = new CountDownLatch(1);
public LPNukkitBootstrap() {
this.logger = new NukkitPluginLogger(getLogger());
this.schedulerAdapter = new NukkitSchedulerAdapter(this);
this.classLoader = new ReflectionClassLoader(this);
this.plugin = new LPNukkitPlugin(this);
@ -77,6 +84,11 @@ public class LPNukkitBootstrap extends PluginBase implements LuckPermsBootstrap
// provide adapters
@Override
public PluginLogger getPluginLogger() {
return this.logger;
}
@Override
public NukkitSchedulerAdapter getScheduler() {
return this.schedulerAdapter;

View File

@ -111,7 +111,7 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
}
@Override

View File

@ -0,0 +1,53 @@
/*
* 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.nukkit;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import cn.nukkit.utils.Logger;
public class NukkitPluginLogger implements PluginLogger {
private final Logger logger;
public NukkitPluginLogger(cn.nukkit.plugin.PluginLogger logger) {
this.logger = logger;
}
@Override
public void info(String s) {
this.logger.info(s);
}
@Override
public void warn(String s) {
this.logger.warning(s);
}
@Override
public void severe(String s) {
this.logger.error(s);
}
}

View File

@ -44,14 +44,18 @@
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>me.lucko.luckperms:luckperms-common</include>
<include>me.lucko.luckperms:luckperms-api</include>
</includes>
</artifactSet>
<relocations>
<!-- shaded dependencies -->
<!-- relocated dependencies -->
<relocation>
<pattern>net.kyori.text</pattern>
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
</relocation>
<!-- relocated dependencies -->
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
@ -177,14 +181,6 @@
</exclusion>
</exclusions>
</dependency>
<!-- configurate -->
<dependency>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
<version>3.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>

View File

@ -31,6 +31,8 @@ import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.plugin.logging.Slf4jPluginLogger;
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
import me.lucko.luckperms.common.utils.MoreFiles;
import me.lucko.luckperms.sponge.utils.VersionData;
@ -74,6 +76,11 @@ import java.util.stream.Stream;
)
public class LPSpongeBootstrap implements LuckPermsBootstrap {
/**
* The plugin logger
*/
private final PluginLogger logger;
/**
* A scheduler adapter for the platform
*/
@ -98,12 +105,6 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
private final CountDownLatch loadLatch = new CountDownLatch(1);
private final CountDownLatch enableLatch = new CountDownLatch(1);
/**
* Injected plugin logger
*/
@Inject
private Logger logger;
/**
* Reference to the central {@link Game} instance in the API
*/
@ -129,7 +130,8 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
private PluginContainer pluginContainer;
@Inject
public LPSpongeBootstrap(@SynchronousExecutor SpongeExecutorService syncExecutor, @AsynchronousExecutor SpongeExecutorService asyncExecutor) {
public LPSpongeBootstrap(Logger logger, @SynchronousExecutor SpongeExecutorService syncExecutor, @AsynchronousExecutor SpongeExecutorService asyncExecutor) {
this.logger = new Slf4jPluginLogger(logger);
this.spongeScheduler = Sponge.getScheduler();
this.schedulerAdapter = new SpongeSchedulerAdapter(this, this.spongeScheduler, syncExecutor, asyncExecutor);
this.classLoader = new ReflectionClassLoader(this);
@ -138,6 +140,11 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
// provide adapters
@Override
public PluginLogger getPluginLogger() {
return this.logger;
}
@Override
public SchedulerAdapter getScheduler() {
return this.schedulerAdapter;
@ -188,10 +195,6 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
// getters for the injected sponge instances
public Logger getLogger() {
return this.logger;
}
public Game getGame() {
return this.game;
}

View File

@ -112,7 +112,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP,
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP,
Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_HOCON, Dependency.HOCON_CONFIG);
}
@ -260,7 +260,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
return new DummySender(this, CommandManager.CONSOLE_UUID, CommandManager.CONSOLE_NAME) {
@Override
protected void consumeMessage(String s) {
LPSpongePlugin.this.bootstrap.getLogger().info(s);
LPSpongePlugin.this.bootstrap.getPluginLogger().info(s);
}
};
}