Remove more Reflection stuff

This commit is contained in:
2026-05-16 13:02:20 +02:00
parent 3c48e7c02d
commit a100d2d798
6 changed files with 18 additions and 36 deletions
@@ -19,9 +19,10 @@
package de.steamwar.misslewars.slowmo;
import de.steamwar.Reflection;
import net.minecraft.server.level.ServerLevel;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.CraftWorld;
import java.lang.reflect.Field;
@@ -30,7 +31,6 @@ public class SlowMoUtils {
private static final Field field;
public static final boolean freezeEnabled;
private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", null);
private static boolean frozen = false;
private static final World world;
@@ -38,7 +38,7 @@ public class SlowMoUtils {
static {
Field temp;
try {
temp = Reflection.getClass("net.minecraft.server.level.ServerLevel").getField("freezed");
temp = ServerLevel.class.getField("freezed");
} catch (NoSuchFieldException e) {
temp = null;
}
@@ -64,7 +64,7 @@ public class SlowMoUtils {
if (freezeEnabled) {
if (frozen == state) return;
try {
field.set(getWorldHandle.invoke(world), state);
field.set(((CraftWorld) world).getHandle(), state);
frozen = state;
} catch (IllegalAccessException e) {
// Ignored;