diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index 92dc3106..848828ee 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -167,6 +167,23 @@ public void onEnable() { executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20)); + File cacheDir = new File(getDataFolder(), "cache"); + cacheDir.mkdirs(); + try { + profileCache = new SQLiteCache(new File(cacheDir, "profiles.sqlite")); + } catch (IOException e) { + WorldGuard.logger.log(Level.WARNING, "Failed to initialize SQLite profile cache"); + profileCache = new HashMapCache(); + } + + profileService = new CacheForwardingService( + new CombinedProfileService( + BukkitPlayerService.getInstance(), + HttpRepositoryService.forMinecraft()), + profileCache); + + PermissionsResolverManager.initialize(this); + WorldGuard.getInstance().setPlatform(platform = new BukkitWorldGuardPlatform()); // Initialise WorldGuard WorldGuard.getInstance().setup(); BukkitSessionManager sessionManager = (BukkitSessionManager) platform.getSessionManager(); @@ -185,32 +202,12 @@ public void onEnable() { reg.register(ToggleCommands.class); reg.register(ProtectionCommands.class); - getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - if (!platform.getGlobalStateManager().hasCommandBookGodMode()) { - reg.register(GeneralCommands.class); - } + getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { + if (!platform.getGlobalStateManager().hasCommandBookGodMode()) { + reg.register(GeneralCommands.class); } }, 0L); - File cacheDir = new File(getDataFolder(), "cache"); - cacheDir.mkdirs(); - try { - profileCache = new SQLiteCache(new File(cacheDir, "profiles.sqlite")); - } catch (IOException e) { - WorldGuard.logger.log(Level.WARNING, "Failed to initialize SQLite profile cache"); - profileCache = new HashMapCache(); - } - - profileService = new CacheForwardingService( - new CombinedProfileService( - BukkitPlayerService.getInstance(), - HttpRepositoryService.forMinecraft()), - profileCache); - - PermissionsResolverManager.initialize(this); - WorldGuard.logger.info("Loading region data..."); getServer().getScheduler().scheduleSyncRepeatingTask(this, sessionManager, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);