* #1874 Introduce individual ConsoleLogger instance per class - Create ConsoleLoggerFactory from which a separate logger can be created for each class - Allows to support individual log level settings in the future * Fix CodeStyle issue * Replace full class name with import * Update usages after merge from master
This commit is contained in:
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
@@ -17,6 +18,8 @@ import org.bukkit.entity.Player;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AsyncChangePassword implements AsynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(AsyncChangePassword.class);
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
@@ -58,7 +61,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
|
||||
playerCache.updatePlayer(auth);
|
||||
commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
ConsoleLogger.info(player.getName() + " changed his password");
|
||||
logger.info(player.getName() + " changed his password");
|
||||
} else {
|
||||
commonService.send(player, MessageKey.WRONG_PASSWORD);
|
||||
}
|
||||
@@ -75,7 +78,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
final String lowerCaseName = playerName.toLowerCase();
|
||||
if (!(playerCache.isAuthenticated(lowerCaseName) || dataSource.isAuthAvailable(lowerCaseName))) {
|
||||
if (sender == null) {
|
||||
ConsoleLogger.warning("Tried to change password for user " + lowerCaseName + " but it doesn't exist!");
|
||||
logger.warning("Tried to change password for user " + lowerCaseName + " but it doesn't exist!");
|
||||
} else {
|
||||
commonService.send(sender, MessageKey.UNKNOWN_USER);
|
||||
}
|
||||
@@ -87,15 +90,15 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, lowerCaseName);
|
||||
if (sender != null) {
|
||||
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
ConsoleLogger.info(sender.getName() + " changed password of " + lowerCaseName);
|
||||
logger.info(sender.getName() + " changed password of " + lowerCaseName);
|
||||
} else {
|
||||
ConsoleLogger.info("Changed password of " + lowerCaseName);
|
||||
logger.info("Changed password of " + lowerCaseName);
|
||||
}
|
||||
} else {
|
||||
if (sender != null) {
|
||||
commonService.send(sender, MessageKey.ERROR);
|
||||
}
|
||||
ConsoleLogger.warning("An error occurred while changing password for user " + lowerCaseName + "!");
|
||||
logger.warning("An error occurred while changing password for user " + lowerCaseName + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.EmailChangedEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
@@ -22,6 +23,8 @@ import javax.inject.Inject;
|
||||
*/
|
||||
public class AsyncAddEmail implements AsynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(AsyncAddEmail.class);
|
||||
|
||||
@Inject
|
||||
private CommonService service;
|
||||
|
||||
@@ -65,7 +68,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
||||
EmailChangedEvent event = bukkitService.createAndCallEvent(isAsync
|
||||
-> new EmailChangedEvent(player, null, email, isAsync));
|
||||
if (event.isCancelled()) {
|
||||
ConsoleLogger.info("Could not add email to player '" + player + "' – event was cancelled");
|
||||
logger.info("Could not add email to player '" + player + "' – event was cancelled");
|
||||
service.send(player, MessageKey.EMAIL_ADD_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +78,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, playerName);
|
||||
service.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||
} else {
|
||||
ConsoleLogger.warning("Could not save email for player '" + player + "'");
|
||||
logger.warning("Could not save email for player '" + player + "'");
|
||||
service.send(player, MessageKey.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.EmailChangedEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
@@ -20,6 +21,8 @@ import javax.inject.Inject;
|
||||
* Async task for changing the email.
|
||||
*/
|
||||
public class AsyncChangeEmail implements AsynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(AsyncChangeEmail.class);
|
||||
|
||||
@Inject
|
||||
private CommonService service;
|
||||
@@ -83,7 +86,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
||||
EmailChangedEvent event = bukkitService.createAndCallEvent(isAsync
|
||||
-> new EmailChangedEvent(player, oldEmail, newEmail, isAsync));
|
||||
if (event.isCancelled()) {
|
||||
ConsoleLogger.info("Could not change email for player '" + player + "' – event was cancelled");
|
||||
logger.info("Could not change email for player '" + player + "' – event was cancelled");
|
||||
service.send(player, MessageKey.EMAIL_CHANGE_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
@@ -35,6 +36,8 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_IN
|
||||
* Asynchronous process for when a player joins.
|
||||
*/
|
||||
public class AsynchronousJoin implements AsynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(AsynchronousJoin.class);
|
||||
|
||||
@Inject
|
||||
private Server server;
|
||||
@@ -112,7 +115,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
isAsync -> new ProtectInventoryEvent(player, isAsync));
|
||||
if (ev.isCancelled()) {
|
||||
player.updateInventory();
|
||||
ConsoleLogger.fine("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
|
||||
logger.fine("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||
import fr.xephi.authme.events.FailedLoginEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.mail.EmailService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.permission.AdminPermission;
|
||||
@@ -44,6 +45,8 @@ import java.util.List;
|
||||
* Asynchronous task for a player login.
|
||||
*/
|
||||
public class AsynchronousLogin implements AsynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(AsynchronousLogin.class);
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
@@ -199,7 +202,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
* @param ip the ip address of the player
|
||||
*/
|
||||
private void handleWrongPassword(Player player, PlayerAuth auth, String ip) {
|
||||
ConsoleLogger.fine(player.getName() + " used the wrong password");
|
||||
logger.fine(player.getName() + " used the wrong password");
|
||||
|
||||
bukkitService.createAndCallEvent(isAsync -> new FailedLoginEvent(player, isAsync));
|
||||
if (tempbanManager.shouldTempban(ip)) {
|
||||
@@ -256,7 +259,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
service.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||
}
|
||||
|
||||
ConsoleLogger.fine(player.getName() + " logged in!");
|
||||
logger.fine(player.getName() + " logged in!");
|
||||
|
||||
// makes player loggedin
|
||||
playerCache.updatePlayer(auth);
|
||||
@@ -270,7 +273,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
// processed in other order.
|
||||
syncProcessManager.processSyncPlayerLogin(player, isFirstLogin, auths);
|
||||
} else {
|
||||
ConsoleLogger.warning("Player '" + player.getName() + "' wasn't online during login process, aborted...");
|
||||
logger.warning("Player '" + player.getName() + "' wasn't online during login process, aborted...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,8 +300,8 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
|
||||
String message = ChatColor.GRAY + String.join(", ", formattedNames) + ".";
|
||||
|
||||
ConsoleLogger.fine("The user " + player.getName() + " has " + auths.size() + " accounts:");
|
||||
ConsoleLogger.fine(message);
|
||||
logger.fine("The user " + player.getName() + " has " + auths.size() + " accounts:");
|
||||
logger.fine(message);
|
||||
|
||||
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
|
||||
if (onlinePlayer.getName().equalsIgnoreCase(player.getName())
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.process.logout;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.events.LogoutEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
@@ -23,6 +24,8 @@ import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
|
||||
|
||||
public class ProcessSyncPlayerLogout implements SynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(ProcessSyncPlayerLogout.class);
|
||||
|
||||
@Inject
|
||||
private CommonService service;
|
||||
|
||||
@@ -61,7 +64,7 @@ public class ProcessSyncPlayerLogout implements SynchronousProcess {
|
||||
bukkitService.callEvent(new LogoutEvent(player));
|
||||
|
||||
service.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||
ConsoleLogger.info(player.getName() + " logged out");
|
||||
logger.info(player.getName() + " logged out");
|
||||
}
|
||||
|
||||
private void applyLogoutEffect(Player player) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.process.register;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.events.RegisterEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
@@ -16,6 +17,8 @@ import javax.inject.Inject;
|
||||
* Performs synchronous tasks after a successful {@link RegistrationType#EMAIL email registration}.
|
||||
*/
|
||||
public class ProcessSyncEmailRegister implements SynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(ProcessSyncEmailRegister.class);
|
||||
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
@@ -40,7 +43,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
||||
|
||||
player.saveData();
|
||||
bukkitService.callEvent(new RegisterEvent(player));
|
||||
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
|
||||
logger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.process.register;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.events.RegisterEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
@@ -21,6 +22,8 @@ import javax.inject.Inject;
|
||||
*/
|
||||
public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(ProcessSyncPasswordRegister.class);
|
||||
|
||||
@Inject
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
@@ -66,7 +69,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
|
||||
player.saveData();
|
||||
bukkitService.callEvent(new RegisterEvent(player));
|
||||
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
|
||||
logger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
|
||||
|
||||
// Kick Player after Registration is enabled, kick the player
|
||||
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.UnregisterByAdminEvent;
|
||||
import fr.xephi.authme.events.UnregisterByPlayerEvent;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
@@ -28,6 +29,8 @@ import javax.inject.Inject;
|
||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
|
||||
|
||||
public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(AsynchronousUnregister.class);
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
@@ -72,7 +75,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
if (passwordSecurity.comparePassword(password, cachedAuth.getPassword(), name)) {
|
||||
if (dataSource.removeAuth(name)) {
|
||||
performPostUnregisterActions(name, player);
|
||||
ConsoleLogger.info(name + " unregistered himself");
|
||||
logger.info(name + " unregistered himself");
|
||||
bukkitService.createAndCallEvent(isAsync -> new UnregisterByPlayerEvent(player, isAsync));
|
||||
} else {
|
||||
service.send(player, MessageKey.ERROR);
|
||||
@@ -97,9 +100,9 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
bukkitService.createAndCallEvent(isAsync -> new UnregisterByAdminEvent(player, name, isAsync, initiator));
|
||||
|
||||
if (initiator == null) {
|
||||
ConsoleLogger.info(name + " was unregistered");
|
||||
logger.info(name + " was unregistered");
|
||||
} else {
|
||||
ConsoleLogger.info(name + " was unregistered by " + initiator.getName());
|
||||
logger.info(name + " was unregistered by " + initiator.getName());
|
||||
service.send(initiator, MessageKey.UNREGISTERED_SUCCESS);
|
||||
}
|
||||
} else if (initiator != null) {
|
||||
|
||||
Reference in New Issue
Block a user