@@ -162,8 +162,11 @@ public void onEnable() {
162162
163163 //Folia lib plugin instance
164164 foliaLib = new FoliaLib (this );
165- InvalidTickDelayNotifier .disableNotifications = true ;
166- foliaPerformanceHack ();
165+ foliaLib .getOptions ().disableNotifications ();
166+ // Performance optimization
167+ // This makes the scheduler behave differently between Spigot/Legacy-Paper & Folia/Modern-Paper
168+ foliaLib .getOptions ().disableIsValidOnNonFolia ();
169+
167170
168171 setupFilePaths ();
169172 generalConfig = new GeneralConfig (getDataFolder ()); //Load before skillTools
@@ -317,37 +320,6 @@ public void onEnable() {
317320 }
318321 }
319322
320- private void foliaPerformanceHack () {
321- // Spigot can't use this optimization
322- if (!hasGlobalRegionScheduler ()) {
323- return ;
324- }
325-
326- // Thanks SirSalad
327- // https://github.com/CraftYourTown/mcMMO/commit/2cffd64b127678411e20f0b8f9a3e3b87a649ee8
328- try {
329- final FoliaImplementation setScheduler = new FoliaImplementation (foliaLib );
330- final java .lang .reflect .Field scheduler = FoliaLib .class .getDeclaredField ("scheduler" );
331- scheduler .setAccessible (true );
332- scheduler .set (foliaLib , setScheduler );
333- scheduler .setAccessible (false );
334- } catch (NoSuchFieldException | IllegalAccessException e ) {
335- getLogger ().warning ("Unexpected exception when attempting to apply performance tweaks to FoliaLib" );
336- }
337- }
338-
339- private static boolean hasGlobalRegionScheduler () {
340- try {
341- // No parameters → empty Class<?> array
342- Bukkit .getServer ()
343- .getClass ()
344- .getMethod ("getGlobalRegionScheduler" );
345- return true ; // Method is present
346- } catch (NoSuchMethodException ignored ) {
347- return false ; // Not running on Paper/Folia
348- }
349- }
350-
351323 public static PlayerLevelUtils getPlayerLevelUtils () {
352324 return playerLevelUtils ;
353325 }
0 commit comments