mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-09 10:31:25 +02:00
Less hacky performance improvements (#5187)
This commit is contained in:
parent
4def2be918
commit
9eb8f4e918
10
pom.xml
10
pom.xml
@ -171,7 +171,7 @@
|
||||
<include>net.kyori:option</include>
|
||||
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
||||
<include>co.aikar:acf-bukkit</include>
|
||||
<include>com.github.technicallycoded:FoliaLib</include>
|
||||
<include>com.tcoded:FoliaLib</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
@ -277,6 +277,10 @@
|
||||
<id>jitpack</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tcoded-releases</id>
|
||||
<url>https://repo.tcoded.com/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||
@ -462,9 +466,9 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.technicallycoded</groupId>
|
||||
<groupId>com.tcoded</groupId>
|
||||
<artifactId>FoliaLib</artifactId>
|
||||
<version>main-SNAPSHOT</version>
|
||||
<version>0.5.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -162,8 +162,11 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Folia lib plugin instance
|
||||
foliaLib = new FoliaLib(this);
|
||||
InvalidTickDelayNotifier.disableNotifications = true;
|
||||
foliaPerformanceHack();
|
||||
foliaLib.getOptions().disableNotifications();
|
||||
// Performance optimization
|
||||
// This makes the scheduler behave differently between Spigot/Legacy-Paper & Folia/Modern-Paper
|
||||
foliaLib.getOptions().disableIsValidOnNonFolia();
|
||||
|
||||
|
||||
setupFilePaths();
|
||||
generalConfig = new GeneralConfig(getDataFolder()); //Load before skillTools
|
||||
@ -317,37 +320,6 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void foliaPerformanceHack() {
|
||||
// Spigot can't use this optimization
|
||||
if (!hasGlobalRegionScheduler()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Thanks SirSalad
|
||||
// https://github.com/CraftYourTown/mcMMO/commit/2cffd64b127678411e20f0b8f9a3e3b87a649ee8
|
||||
try {
|
||||
final FoliaImplementation setScheduler = new FoliaImplementation(foliaLib);
|
||||
final java.lang.reflect.Field scheduler = FoliaLib.class.getDeclaredField("scheduler");
|
||||
scheduler.setAccessible(true);
|
||||
scheduler.set(foliaLib, setScheduler);
|
||||
scheduler.setAccessible(false);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
getLogger().warning("Unexpected exception when attempting to apply performance tweaks to FoliaLib");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasGlobalRegionScheduler() {
|
||||
try {
|
||||
// No parameters → empty Class<?> array
|
||||
Bukkit.getServer()
|
||||
.getClass()
|
||||
.getMethod("getGlobalRegionScheduler");
|
||||
return true; // Method is present
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
return false; // Not running on Paper/Folia
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerLevelUtils getPlayerLevelUtils() {
|
||||
return playerLevelUtils;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user