mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fix OfflinePlayerUtil runtime exception
This commit is contained in:
parent
271109a726
commit
254a0541cc
@ -12,9 +12,11 @@ import java.util.UUID;
|
|||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.callConstructor;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.callConstructor;
|
||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.callMethod;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.callMethod;
|
||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getCbClass;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getCbClass;
|
||||||
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getField;
|
||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getNmsClass;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getNmsClass;
|
||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getUtilClass;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getUtilClass;
|
||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeConstructor;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeConstructor;
|
||||||
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeField;
|
||||||
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeMethod;
|
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeMethod;
|
||||||
|
|
||||||
public class OfflinePlayerUtil {
|
public class OfflinePlayerUtil {
|
||||||
@ -67,11 +69,26 @@ public class OfflinePlayerUtil {
|
|||||||
return callConstructor(c, worldServer);
|
return callConstructor(c, worldServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object getWorldServerNew() {
|
||||||
|
Object server = getMinecraftServer();
|
||||||
|
Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
|
||||||
|
Class<?> dimensionManager = getNmsClass("DimensionManager");
|
||||||
|
Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null);
|
||||||
|
Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", dimensionManager);
|
||||||
|
return callMethod(getWorldServer, server, overworld);
|
||||||
|
}
|
||||||
|
|
||||||
private static Object getWorldServer() {
|
private static Object getWorldServer() {
|
||||||
Object server = getMinecraftServer();
|
Object server = getMinecraftServer();
|
||||||
Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
|
Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
|
||||||
Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", int.class);
|
Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", int.class);
|
||||||
return callMethod(getWorldServer, server, 0);
|
Object o;
|
||||||
|
try {
|
||||||
|
o = callMethod(getWorldServer, server, 0);
|
||||||
|
} catch (final RuntimeException e) {
|
||||||
|
o = getWorldServerNew();
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NMS Utils
|
//NMS Utils
|
||||||
|
Loading…
Reference in New Issue
Block a user