Cleanup login handling & reduce the amount of unnecessary logging output on startup

This commit is contained in:
Luck 2017-05-18 22:30:01 +01:00
parent cc907b6530
commit 139dd5302b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
8 changed files with 66 additions and 65 deletions

View File

@ -74,7 +74,6 @@ public class BukkitListener implements Listener {
/* the player was denied entry to the server before this priority. /* the player was denied entry to the server before this priority.
log this, so we can handle appropriately later. */ log this, so we can handle appropriately later. */
if (e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { if (e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
plugin.getLog().warn("Connection from " + e.getUniqueId() + " was already denied. No permissions data will be loaded.");
deniedAsyncLogin.add(e.getUniqueId()); deniedAsyncLogin.add(e.getUniqueId());
return; return;
} }
@ -89,7 +88,7 @@ public class BukkitListener implements Listener {
deniedAsyncLogin.add(e.getUniqueId()); deniedAsyncLogin.add(e.getUniqueId());
// actually deny the connection. // actually deny the connection.
plugin.getLog().warn("Permissions storage is not loaded yet. Denying connection from: " + e.getUniqueId() + " - " + e.getName()); plugin.getLog().warn("Permissions storage is not loaded. Denying connection from: " + e.getUniqueId() + " - " + e.getName());
e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_ERROR.asString(plugin.getLocaleManager())); e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_ERROR.asString(plugin.getLocaleManager()));
return; return;
} }
@ -121,6 +120,7 @@ public class BukkitListener implements Listener {
// Check to see if this connection was denied at LOW. // Check to see if this connection was denied at LOW.
if (deniedAsyncLogin.remove(e.getUniqueId())) { if (deniedAsyncLogin.remove(e.getUniqueId())) {
// their data was never loaded at LOW priority, now check to see if they have been magically allowed since then.
// This is a problem, as they were denied at low priority, but are now being allowed. // This is a problem, as they were denied at low priority, but are now being allowed.
if (e.getLoginResult() == AsyncPlayerPreLoginEvent.Result.ALLOWED) { if (e.getLoginResult() == AsyncPlayerPreLoginEvent.Result.ALLOWED) {
@ -131,7 +131,7 @@ public class BukkitListener implements Listener {
return; return;
} }
// Login event was cancelled by another plugin // Login event was cancelled by another plugin, but it wasn't cancelled when we handled it at LOW
if (e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { if (e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
// Schedule cleanup of this user. // Schedule cleanup of this user.
plugin.getUserManager().scheduleUnload(e.getUniqueId()); plugin.getUserManager().scheduleUnload(e.getUniqueId());
@ -147,7 +147,6 @@ public class BukkitListener implements Listener {
/* the player was denied entry to the server before this priority. /* the player was denied entry to the server before this priority.
log this, so we can handle appropriately later. */ log this, so we can handle appropriately later. */
if (e.getResult() != PlayerLoginEvent.Result.ALLOWED) { if (e.getResult() != PlayerLoginEvent.Result.ALLOWED) {
plugin.getLog().warn("Login from " + e.getPlayer().getUniqueId() + " was denied before an attachment could be injected.");
deniedLogin.add(e.getPlayer().getUniqueId()); deniedLogin.add(e.getPlayer().getUniqueId());
return; return;
} }
@ -190,20 +189,20 @@ public class BukkitListener implements Listener {
/* Listen to see if the event was cancelled after we initially handled the login /* Listen to see if the event was cancelled after we initially handled the login
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */ If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW. // Check to see if this connection was denied at LOW. Even if it was denied at LOW, their data will still be present.
boolean denied = false;
if (deniedLogin.remove(e.getPlayer().getUniqueId())) { if (deniedLogin.remove(e.getPlayer().getUniqueId())) {
denied = true;
// This is a problem, as they were denied at low priority, but are now being allowed. // This is a problem, as they were denied at low priority, but are now being allowed.
if (e.getResult() == PlayerLoginEvent.Result.ALLOWED) { if (e.getResult() == PlayerLoginEvent.Result.ALLOWED) {
plugin.getLog().severe("Player connection was re-allowed for " + e.getPlayer().getUniqueId()); plugin.getLog().severe("Player connection was re-allowed for " + e.getPlayer().getUniqueId());
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, ""); e.disallow(PlayerLoginEvent.Result.KICK_OTHER, "");
} }
return;
} }
// Login event was cancelled by another plugin // Login event was cancelled by another plugin since we first loaded their data
if (e.getResult() != PlayerLoginEvent.Result.ALLOWED) { if (denied || e.getResult() != PlayerLoginEvent.Result.ALLOWED) {
// Schedule cleanup of this user. // Schedule cleanup of this user.
plugin.getUserManager().scheduleUnload(e.getPlayer().getUniqueId()); plugin.getUserManager().scheduleUnload(e.getPlayer().getUniqueId());
return; return;
@ -236,8 +235,7 @@ public class BukkitListener implements Listener {
return; return;
} }
String s = e.getMessage().toLowerCase() String s = e.getMessage().substring(1).toLowerCase()
.replace("/", "")
.replace("bukkit:", "") .replace("bukkit:", "")
.replace("spigot:", "") .replace("spigot:", "")
.replace("minecraft:", ""); .replace("minecraft:", "");

View File

@ -192,9 +192,8 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
}, 1L); }, 1L);
// register events // register events
PluginManager pm = getServer().getPluginManager();
listener = new BukkitListener(this); listener = new BukkitListener(this);
pm.registerEvents(listener, this); getServer().getPluginManager().registerEvents(listener, this);
if (getConfiguration().get(ConfigKeys.WATCH_FILES)) { if (getConfiguration().get(ConfigKeys.WATCH_FILES)) {
fileWatcher = new FileWatcher(this); fileWatcher = new FileWatcher(this);
@ -209,14 +208,16 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) { if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
messagingType = "redis"; messagingType = "redis";
} }
if (!messagingType.equals("none")) {
getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
}
if (messagingType.equals("redis")) { if (messagingType.equals("redis")) {
getLog().info("Loading redis...");
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) { if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
RedisMessaging redis = new RedisMessaging(this); RedisMessaging redis = new RedisMessaging(this);
try { try {
redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD)); redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
getLog().info("Loaded redis successfully...");
messagingService = redis; messagingService = redis;
} catch (Exception e) { } catch (Exception e) {
getLog().warn("Couldn't load redis..."); getLog().warn("Couldn't load redis...");
@ -226,12 +227,10 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
getLog().warn("Messaging Service was set to redis, but redis is not enabled!"); getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
} }
} else if (messagingType.equals("bungee")) { } else if (messagingType.equals("bungee")) {
getLog().info("Loading bungee messaging service...");
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this); BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this);
bungeeMessaging.init(); bungeeMessaging.init();
messagingService = bungeeMessaging; messagingService = bungeeMessaging;
} else if (messagingType.equals("lilypad")) { } else if (messagingType.equals("lilypad")) {
getLog().info("Loading LilyPad messaging service...");
if (getServer().getPluginManager().getPlugin("LilyPad-Connect") == null) { if (getServer().getPluginManager().getPlugin("LilyPad-Connect") == null) {
getLog().warn("LilyPad-Connect plugin not present."); getLog().warn("LilyPad-Connect plugin not present.");
} else { } else {
@ -260,7 +259,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
localeManager = new SimpleLocaleManager(); localeManager = new SimpleLocaleManager();
File locale = new File(getDataFolder(), "lang.yml"); File locale = new File(getDataFolder(), "lang.yml");
if (locale.exists()) { if (locale.exists()) {
getLog().info("Found locale file. Attempting to load from it."); getLog().info("Found lang.yml - loading messages...");
try { try {
localeManager.loadFromFile(locale); localeManager.loadFromFile(locale);
} catch (Exception e) { } catch (Exception e) {
@ -269,7 +268,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
} }
// register commands // register commands
getLog().info("Registering commands...");
commandManager = new BukkitCommand(this); commandManager = new BukkitCommand(this);
PluginCommand main = getServer().getPluginCommand("luckperms"); PluginCommand main = getServer().getPluginCommand("luckperms");
main.setExecutor(commandManager); main.setExecutor(commandManager);
@ -298,7 +296,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
tryVaultHook(false); tryVaultHook(false);
// register with the LP API // register with the LP API
getLog().info("Registering API...");
apiProvider = new ApiProvider(this); apiProvider = new ApiProvider(this);
ApiHandler.registerProvider(apiProvider); ApiHandler.registerProvider(apiProvider);
getServer().getServicesManager().register(LuckPermsApi.class, apiProvider, this, ServicePriority.Normal); getServer().getServicesManager().register(LuckPermsApi.class, apiProvider, this, ServicePriority.Normal);
@ -313,6 +310,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L); scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L);
// run an update instantly. // run an update instantly.
getLog().info("Performing initial data load...");
updateTaskBuffer.requestDirectly(); updateTaskBuffer.requestDirectly();
// register tasks // register tasks
@ -351,7 +349,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
}); });
} }
getLog().info("Successfully loaded."); getLog().info("Successfully enabled.");
} }
@Override @Override
@ -378,7 +376,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
} }
} }
getLog().info("Closing datastore..."); getLog().info("Closing storage...");
storage.shutdown(); storage.shutdown();
if (fileWatcher != null) { if (fileWatcher != null) {
@ -390,7 +388,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
messagingService.close(); messagingService.close();
} }
getLog().info("Unregistering API...");
ApiHandler.unregisterProvider(); ApiHandler.unregisterProvider();
getServer().getServicesManager().unregisterAll(this); getServer().getServicesManager().unregisterAll(this);
@ -398,6 +395,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
vaultHook.unhook(this); vaultHook.unhook(this);
} }
getLog().info("Shutting down internal scheduler...");
scheduler.shutdown(); scheduler.shutdown();
// Bukkit will do this again when #onDisable completes, but we do it early to prevent NPEs elsewhere. // Bukkit will do this again when #onDisable completes, but we do it early to prevent NPEs elsewhere.
@ -436,9 +434,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
return; // already hooked return; // already hooked
} }
if (force) {
getLog().info("Attempting to hook with Vault...");
}
try { try {
if (force || getServer().getPluginManager().isPluginEnabled("Vault")) { if (force || getServer().getPluginManager().isPluginEnabled("Vault")) {
vaultHook = new VaultHook(); vaultHook = new VaultHook();

View File

@ -78,7 +78,6 @@ public class BungeeListener implements Listener {
if (e.isCancelled()) { if (e.isCancelled()) {
// log that we are not loading any data // log that we are not loading any data
plugin.getLog().warn("Connection from " + c.getUniqueId() + " was already denied. No permissions data will be loaded.");
deniedLogin.add(c.getUniqueId()); deniedLogin.add(c.getUniqueId());
e.completeIntent(plugin); e.completeIntent(plugin);
@ -91,7 +90,7 @@ public class BungeeListener implements Listener {
if (!plugin.getStorage().isAcceptingLogins()) { if (!plugin.getStorage().isAcceptingLogins()) {
// log that the user tried to login, but was denied at this stage. // log that the user tried to login, but was denied at this stage.
plugin.getLog().warn("Permissions storage is not loaded yet. No permissions data will be loaded for: " + c.getUniqueId() + " - " + c.getName()); plugin.getLog().warn("Permissions storage is not loaded. No permissions data will be loaded for: " + c.getUniqueId() + " - " + c.getName());
deniedLogin.add(c.getUniqueId()); deniedLogin.add(c.getUniqueId());
e.completeIntent(plugin); e.completeIntent(plugin);

View File

@ -150,14 +150,16 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) { if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
messagingType = "redis"; messagingType = "redis";
} }
if (!messagingType.equals("none")) {
getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
}
if (messagingType.equals("redis")) { if (messagingType.equals("redis")) {
getLog().info("Loading redis...");
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) { if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
RedisMessaging redis = new RedisMessaging(this); RedisMessaging redis = new RedisMessaging(this);
try { try {
redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD)); redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
getLog().info("Loaded redis successfully...");
messagingService = redis; messagingService = redis;
} catch (Exception e) { } catch (Exception e) {
getLog().warn("Couldn't load redis..."); getLog().warn("Couldn't load redis...");
@ -167,7 +169,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
getLog().warn("Messaging Service was set to redis, but redis is not enabled!"); getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
} }
} else if (messagingType.equals("bungee")) { } else if (messagingType.equals("bungee")) {
getLog().info("Loading bungee messaging service...");
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this); BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this);
bungeeMessaging.init(); bungeeMessaging.init();
messagingService = bungeeMessaging; messagingService = bungeeMessaging;
@ -192,7 +193,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
localeManager = new SimpleLocaleManager(); localeManager = new SimpleLocaleManager();
File locale = new File(getDataFolder(), "lang.yml"); File locale = new File(getDataFolder(), "lang.yml");
if (locale.exists()) { if (locale.exists()) {
getLog().info("Found locale file. Attempting to load from it."); getLog().info("Found lang.yml - loading messages...");
try { try {
localeManager.loadFromFile(locale); localeManager.loadFromFile(locale);
} catch (Exception e) { } catch (Exception e) {
@ -201,7 +202,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
} }
// register commands // register commands
getLog().info("Registering commands...");
commandManager = new CommandManager(this); commandManager = new CommandManager(this);
getProxy().getPluginManager().registerCommand(this, new BungeeCommand(this, commandManager)); getProxy().getPluginManager().registerCommand(this, new BungeeCommand(this, commandManager));
@ -226,7 +226,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
contextManager.registerStaticCalculator(staticCalculator); contextManager.registerStaticCalculator(staticCalculator);
// register with the LP API // register with the LP API
getLog().info("Registering API...");
apiProvider = new ApiProvider(this); apiProvider = new ApiProvider(this);
ApiHandler.registerProvider(apiProvider); ApiHandler.registerProvider(apiProvider);
@ -239,18 +238,19 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L); scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L);
// run an update instantly. // run an update instantly.
getLog().info("Performing initial data load...");
updateTaskBuffer.requestDirectly(); updateTaskBuffer.requestDirectly();
// register tasks // register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L); scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L); scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
getLog().info("Successfully loaded."); getLog().info("Successfully enabled.");
} }
@Override @Override
public void onDisable() { public void onDisable() {
getLog().info("Closing datastore..."); getLog().info("Closing storage...");
storage.shutdown(); storage.shutdown();
if (fileWatcher != null) { if (fileWatcher != null) {
@ -262,9 +262,10 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
messagingService.close(); messagingService.close();
} }
getLog().info("Unregistering API...");
ApiHandler.unregisterProvider(); ApiHandler.unregisterProvider();
getLog().info("Shutting down internal scheduler...");
scheduler.shutdown();
getProxy().getScheduler().cancel(this); getProxy().getScheduler().cancel(this);
getProxy().getPluginManager().unregisterListeners(this); getProxy().getPluginManager().unregisterListeners(this);
} }

View File

@ -71,8 +71,6 @@ public class DependencyManager {
.build(); .build();
public static void loadDependencies(LuckPermsPlugin plugin, Set<StorageType> storageTypes) { public static void loadDependencies(LuckPermsPlugin plugin, Set<StorageType> storageTypes) {
plugin.getLog().info("Loading dependencies...");
List<Dependency> dependencies = new ArrayList<>(); List<Dependency> dependencies = new ArrayList<>();
for (StorageType storageType : storageTypes) { for (StorageType storageType : storageTypes) {
dependencies.addAll(STORAGE_DEPENDENCIES.get(storageType)); dependencies.addAll(STORAGE_DEPENDENCIES.get(storageType));

View File

@ -52,10 +52,7 @@ import java.util.Set;
public class StorageFactory { public class StorageFactory {
public static Set<StorageType> getRequiredTypes(LuckPermsPlugin plugin, StorageType defaultMethod) { public static Set<StorageType> getRequiredTypes(LuckPermsPlugin plugin, StorageType defaultMethod) {
plugin.getLog().info("Detecting storage method...");
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) { if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
plugin.getLog().info("Loading split storage options.");
Map<String, String> types = new HashMap<>(plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS)); Map<String, String> types = new HashMap<>(plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS));
types.entrySet().stream() types.entrySet().stream()
.filter(e -> StorageType.parse(e.getValue()) == null) .filter(e -> StorageType.parse(e.getValue()) == null)
@ -82,10 +79,8 @@ public class StorageFactory {
public static Storage getInstance(LuckPermsPlugin plugin, StorageType defaultMethod) { public static Storage getInstance(LuckPermsPlugin plugin, StorageType defaultMethod) {
Storage storage; Storage storage;
plugin.getLog().info("Initializing storage backings...");
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) { if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
plugin.getLog().info("Using split storage."); plugin.getLog().info("Loading storage provider... [SPLIT STORAGE]");
Map<String, String> types = new HashMap<>(plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS)); Map<String, String> types = new HashMap<>(plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS));
types.entrySet().stream() types.entrySet().stream()
@ -110,11 +105,10 @@ public class StorageFactory {
type = defaultMethod; type = defaultMethod;
} }
plugin.getLog().info("Using " + type.getName() + " storage."); plugin.getLog().info("Loading storage provider... [" + type.name() + "]");
storage = makeInstance(type, plugin); storage = makeInstance(type, plugin);
} }
plugin.getLog().info("Initialising storage provider...");
storage.init(); storage.init();
return storage; return storage;
} }

View File

@ -201,14 +201,16 @@ public class LPSpongePlugin implements LuckPermsPlugin {
if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) { if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
messagingType = "redis"; messagingType = "redis";
} }
if (!messagingType.equals("none")) {
getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
}
if (messagingType.equals("redis")) { if (messagingType.equals("redis")) {
getLog().info("Loading redis...");
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) { if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
RedisMessaging redis = new RedisMessaging(this); RedisMessaging redis = new RedisMessaging(this);
try { try {
redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD)); redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
getLog().info("Loaded redis successfully...");
messagingService = redis; messagingService = redis;
} catch (Exception e) { } catch (Exception e) {
getLog().warn("Couldn't load redis..."); getLog().warn("Couldn't load redis...");
@ -218,7 +220,6 @@ public class LPSpongePlugin implements LuckPermsPlugin {
getLog().warn("Messaging Service was set to redis, but redis is not enabled!"); getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
} }
} else if (messagingType.equals("bungee")) { } else if (messagingType.equals("bungee")) {
getLog().info("Loading bungee messaging service...");
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this); BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this);
bungeeMessaging.init(); bungeeMessaging.init();
messagingService = bungeeMessaging; messagingService = bungeeMessaging;
@ -243,7 +244,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
localeManager = new SimpleLocaleManager(); localeManager = new SimpleLocaleManager();
File locale = new File(getDataDirectory(), "lang.yml"); File locale = new File(getDataDirectory(), "lang.yml");
if (locale.exists()) { if (locale.exists()) {
getLog().info("Found locale file. Attempting to load from it."); getLog().info("Found lang.yml - loading messages...");
try { try {
localeManager.loadFromFile(locale); localeManager.loadFromFile(locale);
} catch (Exception e) { } catch (Exception e) {
@ -252,7 +253,6 @@ public class LPSpongePlugin implements LuckPermsPlugin {
} }
// register commands // register commands
getLog().info("Registering commands...");
CommandManager cmdService = game.getCommandManager(); CommandManager cmdService = game.getCommandManager();
commandManager = new SpongeCommand(this); commandManager = new SpongeCommand(this);
cmdService.register(this, commandManager, "luckperms", "lp", "perm", "perms", "permission", "permissions"); cmdService.register(this, commandManager, "luckperms", "lp", "perm", "perms", "permission", "permissions");
@ -288,7 +288,6 @@ public class LPSpongePlugin implements LuckPermsPlugin {
} }
// register with the LP API // register with the LP API
getLog().info("Registering API...");
apiProvider = new ApiProvider(this); apiProvider = new ApiProvider(this);
ApiHandler.registerProvider(apiProvider); ApiHandler.registerProvider(apiProvider);
game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider); game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
@ -302,6 +301,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L); scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L);
// run an update instantly. // run an update instantly.
getLog().info("Performing initial data load...");
updateTaskBuffer.requestDirectly(); updateTaskBuffer.requestDirectly();
// register tasks // register tasks
@ -310,7 +310,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
scheduler.asyncRepeating(new ServiceCacheHousekeepingTask(service), 2400L); scheduler.asyncRepeating(new ServiceCacheHousekeepingTask(service), 2400L);
// scheduler.asyncRepeating(() -> userManager.performCleanup(), 2400L); // scheduler.asyncRepeating(() -> userManager.performCleanup(), 2400L);
getLog().info("Successfully loaded."); getLog().info("Successfully enabled.");
} }
@Listener(order = Order.LATE) @Listener(order = Order.LATE)
@ -325,7 +325,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
@Listener @Listener
public void onDisable(GameStoppingServerEvent event) { public void onDisable(GameStoppingServerEvent event) {
getLog().info("Closing datastore..."); getLog().info("Closing storage...");
storage.shutdown(); storage.shutdown();
if (fileWatcher != null) { if (fileWatcher != null) {
@ -337,9 +337,9 @@ public class LPSpongePlugin implements LuckPermsPlugin {
messagingService.close(); messagingService.close();
} }
getLog().info("Unregistering API...");
ApiHandler.unregisterProvider(); ApiHandler.unregisterProvider();
getLog().info("Shutting down internal scheduler...");
scheduler.shutdown(); scheduler.shutdown();
} }

View File

@ -75,7 +75,6 @@ public class SpongeListener {
/* the player was denied entry to the server before this priority. /* the player was denied entry to the server before this priority.
log this, so we can handle appropriately later. */ log this, so we can handle appropriately later. */
if (e.isCancelled()) { if (e.isCancelled()) {
plugin.getLog().warn("Connection from " + p.getUniqueId() + " was already denied. No permissions data will be loaded.");
deniedAsyncLogin.add(p.getUniqueId()); deniedAsyncLogin.add(p.getUniqueId());
return; return;
} }
@ -90,9 +89,9 @@ public class SpongeListener {
deniedAsyncLogin.add(p.getUniqueId()); deniedAsyncLogin.add(p.getUniqueId());
// actually deny the connection. // actually deny the connection.
plugin.getLog().warn("Permissions storage is not loaded yet. Denying connection from: " + p.getUniqueId() + " - " + p.getName()); plugin.getLog().warn("Permissions storage is not loaded. Denying connection from: " + p.getUniqueId() + " - " + p.getName());
e.setCancelled(true); e.setCancelled(true);
e.setMessageCancelled(true); e.setMessageCancelled(false);
//noinspection deprecation //noinspection deprecation
e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(plugin.getLocaleManager())));
return; return;
@ -112,8 +111,10 @@ public class SpongeListener {
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
deniedAsyncLogin.add(p.getUniqueId());
e.setCancelled(true); e.setCancelled(true);
e.setMessageCancelled(true); e.setMessageCancelled(false);
//noinspection deprecation //noinspection deprecation
e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(plugin.getLocaleManager())));
} }
@ -149,7 +150,6 @@ public class SpongeListener {
/* the player was denied entry to the server before this priority. /* the player was denied entry to the server before this priority.
log this, so we can handle appropriately later. */ log this, so we can handle appropriately later. */
if (e.isCancelled()) { if (e.isCancelled()) {
plugin.getLog().warn("Login from " + player.getUniqueId() + " was denied before an attachment could be injected.");
deniedLogin.add(player.getUniqueId()); deniedLogin.add(player.getUniqueId());
return; return;
} }
@ -162,7 +162,7 @@ public class SpongeListener {
plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login."); plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
e.setCancelled(true); e.setCancelled(true);
e.setMessageCancelled(true); e.setMessageCancelled(false);
//noinspection deprecation //noinspection deprecation
e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(plugin.getLocaleManager())));
return; return;
@ -192,6 +192,22 @@ public class SpongeListener {
} }
} }
@Listener(order = Order.BEFORE_POST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLoginMonitor(ClientConnectionEvent.Login e) {
/* Listen to see if the event was cancelled after we initially handled the login
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW. Even if it was denied at LOW, their data will still be present.
if (deniedLogin.remove(e.getProfile().getUniqueId())) {
// This is a problem, as they were denied at low priority, but are now being allowed.
if (!e.isCancelled()) {
plugin.getLog().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId());
e.setCancelled(true);
}
}
}
@Listener(order = Order.EARLY) @Listener(order = Order.EARLY)
public void onClientJoin(ClientConnectionEvent.Join e) { public void onClientJoin(ClientConnectionEvent.Join e) {
// Refresh permissions again // Refresh permissions again