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:option</include>
|
||||||
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
||||||
<include>co.aikar:acf-bukkit</include>
|
<include>co.aikar:acf-bukkit</include>
|
||||||
<include>com.github.technicallycoded:FoliaLib</include>
|
<include>com.tcoded:FoliaLib</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
@ -277,6 +277,10 @@
|
|||||||
<id>jitpack</id>
|
<id>jitpack</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>tcoded-releases</id>
|
||||||
|
<url>https://repo.tcoded.com/releases/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||||
@ -462,9 +466,9 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.technicallycoded</groupId>
|
<groupId>com.tcoded</groupId>
|
||||||
<artifactId>FoliaLib</artifactId>
|
<artifactId>FoliaLib</artifactId>
|
||||||
<version>main-SNAPSHOT</version>
|
<version>0.5.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -162,8 +162,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Folia lib plugin instance
|
//Folia lib plugin instance
|
||||||
foliaLib = new FoliaLib(this);
|
foliaLib = new FoliaLib(this);
|
||||||
InvalidTickDelayNotifier.disableNotifications = true;
|
foliaLib.getOptions().disableNotifications();
|
||||||
foliaPerformanceHack();
|
// Performance optimization
|
||||||
|
// This makes the scheduler behave differently between Spigot/Legacy-Paper & Folia/Modern-Paper
|
||||||
|
foliaLib.getOptions().disableIsValidOnNonFolia();
|
||||||
|
|
||||||
|
|
||||||
setupFilePaths();
|
setupFilePaths();
|
||||||
generalConfig = new GeneralConfig(getDataFolder()); //Load before skillTools
|
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() {
|
public static PlayerLevelUtils getPlayerLevelUtils() {
|
||||||
return playerLevelUtils;
|
return playerLevelUtils;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user