mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-26 10:44:42 +02:00
Some fixes
This commit is contained in:
@ -56,6 +56,12 @@ public interface IPlotMain {
|
||||
*/
|
||||
int[] getServerVersion();
|
||||
|
||||
/**
|
||||
* Get the nms package prefix
|
||||
* @return
|
||||
*/
|
||||
String getNMSPackage();
|
||||
|
||||
/**
|
||||
* Get the schematic handler
|
||||
* @return
|
||||
|
@ -75,6 +75,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
@ -129,6 +130,7 @@ public class PS {
|
||||
this.thread = Thread.currentThread();
|
||||
SetupUtils.generators = new HashMap<>();
|
||||
IMP = imp_class;
|
||||
new ReflectionUtils(IMP.getNMSPackage());
|
||||
URL url;
|
||||
try {
|
||||
url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
|
@ -87,14 +87,14 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
private ScriptEngine engine;
|
||||
private Bindings scope;
|
||||
|
||||
|
||||
public void init() {
|
||||
if (engine != null) {
|
||||
return;
|
||||
}
|
||||
engine = (new ScriptEngineManager()).getEngineByName("nashorn");
|
||||
engine = (new ScriptEngineManager(null)).getEngineByName("nashorn");
|
||||
if (engine == null) {
|
||||
engine = (new ScriptEngineManager()).getEngineByName("JavaScript");
|
||||
engine = (new ScriptEngineManager(null)).getEngineByName("JavaScript");
|
||||
}
|
||||
ScriptContext context = new SimpleScriptContext();
|
||||
scope = context.getBindings(ScriptContext.ENGINE_SCOPE);
|
||||
|
@ -947,7 +947,11 @@ public class SQLManager implements AbstractDB {
|
||||
user = UUID.fromString(o);
|
||||
uuids.put(o, user);
|
||||
}
|
||||
Timestamp timestamp = r.getTimestamp("timestamp");
|
||||
Timestamp timestamp = null;
|
||||
try {
|
||||
timestamp = r.getTimestamp("timestamp");
|
||||
}
|
||||
catch (Exception e) {};
|
||||
long time;
|
||||
if (timestamp == null) {
|
||||
time = plot_id.hashCode();
|
||||
|
@ -30,14 +30,18 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
/**
|
||||
* @author DPOH-VAR
|
||||
* @version 1.0
|
||||
*/
|
||||
@SuppressWarnings({ "UnusedDeclaration", "rawtypes" })
|
||||
public class ReflectionUtils {
|
||||
|
||||
public ReflectionUtils(String version) {
|
||||
preClassB += "." + version;
|
||||
preClassM += "." + version;
|
||||
}
|
||||
|
||||
/**
|
||||
* prefix of bukkit classes
|
||||
*/
|
||||
@ -46,36 +50,6 @@ public class ReflectionUtils {
|
||||
* prefix of minecraft classes
|
||||
*/
|
||||
private static String preClassM = "net.minecraft.server";
|
||||
/**
|
||||
* boolean value, TRUE if server uses forge or MCPC+
|
||||
*/
|
||||
private static boolean forge = false;
|
||||
/** check server version and class names */
|
||||
static {
|
||||
if (Bukkit.getServer() != null) {
|
||||
if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) {
|
||||
forge = true;
|
||||
}
|
||||
final Server server = Bukkit.getServer();
|
||||
final Class<?> bukkitServerClass = server.getClass();
|
||||
String[] pas = bukkitServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
final String verB = pas[3];
|
||||
preClassB += "." + verB;
|
||||
}
|
||||
try {
|
||||
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
||||
final Object handle = getHandle.invoke(server);
|
||||
final Class handleServerClass = handle.getClass();
|
||||
pas = handleServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
final String verM = pas[3];
|
||||
preClassM += "." + verM;
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getNmsClass(final String name) {
|
||||
final String className = "net.minecraft.server." + getVersion() + "." + name;
|
||||
@ -211,13 +185,6 @@ public class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if server has forge classes
|
||||
*/
|
||||
public static boolean isForge() {
|
||||
return forge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
|
||||
* {nm} to net.minecraft
|
||||
|
Reference in New Issue
Block a user