mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-31 04:46:40 +00:00
- Saving iris and mc version data to engine
This commit is contained in:
@@ -24,6 +24,7 @@ import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.ServerConfigurator;
|
||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.core.safeguard.UtilsSFG;
|
||||
@@ -45,6 +46,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
|
||||
import static com.volmit.iris.core.safeguard.IrisSafeguard.unstablemode;
|
||||
@@ -173,7 +176,6 @@ public class IrisCreator {
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (benchmark){loaded = true;}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -64,6 +65,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(exclude = "context")
|
||||
@@ -254,7 +257,10 @@ public class IrisEngine implements Engine {
|
||||
if (!f.exists()) {
|
||||
try {
|
||||
f.getParentFile().mkdirs();
|
||||
IO.writeAll(f, new Gson().toJson(new IrisEngineData()));
|
||||
IrisEngineData data = new IrisEngineData();
|
||||
data.getStatistics().setVersion(getIrisVersion());
|
||||
data.getStatistics().setMCVersion(getMCVersion());
|
||||
IO.writeAll(f, new Gson().toJson(data));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -521,4 +527,37 @@ public class IrisEngine implements Engine {
|
||||
public int getCacheID() {
|
||||
return cacheId;
|
||||
}
|
||||
|
||||
private 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);
|
||||
}
|
||||
Iris.error("Failed to assign a Iris Version");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,35 +29,28 @@ import java.util.regex.Pattern;
|
||||
public class IrisEngineStatistics {
|
||||
private int totalHotloads = 0;
|
||||
private int chunksGenerated = 0;
|
||||
private String IrisCreationVersion = getVersion();
|
||||
private String MinecraftVersion = getMCVersion();
|
||||
private int IrisCreationVersion = 0;
|
||||
private int MinecraftVersion = 0;
|
||||
|
||||
public void generatedChunk() {
|
||||
chunksGenerated++;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
String input = Iris.instance.getDescription().getVersion();
|
||||
int hyphenIndex = input.indexOf('-');
|
||||
|
||||
String result = null;
|
||||
if (hyphenIndex != -1) {
|
||||
result = input.substring(0, hyphenIndex);
|
||||
}
|
||||
return result;
|
||||
public void setVersion(int i) {
|
||||
IrisCreationVersion = i;
|
||||
}
|
||||
public String getMCVersion() {
|
||||
String bukkitVersion = "git-Purpur-2023 (MC: 1.20.1)";
|
||||
|
||||
Pattern pattern = Pattern.compile("\\(MC: (\\d+\\.\\d+(\\.\\d+)?)\\)");
|
||||
Matcher matcher = pattern.matcher(bukkitVersion);
|
||||
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
} else {
|
||||
return "ERROR"; // todo: Maybe do something ?
|
||||
}
|
||||
public void setMCVersion(int i) {
|
||||
MinecraftVersion = i;
|
||||
}
|
||||
public int getMCVersion() {
|
||||
return MinecraftVersion;
|
||||
}
|
||||
public int getVersion() {
|
||||
return MinecraftVersion;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void hotloaded() {
|
||||
|
||||
Reference in New Issue
Block a user