Skip to content

Commit 9eb8f4e

Browse files
Less hacky performance improvements (mcMMO-Dev#5187)
1 parent 4def2be commit 9eb8f4e

2 files changed

Lines changed: 12 additions & 36 deletions

File tree

pom.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
<include>net.kyori:option</include>
172172
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
173173
<include>co.aikar:acf-bukkit</include>
174-
<include>com.github.technicallycoded:FoliaLib</include>
174+
<include>com.tcoded:FoliaLib</include>
175175
</includes>
176176
</artifactSet>
177177
<relocations>
@@ -277,6 +277,10 @@
277277
<id>jitpack</id>
278278
<url>https://jitpack.io</url>
279279
</repository>
280+
<repository>
281+
<id>tcoded-releases</id>
282+
<url>https://repo.tcoded.com/releases/</url>
283+
</repository>
280284
</repositories>
281285
<dependencies>
282286
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
@@ -462,9 +466,9 @@
462466
<scope>compile</scope>
463467
</dependency>
464468
<dependency>
465-
<groupId>com.github.technicallycoded</groupId>
469+
<groupId>com.tcoded</groupId>
466470
<artifactId>FoliaLib</artifactId>
467-
<version>main-SNAPSHOT</version>
471+
<version>0.5.1</version>
468472
<scope>compile</scope>
469473
</dependency>
470474
</dependencies>

src/main/java/com/gmail/nossr50/mcMMO.java

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)