Deleted leftovers and a couple of changes

This commit is contained in:
RePixelatedMC
2023-12-24 14:32:13 +01:00
parent ca78200c1c
commit aef05bad20
3 changed files with 49 additions and 31 deletions
@@ -94,6 +94,8 @@ import java.lang.management.OperatingSystemMXBean;
import java.net.URL; import java.net.URL;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.volmit.iris.core.safeguard.IrisSafeguard.*; import static com.volmit.iris.core.safeguard.IrisSafeguard.*;
import static com.volmit.iris.core.safeguard.ServerBootSFG.passedserversoftware; import static com.volmit.iris.core.safeguard.ServerBootSFG.passedserversoftware;
@@ -873,4 +875,33 @@ public class Iris extends VolmitPlugin implements Listener {
} }
Iris.info(" " + dimName + " v" + version); Iris.info(" " + dimName + " v" + version);
} }
public int getIrisVersion() {
String input = Iris.instance.getDescription().getVersion();
int hyphenIndex = input.indexOf('-');
if (hyphenIndex != -1) {
String result = input.substring(0, hyphenIndex);
result = result.replaceAll("\\.", "");
return Integer.parseInt(result);
}
return -1;
}
public int getMCVersion() {
try {
String version = Bukkit.getVersion();
Matcher matcher = Pattern.compile("\\(MC: ([\\d.]+)\\)").matcher(version);
if (matcher.find()) {
version = matcher.group(1).replaceAll("\\.", "");
long versionNumber = Long.parseLong(version);
if (versionNumber > Integer.MAX_VALUE) {
return -1;
}
return (int) versionNumber;
}
return -1;
} catch (Exception e) {
return -1;
}
}
} }
@@ -117,6 +117,7 @@ public class IrisSettings {
@Data @Data
public static class IrisSettingsWorld { public static class IrisSettingsWorld {
public boolean forceBootWorlds = false;
public IrisAsyncTeleport asyncTeleport = new IrisAsyncTeleport(); public IrisAsyncTeleport asyncTeleport = new IrisAsyncTeleport();
public boolean postLoadBlockUpdates = true; public boolean postLoadBlockUpdates = true;
public boolean forcePersistEntities = true; public boolean forcePersistEntities = true;
@@ -21,6 +21,7 @@ package com.volmit.iris.engine;
import com.google.common.util.concurrent.AtomicDouble; import com.google.common.util.concurrent.AtomicDouble;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator; import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.events.IrisEngineHotloadEvent; import com.volmit.iris.core.events.IrisEngineHotloadEvent;
import com.volmit.iris.core.gui.PregeneratorJob; import com.volmit.iris.core.gui.PregeneratorJob;
@@ -258,8 +259,11 @@ public class IrisEngine implements Engine {
try { try {
f.getParentFile().mkdirs(); f.getParentFile().mkdirs();
IrisEngineData data = new IrisEngineData(); IrisEngineData data = new IrisEngineData();
data.getStatistics().setVersion(getIrisVersion()); data.getStatistics().setVersion(Iris.instance.getIrisVersion());
data.getStatistics().setMCVersion(getMCVersion()); data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
if (data.getStatistics().getVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) {
Iris.error("Failed to setup Engine Data!");
}
IO.writeAll(f, new Gson().toJson(data)); IO.writeAll(f, new Gson().toJson(data));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@@ -528,36 +532,18 @@ public class IrisEngine implements Engine {
return cacheId; return cacheId;
} }
private int getIrisVersion() { private boolean EngineSafe() {
String input = Iris.instance.getDescription().getVersion(); // Todo: this has potential if done right
int hyphenIndex = input.indexOf('-'); int EngineMCVersion = getEngineData().getStatistics().getMCVersion();
if (hyphenIndex != -1) { int EngineIrisVersion = getEngineData().getStatistics().getVersion();
String result = input.substring(0, hyphenIndex); int MinecraftVersion = Iris.instance.getMCVersion();
result = result.replaceAll("\\.", ""); int IrisVersion = Iris.instance.getIrisVersion();
return Integer.parseInt(result); if (EngineIrisVersion != IrisVersion) {
return false;
} }
Iris.error("Failed to assign a Iris Version"); if (EngineMCVersion != MinecraftVersion) {
return 0; return false;
}
private int getMCVersion() {
try {
String version = Bukkit.getVersion();
Matcher matcher = Pattern.compile("\\(MC: ([\\d.]+)\\)").matcher(version);
if (matcher.find()) {
version = matcher.group(1).replaceAll("\\.", "");
long versionNumber = Long.parseLong(version);
if (versionNumber > Integer.MAX_VALUE) {
return -1;
}
return (int) versionNumber;
}
Iris.error("Failed to assign a Minecraft Version");
return -1;
} catch (Exception e) {
Iris.error("Failed to assign a Minecraft Version");
return -1;
} }
return true;
} }
} }