Move exception printing to logger (#2695)

This commit is contained in:
MrMicky 2020-10-31 23:25:11 +01:00 committed by GitHub
parent 4c23f93a67
commit 7854de8991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 136 additions and 126 deletions

View File

@ -33,7 +33,6 @@ import me.lucko.luckperms.common.sender.Sender;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
@ -48,7 +47,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.stream.Collectors;
public class BukkitCommandExecutor extends CommandManager implements CommandExecutor, TabExecutor, Listener {
public class BukkitCommandExecutor extends CommandManager implements TabExecutor, Listener {
private static final boolean SELECT_ENTITIES_SUPPORTED;
static {
@ -144,8 +143,7 @@ public class BukkitCommandExecutor extends CommandManager implements CommandExec
.map(e -> ((Player) e))
.collect(Collectors.toList());
} catch (IllegalArgumentException e) {
this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + sender + " executing " + args);
e.printStackTrace();
this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + sender + " executing " + args, e);
continue;
}

View File

@ -245,8 +245,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
}
} catch (Exception e) {
this.vaultHookManager = null;
getLogger().severe("Error occurred whilst hooking into Vault.");
e.printStackTrace();
getLogger().severe("Error occurred whilst hooking into Vault.", e);
}
}
@ -305,12 +304,14 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
PermissibleInjector.inject(player, lpPermissible);
} catch (Throwable t) {
t.printStackTrace();
getLogger().severe("Exception thrown when setting up permissions for " +
player.getUniqueId() + " - " + player.getName(), t);
}
});
}
} catch (Exception e) {
e.printStackTrace();
getLogger().severe("Exception occurred whilst loading data for " +
player.getUniqueId() + " - " + player.getName(), e);
}
});
}
@ -323,7 +324,8 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
try {
PermissibleInjector.uninject(player, false);
} catch (Exception e) {
e.printStackTrace();
getLogger().severe("Exception thrown when unloading permissions from " +
player.getUniqueId() + " - " + player.getName(), e);
}
if (getConfiguration().get(ConfigKeys.AUTO_OP)) {

View File

@ -67,8 +67,7 @@ public class InjectorDefaultsMap {
this.plugin.setDefaultPermissionMap(defaultsMap);
}
} catch (Exception e) {
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Default Permission map.");
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Default Permission map.", e);
}
}
@ -111,7 +110,7 @@ public class InjectorDefaultsMap {
DEFAULT_PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
}
} catch (Exception e) {
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst uninjecting LuckPerms Default Permission map.", e);
}
}
}

View File

@ -66,8 +66,7 @@ public class InjectorPermissionMap {
this.plugin.setPermissionMap(permissionMap);
}
} catch (Exception e) {
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission map.");
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission map.", e);
}
}

View File

@ -65,8 +65,7 @@ public class InjectorSubscriptionMap {
this.plugin.setSubscriptionMap(subscriptionMap);
}
} catch (Exception e) {
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission Subscription map.");
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission Subscription map.", e);
}
}
@ -113,7 +112,7 @@ public class InjectorSubscriptionMap {
PERM_SUBS_FIELD.set(pluginManager, lpMap.detach());
}
} catch (Exception e) {
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst uninjecting LuckPerms Permission Subscription map.", e);
}
}

View File

@ -121,8 +121,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
recordConnection(e.getUniqueId());
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUniqueId(), e.getName(), user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUniqueId() + " - " + e.getName());
ex.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUniqueId() + " - " + e.getName(), ex);
// deny the connection
this.deniedAsyncLogin.add(e.getUniqueId());
@ -203,8 +202,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
} catch (Throwable t) {
this.plugin.getLogger().warn("Exception thrown when setting up permissions for " +
player.getUniqueId() + " - " + player.getName() + " - denying login.");
t.printStackTrace();
player.getUniqueId() + " - " + player.getName() + " - denying login.", t);
Component reason = TranslationManager.render(Message.LOADING_SETUP_ERROR.build(), player.getLocale());
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, LegacyComponentSerializer.legacySection().serialize(reason));
@ -242,7 +240,8 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
try {
PermissibleInjector.uninject(player, true);
} catch (Exception ex) {
ex.printStackTrace();
this.plugin.getLogger().severe("Exception thrown when unloading permissions from " +
player.getUniqueId() + " - " + player.getName(), ex);
}
// Handle auto op

View File

@ -131,7 +131,7 @@ public class MigrationPowerfulPerms extends ChildCommand<Object> {
try (ResultSet rs = ps.executeQuery()) {
log.log("Found table: " + dbTable);
while (rs.next()) {
log.log("" + rs.getString("COLUMN_NAME") + " - " + rs.getString("COLUMN_TYPE"));
log.log(rs.getString("COLUMN_NAME") + " - " + rs.getString("COLUMN_TYPE"));
}
}
}

View File

@ -201,7 +201,7 @@ public class MigrationZPermissions extends ChildCommand<Object> {
for (Entry e : entity.getPermissions()) {
if (e.getPermission().isEmpty()) continue;
if (e.getWorld() != null && !e.getWorld().getName().equals("")) {
if (e.getWorld() != null && !e.getWorld().getName().isEmpty()) {
holder.setNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(e.getPermission()).value(e.isValue()).withContext(DefaultContextKeys.WORLD_KEY, e.getWorld().getName()).build(), true);
} else {
holder.setNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(e.getPermission()).value(e.isValue()).build(), true);

View File

@ -273,7 +273,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
private QueryOptions createQueryOptionsForWorldSet(String world) {
ImmutableContextSet.Builder context = new ImmutableContextSetImpl.BuilderImpl();
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
if (world != null && !world.isEmpty() && !world.equalsIgnoreCase("global")) {
context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase());
}
context.add(DefaultContextKeys.SERVER_KEY, this.vaultPermission.getVaultServer());

View File

@ -65,7 +65,7 @@ public class VaultHookManager {
sm.register(Chat.class, this.chat, this.plugin.getBootstrap(), ServicePriority.High);
} catch (Exception e) {
e.printStackTrace();
this.plugin.getLogger().severe("Error occurred whilst hooking into Vault.", e);
}
}

View File

@ -93,8 +93,7 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme
recordConnection(c.getUniqueId());
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(c.getUniqueId(), c.getName(), user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + c.getUniqueId() + " - " + c.getName());
ex.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + c.getUniqueId() + " - " + c.getName(), ex);
// there was some error loading
if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {

View File

@ -63,8 +63,7 @@ public class BungeePermissionCheckListener implements Listener {
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user == null) {
this.plugin.getLogger().warn("A permission check was made for player " + player.getName() + " - " + player.getUniqueId() + ", " +
"but LuckPerms does not have any permissions data loaded for them. Perhaps their UUID has been altered since login?");
new Exception().printStackTrace();
"but LuckPerms does not have any permissions data loaded for them. Perhaps their UUID has been altered since login?", new Exception());
e.setHasPermission(false);
return;
@ -93,8 +92,7 @@ public class BungeePermissionCheckListener implements Listener {
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user == null) {
this.plugin.getLogger().warn("A permission check was made for player " + player.getName() + " - " + player.getUniqueId() + ", " +
"but LuckPerms does not have any permissions data loaded for them. Perhaps their UUID has been altered since login?");
new Exception().printStackTrace();
"but LuckPerms does not have any permissions data loaded for them. Perhaps their UUID has been altered since login?", new Exception());
e.setResult(Tristate.UNDEFINED);
return;

View File

@ -100,7 +100,7 @@ public class LogDispatcher {
try {
this.plugin.getStorage().logAction(entry).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst storing action", e);
}
}

View File

@ -258,7 +258,7 @@ public abstract class Exporter implements Runnable {
try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(bytesOut), StandardCharsets.UTF_8)) {
GsonProvider.prettyPrinting().toJson(json, writer);
} catch (IOException e) {
e.printStackTrace();
this.plugin.getLogger().severe("Error compressing data", e);
}
try {
@ -267,7 +267,7 @@ public abstract class Exporter implements Runnable {
} catch (UnsuccessfulRequestException e) {
this.log.getListeners().forEach(l -> Message.HTTP_REQUEST_FAILURE.send(l, e.getResponse().code(), e.getResponse().message()));
} catch (IOException e) {
new RuntimeException("Error uploading data to bytebin", e).printStackTrace();
this.plugin.getLogger().severe("Error uploading data to bytebin", e);
this.log.getListeners().forEach(Message.HTTP_UNKNOWN_FAILURE::send);
}
}

View File

@ -134,7 +134,7 @@ public class Importer implements Runnable {
@Override
public void run() {
long startTime = System.currentTimeMillis();
this.notify.forEach(s -> Message.IMPORT_START.send(s));
this.notify.forEach(Message.IMPORT_START::send);
// start an update task in the background - we'll #join this later
CompletableFuture<Void> updateTask = CompletableFuture.runAsync(() -> this.plugin.getSyncTaskBuffer().requestDirectly());

View File

@ -141,8 +141,7 @@ public class CommandManager {
try {
return execute(sender, label, args);
} catch (Throwable e) {
this.plugin.getLogger().severe("Exception whilst executing command: " + args.toString());
e.printStackTrace();
this.plugin.getLogger().severe("Exception whilst executing command: " + args, e);
return null;
}
}, this.executor);

View File

@ -104,7 +104,7 @@ public final class TabCompletions {
// cursor is specifying the value
String key = partial.substring(0, index);
if (key.equals("") || key.trim().isEmpty()) {
if (key.isEmpty() || key.trim().isEmpty()) {
return Collections.emptyList();
}

View File

@ -77,7 +77,7 @@ public final class StorageAssistant {
try {
plugin.getStorage().saveUser(user).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst saving user", e);
Message.USER_SAVE_ERROR.send(sender, user);
return;
}
@ -92,7 +92,7 @@ public final class StorageAssistant {
try {
plugin.getStorage().saveGroup(group).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst saving group", e);
Message.GROUP_SAVE_ERROR.send(sender, group);
return;
}
@ -110,7 +110,7 @@ public final class StorageAssistant {
try {
plugin.getStorage().saveTrack(track).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst saving track", e);
Message.TRACK_SAVE_ERROR.send(sender, track.getName());
return;
}

View File

@ -67,7 +67,7 @@ public class HolderShowTracks<T extends PermissionHolder> extends ChildCommand<T
try {
plugin.getStorage().loadAllTracks().get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst loading tracks", e);
Message.TRACKS_LOAD_ERROR.send(sender);
return CommandResult.LOADING_ERROR;
}

View File

@ -67,7 +67,7 @@ public class CreateGroup extends SingleCommand {
try {
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst creating group", e);
Message.CREATE_ERROR.send(sender, Component.text(groupName));
return CommandResult.FAILURE;
}

View File

@ -73,7 +73,7 @@ public class DeleteGroup extends SingleCommand {
try {
plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst deleting group", e);
Message.DELETE_ERROR.send(sender, group.getFormattedDisplayName());
return CommandResult.FAILURE;
}

View File

@ -66,7 +66,7 @@ public class GroupRename extends ChildCommand<Group> {
try {
newGroup = plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst creating group", e);
Message.CREATE_ERROR.send(sender, Component.text(newGroupName));
return CommandResult.FAILURE;
}
@ -74,7 +74,7 @@ public class GroupRename extends ChildCommand<Group> {
try {
plugin.getStorage().deleteGroup(target, DeletionCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst deleting group", e);
Message.DELETE_ERROR.send(sender, target.getFormattedDisplayName());
return CommandResult.FAILURE;
}

View File

@ -49,7 +49,7 @@ public class ListGroups extends SingleCommand {
try {
plugin.getStorage().loadAllGroups().get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst loading groups", e);
Message.GROUPS_LOAD_ERROR.send(sender);
return CommandResult.LOADING_ERROR;
}

View File

@ -62,7 +62,7 @@ public class ApplyEditsCommand extends SingleCommand {
Message.EDITOR_HTTP_REQUEST_FAILURE.send(sender, e.getResponse().code(), e.getResponse().message());
return CommandResult.STATE_ERROR;
} catch (IOException e) {
new RuntimeException("Error reading data from bytebin", e).printStackTrace();
plugin.getLogger().warn("Error reading data from bytebin", e);
Message.EDITOR_HTTP_UNKNOWN_FAILURE.send(sender);
return CommandResult.STATE_ERROR;
}

View File

@ -85,7 +85,7 @@ public class ExportCommand extends SingleCommand {
Files.createFile(path);
} catch (IOException e) {
Message.EXPORT_FILE_FAILURE.send(sender);
e.printStackTrace();
plugin.getLogger().warn("Error whilst writing to the file", e);
return CommandResult.FAILURE;
}

View File

@ -102,7 +102,7 @@ public class ImportCommand extends SingleCommand {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(Files.newInputStream(path)), StandardCharsets.UTF_8))) {
data = GsonProvider.normal().fromJson(reader, JsonObject.class);
} catch (IOException e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst reading from the import file", e);
Message.IMPORT_FILE_READ_FAILURE.send(sender);
this.running.set(false);
return CommandResult.FAILURE;
@ -121,7 +121,7 @@ public class ImportCommand extends SingleCommand {
Message.HTTP_REQUEST_FAILURE.send(sender, e.getResponse().code(), e.getResponse().message());
return CommandResult.STATE_ERROR;
} catch (IOException e) {
new RuntimeException("Error reading data to bytebin", e).printStackTrace();
plugin.getLogger().severe("Error reading data to bytebin", e);
Message.HTTP_UNKNOWN_FAILURE.send(sender);
return CommandResult.STATE_ERROR;
}

View File

@ -60,7 +60,7 @@ public class NetworkSyncCommand extends SingleCommand {
Message.UPDATE_TASK_PUSH_SUCCESS.send(sender, messagingService.get().getName());
return CommandResult.SUCCESS;
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst pushing changes to other servers", e);
Message.UPDATE_TASK_PUSH_FAILURE.send(sender);
return CommandResult.FAILURE;
}

View File

@ -80,7 +80,7 @@ public class TranslationsCommand extends SingleCommand {
availableTranslations = getAvailableTranslations(plugin);
} catch (IOException | UnsuccessfulRequestException e) {
Message.TRANSLATIONS_SEARCHING_ERROR.send(sender);
e.printStackTrace();
plugin.getLogger().warn("Unable to obtain a list of available translations", e);
return CommandResult.FAILURE;
}
@ -134,7 +134,7 @@ public class TranslationsCommand extends SingleCommand {
}
} catch (UnsuccessfulRequestException | IOException e) {
Message.TRANSLATIONS_DOWNLOAD_ERROR.send(sender, language.locale.toString());
e.printStackTrace();
plugin.getLogger().warn("Unable to download translations", e);
}
}
}

View File

@ -94,7 +94,7 @@ public class TreeCommand extends SingleCommand {
Message.GENERIC_HTTP_REQUEST_FAILURE.send(sender, e.getResponse().code(), e.getResponse().message());
return CommandResult.STATE_ERROR;
} catch (IOException e) {
new RuntimeException("Error uploading data to bytebin", e).printStackTrace();
plugin.getLogger().warn("Error uploading data to bytebin", e);
Message.GENERIC_HTTP_UNKNOWN_FAILURE.send(sender);
return CommandResult.STATE_ERROR;
}

View File

@ -128,13 +128,13 @@ public class VerboseCommand extends SingleCommand {
verboseHandler.registerListener(sender, compiledFilter, notify);
if (notify) {
if (!filter.equals("")) {
if (!filter.isEmpty()) {
Message.VERBOSE_ON_QUERY.send(sender, filter);
} else {
Message.VERBOSE_ON.send(sender);
}
} else {
if (!filter.equals("")) {
if (!filter.isEmpty()) {
Message.VERBOSE_RECORDING_ON_QUERY.send(sender, filter);
} else {
Message.VERBOSE_RECORDING_ON.send(sender);
@ -160,7 +160,7 @@ public class VerboseCommand extends SingleCommand {
Message.GENERIC_HTTP_REQUEST_FAILURE.send(sender, e.getResponse().code(), e.getResponse().message());
return CommandResult.STATE_ERROR;
} catch (IOException e) {
new RuntimeException("Error uploading data to bytebin", e).printStackTrace();
plugin.getLogger().warn("Error uploading data to bytebin", e);
Message.GENERIC_HTTP_UNKNOWN_FAILURE.send(sender);
return CommandResult.STATE_ERROR;
}

View File

@ -67,7 +67,7 @@ public class CreateTrack extends SingleCommand {
try {
plugin.getStorage().createAndLoadTrack(trackName, CreationCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst creating track", e);
Message.CREATE_ERROR.send(sender, Component.text(trackName));
return CommandResult.FAILURE;
}

View File

@ -67,7 +67,7 @@ public class DeleteTrack extends SingleCommand {
try {
plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst deleting track", e);
Message.DELETE_ERROR.send(sender, Component.text(track.getName()));
return CommandResult.FAILURE;
}

View File

@ -47,7 +47,7 @@ public class ListTracks extends SingleCommand {
try {
plugin.getStorage().loadAllTracks().get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst loading tracks", e);
Message.TRACKS_LOAD_ERROR.send(sender);
return CommandResult.LOADING_ERROR;
}

View File

@ -65,7 +65,7 @@ public class TrackRename extends ChildCommand<Track> {
try {
newTrack = plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst creating track", e);
Message.CREATE_ERROR.send(sender, Component.text(newTrackName));
return CommandResult.FAILURE;
}
@ -73,7 +73,7 @@ public class TrackRename extends ChildCommand<Track> {
try {
plugin.getStorage().deleteTrack(target, DeletionCause.COMMAND).get();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warn("Error whilst deleting track", e);
Message.DELETE_ERROR.send(sender, Component.text(target.getName()));
return CommandResult.FAILURE;
}

View File

@ -137,8 +137,7 @@ public abstract class ContextManager<S, P extends S> {
try {
calculator.calculate(subject, accumulator::add);
} catch (Throwable e) {
this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst calculating the context of subject " + subject);
e.printStackTrace();
this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst calculating the context of subject " + subject, e);
}
}
return formQueryOptions(subject, accumulator.build());
@ -150,8 +149,7 @@ public abstract class ContextManager<S, P extends S> {
try {
calculator.calculate(accumulator::add);
} catch (Throwable e) {
this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst calculating static contexts");
e.printStackTrace();
this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst calculating static contexts", e);
}
}
return formQueryOptions(accumulator.build());
@ -164,8 +162,7 @@ public abstract class ContextManager<S, P extends S> {
try {
potentialContexts = calculator.estimatePotentialContexts();
} catch (Throwable e) {
this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst estimating potential contexts");
e.printStackTrace();
this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst estimating potential contexts", e);
continue;
}
builder.addAll(potentialContexts);

View File

@ -126,8 +126,7 @@ public class DependencyManager {
try {
loadDependency(dependency);
} catch (Throwable e) {
this.plugin.getLogger().severe("Unable to load dependency " + dependency.name() + ".");
e.printStackTrace();
this.plugin.getLogger().severe("Unable to load dependency " + dependency.name() + ".", e);
} finally {
latch.countDown();
}
@ -210,7 +209,7 @@ public class DependencyManager {
try {
MoreFiles.deleteDirectory(oldCacheDirectory);
} catch (IOException e) {
e.printStackTrace();
plugin.getLogger().warn("Unable to delete lib directory", e);
}
}

View File

@ -94,8 +94,7 @@ public class LuckPermsEventSubscription<T extends LuckPermsEvent> implements Eve
try {
this.consumer.accept(event);
} catch (Throwable t) {
this.eventBus.getPlugin().getLogger().warn("Unable to pass event " + event.getEventType().getSimpleName() + " to handler " + this.consumer.getClass().getName());
t.printStackTrace();
this.eventBus.getPlugin().getLogger().warn("Unable to pass event " + event.getEventType().getSimpleName() + " to handler " + this.consumer.getClass().getName(), t);
}
}

View File

@ -68,7 +68,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
try {
extension.instance.unload();
} catch (Exception e) {
e.printStackTrace();
this.plugin.getLogger().warn("Exception unloading extension", e);
}
}
this.extensions.clear();
@ -96,12 +96,12 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
try {
loadExtension(path);
} catch (IOException e) {
new RuntimeException("Exception loading extension from " + path, e).printStackTrace();
this.plugin.getLogger().warn("Exception loading extension from " + path, e);
}
}
});
} catch (IOException e) {
e.printStackTrace();
this.plugin.getLogger().warn("Exception loading extensions from " + directory, e);
}
}

View File

@ -104,7 +104,7 @@ public class TranslationManager {
try {
this.registry.registerAll(DEFAULT_LOCALE, bundle, false);
} catch (IllegalArgumentException e) {
e.printStackTrace();
this.plugin.getLogger().warn("Error loading default locale file", e);
}
}
@ -127,8 +127,7 @@ public class TranslationManager {
loaded.put(result.getKey(), result.getValue());
}
} catch (Exception e) {
this.plugin.getLogger().warn("Error loading locale file: " + translationFile.getFileName().toString());
e.printStackTrace();
this.plugin.getLogger().warn("Error loading locale file: " + translationFile.getFileName(), e);
}
}
@ -155,8 +154,7 @@ public class TranslationManager {
try (BufferedReader reader = Files.newBufferedReader(translationFile, StandardCharsets.UTF_8)) {
bundle = new PropertyResourceBundle(reader);
} catch(IOException e) {
this.plugin.getLogger().warn("Error loading locale file: " + localeString);
e.printStackTrace();
this.plugin.getLogger().warn("Error loading locale file: " + localeString, e);
return null;
}

View File

@ -96,7 +96,7 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
try {
return new LuckPermsMessagingService(this.plugin, new RedisMessengerProvider());
} catch (Exception e) {
e.printStackTrace();
getPlugin().getLogger().severe("Exception occurred whilst enabling Redis messaging service", e);
}
} else {
this.plugin.getLogger().warn("Messaging Service was set to redis, but redis is not enabled!");
@ -105,7 +105,7 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
try {
return new LuckPermsMessagingService(this.plugin, new SqlMessengerProvider());
} catch (Exception e) {
e.printStackTrace();
getPlugin().getLogger().severe("Exception occurred whilst enabling SQL messaging service", e);
}
}

View File

@ -84,7 +84,7 @@ public final class StandardStackElements {
.map(s -> {
MetaStackElement parsed = parseFromString(plugin, s);
if (parsed == null) {
new IllegalArgumentException("Unable to parse from: " + s).printStackTrace();
plugin.getLogger().warn("Unable to parse from: " + s, new IllegalArgumentException());
}
return parsed;
})

View File

@ -140,8 +140,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
} catch (Throwable e) {
// catch throwable here, seems some JVMs throw UnsatisfiedLinkError when trying
// to create a watch service. see: https://github.com/lucko/LuckPerms/issues/2066
getLogger().warn("Error occurred whilst trying to create a file watcher:");
e.printStackTrace();
getLogger().warn("Error occurred whilst trying to create a file watcher:", e);
}
}

View File

@ -25,6 +25,7 @@
package me.lucko.luckperms.common.plugin.logging;
import java.util.logging.Level;
import java.util.logging.Logger;
public class JavaPluginLogger implements PluginLogger {
@ -44,8 +45,18 @@ public class JavaPluginLogger implements PluginLogger {
this.logger.warning(s);
}
@Override
public void warn(String s, Throwable t) {
this.logger.log(Level.WARNING, s, t);
}
@Override
public void severe(String s) {
this.logger.severe(s);
}
@Override
public void severe(String s, Throwable t) {
this.logger.log(Level.SEVERE, s, t);
}
}

View File

@ -37,6 +37,10 @@ public interface PluginLogger {
void warn(String s);
void warn(String s, Throwable t);
void severe(String s);
void severe(String s, Throwable t);
}

View File

@ -44,8 +44,18 @@ public class Slf4jPluginLogger implements PluginLogger {
this.logger.warn(s);
}
@Override
public void warn(String s, Throwable t) {
this.logger.warn(s, t);
}
@Override
public void severe(String s) {
this.logger.error(s);
}
@Override
public void severe(String s, Throwable t) {
this.logger.error(s, t);
}
}

View File

@ -115,8 +115,7 @@ public class Storage {
try {
this.implementation.init();
} catch (Exception e) {
this.plugin.getLogger().severe("Failed to init storage implementation");
e.printStackTrace();
this.plugin.getLogger().severe("Failed to init storage implementation", e);
}
}
@ -124,8 +123,7 @@ public class Storage {
try {
this.implementation.shutdown();
} catch (Exception e) {
this.plugin.getLogger().severe("Failed to shutdown storage implementation");
e.printStackTrace();
this.plugin.getLogger().severe("Failed to shutdown storage implementation", e);
}
}

View File

@ -36,7 +36,6 @@ import me.lucko.luckperms.common.context.ContextSetConfigurateSerializer;
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.model.HolderType;
import me.lucko.luckperms.common.model.PermissionHolderIdentifier;
import me.lucko.luckperms.common.model.Track;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.model.manager.group.GroupManager;
@ -150,8 +149,7 @@ public abstract class AbstractConfigurateStorage implements StorageImplementatio
// used to report i/o exceptions which took place in a specific file
protected RuntimeException reportException(String file, Exception ex) throws RuntimeException {
this.plugin.getLogger().warn("Exception thrown whilst performing i/o: " + file);
ex.printStackTrace();
this.plugin.getLogger().warn("Exception thrown whilst performing i/o: " + file, ex);
Throwables.throwIfUnchecked(ex);
throw new RuntimeException(ex);
}

View File

@ -103,7 +103,7 @@ public class SplitStorage implements StorageImplementation {
try {
ds.shutdown();
} catch (Exception e) {
e.printStackTrace();
this.plugin.getLogger().severe("Exception whilst disabling " + ds + " storage", e);
}
}
}

View File

@ -86,10 +86,10 @@ public final class SqlNode {
}
public static SqlNode fromSqlFields(long sqlId, String permission, boolean value, String server, String world, long expiry, String contexts) {
if (Strings.emptyToNull(server) == null) {
if (Strings.isNullOrEmpty(server)) {
server = "global";
}
if (Strings.emptyToNull(world) == null) {
if (Strings.isNullOrEmpty(world)) {
world = "global";
}

View File

@ -215,7 +215,7 @@ public class SqlStorage implements StorageImplementation {
try {
this.connectionFactory.shutdown();
} catch (Exception e) {
e.printStackTrace();
this.plugin.getLogger().severe("Exception whilst disabling SQLite storage", e);
}
}

View File

@ -57,7 +57,7 @@ public class H2ConnectionFactory extends FlatfileConnectionFactory {
try {
Files.move(data, getWriteFile());
} catch (IOException e) {
e.printStackTrace();
plugin.getLogger().warn("Unable to move old database", e);
}
}

View File

@ -56,7 +56,7 @@ public class SQLiteConnectionFactory extends FlatfileConnectionFactory {
try {
Files.move(data, file);
} catch (IOException e) {
e.printStackTrace();
plugin.getLogger().warn("Unable to move old database", e);
}
}

View File

@ -63,7 +63,7 @@ public class TreeView {
private final ImmutableTreeNode view;
public TreeView(PermissionRegistry source, String rootPosition) {
if (rootPosition.equals("") || rootPosition.equals("*")) {
if (rootPosition.isEmpty() || rootPosition.equals("*")) {
rootPosition = ".";
} else if (!rootPosition.equals(".") && rootPosition.endsWith(".")) {
rootPosition = rootPosition.substring(0, rootPosition.length() - 1);

View File

@ -221,12 +221,13 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
PermissibleInjector.inject(player, lpPermissible);
} catch (Throwable t) {
t.printStackTrace();
getLogger().severe("Exception thrown when setting up permissions for " +
player.getUniqueId() + " - " + player.getName(), t);
}
});
}
} catch (Exception e) {
e.printStackTrace();
getLogger().severe("Exception occurred whilst loading data for " + player.getUniqueId() + " - " + player.getName(), e);
}
});
}
@ -239,7 +240,8 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
try {
PermissibleInjector.uninject(player, false);
} catch (Exception e) {
e.printStackTrace();
getLogger().severe("Exception thrown when unloading permissions from " +
player.getUniqueId() + " - " + player.getName(), e);
}
if (getConfiguration().get(ConfigKeys.AUTO_OP)) {

View File

@ -46,8 +46,18 @@ public class NukkitPluginLogger implements PluginLogger {
this.logger.warning(s);
}
@Override
public void warn(String s, Throwable t) {
this.logger.warning(s, t);
}
@Override
public void severe(String s) {
this.logger.error(s);
}
@Override
public void severe(String s, Throwable t) {
this.logger.error(s, t);
}
}

View File

@ -79,8 +79,7 @@ public class InjectorDefaultsMap implements Runnable {
this.plugin.setDefaultPermissionMap(defaultsMap);
}
} catch (Exception e) {
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Default Permission map.");
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Default Permission map.", e);
}
}

View File

@ -67,8 +67,7 @@ public class InjectorPermissionMap implements Runnable {
this.plugin.setPermissionMap(permissionMap);
}
} catch (Exception e) {
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission map.");
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission map.", e);
}
}

View File

@ -67,8 +67,7 @@ public class InjectorSubscriptionMap implements Runnable {
this.plugin.setSubscriptionMap(subscriptionMap);
}
} catch (Exception e) {
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission Subscription map.");
e.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission Subscription map.", e);
}
}

View File

@ -92,8 +92,7 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
recordConnection(e.getUuid());
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUuid(), e.getName(), user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUuid() + " - " + e.getName());
ex.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUuid() + " - " + e.getName(), ex);
// deny the connection
this.deniedAsyncLogin.add(e.getUuid());
@ -165,8 +164,7 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
} catch (Throwable t) {
this.plugin.getLogger().warn("Exception thrown when setting up permissions for " +
player.getUniqueId() + " - " + player.getName() + " - denying login.");
t.printStackTrace();
player.getUniqueId() + " - " + player.getName() + " - denying login.", t);
e.setCancelled();
Component reason = TranslationManager.render(Message.LOADING_SETUP_ERROR.build());
@ -211,7 +209,8 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
try {
PermissibleInjector.uninject(player, true);
} catch (Exception ex) {
ex.printStackTrace();
this.plugin.getLogger().severe("Exception thrown when unloading permissions from " +
player.getUniqueId() + " - " + player.getName(), ex);
}
// Handle auto op

View File

@ -256,7 +256,7 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
try {
MoreFiles.createDirectoriesIfNotExists(dataDirectory);
} catch (IOException e) {
e.printStackTrace();
this.logger.warn("Unable to create LuckPerms directory", e);
}
return dataDirectory;
}

View File

@ -107,8 +107,7 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall
.map(e -> ((Player) e))
.collect(Collectors.toList());
} catch (IllegalArgumentException e) {
this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + source + " executing " + args);
e.printStackTrace();
this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + source + " executing " + args, e);
continue;
}

View File

@ -93,8 +93,7 @@ public class SpongeConnectionListener extends AbstractConnectionListener {
recordConnection(profile.getUniqueId());
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(profile.getUniqueId(), username, user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + profile.getUniqueId() + " - " + profile.getName());
ex.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + profile.getUniqueId() + " - " + profile.getName(), ex);
this.deniedAsyncLogin.add(profile.getUniqueId());

View File

@ -47,7 +47,7 @@ public class SpongeMessagingFactory extends MessagingFactory<LPSpongePlugin> {
try {
return new LuckPermsMessagingService(getPlugin(), new PluginMessageMessengerProvider());
} catch (Exception e) {
e.printStackTrace();
getPlugin().getLogger().severe("Exception occurred whilst enabling messaging", e);
}
}

View File

@ -76,7 +76,7 @@ public class SubjectStorage {
}
try (Stream<Path> s = Files.list(this.container)) {
return s.filter(p -> Files.isDirectory(p))
return s.filter(Files::isDirectory)
.map(p -> p.getFileName().toString())
.collect(ImmutableCollectors.toSet());
} catch (IOException e) {

View File

@ -91,8 +91,7 @@ public class VelocityConnectionListener extends AbstractConnectionListener {
e.setProvider(new PlayerPermissionProvider(p, user, this.plugin.getContextManager().getCacheFor(p)));
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(p.getUniqueId(), p.getUsername(), user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + p.getUniqueId() + " - " + p.getUsername());
ex.printStackTrace();
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + p.getUniqueId() + " - " + p.getUsername(), ex);
// there was some error loading
if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {

View File

@ -47,7 +47,7 @@ public class VelocityMessagingFactory extends MessagingFactory<LPVelocityPlugin>
try {
return new LuckPermsMessagingService(getPlugin(), new PluginMessageMessengerProvider());
} catch (Exception e) {
e.printStackTrace();
getPlugin().getLogger().severe("Exception occurred whilst enabling messaging", e);
}
}