Formatting

This commit is contained in:
Brian Neumann-Fopiano 2024-08-07 20:08:11 -04:00
parent ec1187923b
commit ae2600227e
110 changed files with 1041 additions and 1039 deletions

View File

@ -30,6 +30,8 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X; import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.core.pregenerator.LazyPregenerator; import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.safeguard.IrisSafeguard;
import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.EnginePanic; import com.volmit.iris.engine.EnginePanic;
@ -38,8 +40,6 @@ import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld; import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator; import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator; import com.volmit.iris.engine.platform.DummyChunkGenerator;
import com.volmit.iris.core.safeguard.IrisSafeguard;
import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.exceptions.IrisException; import com.volmit.iris.util.exceptions.IrisException;
@ -52,7 +52,6 @@ import com.volmit.iris.util.io.InstanceState;
import com.volmit.iris.util.io.JarScanner; import com.volmit.iris.util.io.JarScanner;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.misc.E;
import com.volmit.iris.util.misc.getHardware; import com.volmit.iris.util.misc.getHardware;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.IrisService; import com.volmit.iris.util.plugin.IrisService;
@ -64,16 +63,16 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Queue; import com.volmit.iris.util.scheduling.Queue;
import com.volmit.iris.util.scheduling.ShurikenQueue; import com.volmit.iris.util.scheduling.ShurikenQueue;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import lombok.Getter;
import net.bytebuddy.agent.ByteBuddyAgent; import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.implementation.bytecode.Throw;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter; import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter; import org.bukkit.Bukkit;
import org.bukkit.*; import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.WorldCreator;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -93,18 +92,15 @@ import org.jetbrains.annotations.Nullable;
import java.io.*; import java.io.*;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.Collection;
import java.util.function.Supplier; import java.util.Date;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.volmit.iris.core.safeguard.IrisSafeguard.*; import static com.volmit.iris.core.safeguard.IrisSafeguard.InitializeSafeguard;
import static com.volmit.iris.core.safeguard.ServerBootSFG.passedserversoftware;
import static com.volmit.iris.util.misc.getHardware.getCPUModel;
import static org.bukkit.Bukkit.getServer;
@SuppressWarnings("CanBeFinal") @SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener { public class Iris extends VolmitPlugin implements Listener {
@ -329,6 +325,7 @@ public class Iris extends VolmitPlugin implements Listener {
public static void info(String format, Object... args) { public static void info(String format, Object... args) {
msg(C.WHITE + String.format(format, args)); msg(C.WHITE + String.format(format, args));
} }
public static void safeguard(String format, Object... args) { public static void safeguard(String format, Object... args) {
msg(C.RESET + String.format(format, args)); msg(C.RESET + String.format(format, args));
} }
@ -457,6 +454,7 @@ public class Iris extends VolmitPlugin implements Listener {
private static void fixShading() { private static void fixShading() {
ShadeFix.fix(ComponentSerializer.class); ShadeFix.fix(ComponentSerializer.class);
} }
private void enable() { private void enable() {
instance = this; instance = this;
InitializeSafeguard(); InitializeSafeguard();
@ -469,7 +467,8 @@ public class Iris extends VolmitPlugin implements Listener {
IrisSafeguard.instance.IrisSafeguardSystem(); IrisSafeguard.instance.IrisSafeguardSystem();
getSender().setTag(getTag()); getSender().setTag(getTag());
INMS.get().injectBukkit(); INMS.get().injectBukkit();
if (IrisSafeguard.instance.unstablemode && !IrisSafeguard.instance.acceptUnstable) IrisSafeguard.instance.earlySplash(); if (IrisSafeguard.instance.unstablemode && !IrisSafeguard.instance.acceptUnstable)
IrisSafeguard.instance.earlySplash();
compat = IrisCompat.configured(getDataFile("compat.json")); compat = IrisCompat.configured(getDataFile("compat.json"));
linkMultiverseCore = new MultiverseCoreLink(); linkMultiverseCore = new MultiverseCoreLink();
linkMythicMobs = new MythicMobsLink(); linkMythicMobs = new MythicMobsLink();
@ -527,7 +526,7 @@ public class Iris extends VolmitPlugin implements Listener {
File world = new File(Bukkit.getWorldContainer().getPath() + "/" + s + "/iris/engine-data/"); File world = new File(Bukkit.getWorldContainer().getPath() + "/" + s + "/iris/engine-data/");
IOFileFilter jsonFilter = org.apache.commons.io.filefilter.FileFilterUtils.suffixFileFilter(".json"); IOFileFilter jsonFilter = org.apache.commons.io.filefilter.FileFilterUtils.suffixFileFilter(".json");
Collection<File> files = FileUtils.listFiles(world, jsonFilter, TrueFileFilter.INSTANCE); Collection<File> files = FileUtils.listFiles(world, jsonFilter, TrueFileFilter.INSTANCE);
if(files.size() != 1) { if (files.size() != 1) {
Iris.info(C.DARK_GRAY + "------------------------------------------"); Iris.info(C.DARK_GRAY + "------------------------------------------");
Iris.info(C.RED + "Failed to load " + C.GRAY + s + C.RED + ". No valid engine-data file was found."); Iris.info(C.RED + "Failed to load " + C.GRAY + s + C.RED + ". No valid engine-data file was found.");
Iris.info(C.DARK_GRAY + "------------------------------------------"); Iris.info(C.DARK_GRAY + "------------------------------------------");
@ -538,7 +537,7 @@ public class Iris extends VolmitPlugin implements Listener {
int lastDotIndex = file.getName().lastIndexOf("."); int lastDotIndex = file.getName().lastIndexOf(".");
generator = file.getName().substring(0, lastDotIndex); generator = file.getName().substring(0, lastDotIndex);
} }
} else { } else {
if (generator.startsWith("Iris:")) { if (generator.startsWith("Iris:")) {
generator = generator.split("\\Q:\\E")[1]; generator = generator.split("\\Q:\\E")[1];
} else if (generator.equalsIgnoreCase("Iris")) { } else if (generator.equalsIgnoreCase("Iris")) {
@ -857,35 +856,35 @@ public class Iris extends VolmitPlugin implements Listener {
} }
String[] info = { String[] info = {
"", "",
"", "",
"", "",
"", "",
"", "",
padd2 + colorIris + " Iris", padd2 + colorIris + " Iris",
padd2 + C.GRAY + " by " + colorVolmit + "Volmit Software", padd2 + C.GRAY + " by " + colorVolmit + "Volmit Software",
padd2 + C.GRAY + " v" + colorVersion + getDescription().getVersion() padd2 + C.GRAY + " v" + colorVersion + getDescription().getVersion()
}; };
String[] splash = { String[] splash = {
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@", padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + colorIris + " .(((()))). ", padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + colorIris + " .(((()))). ",
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + colorIris + " .((((((())))))). ", padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + colorIris + " .((((((())))))). ",
padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + colorIris + " ((((((((())))))))) " + C.GRAY + " @", padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + colorIris + " ((((((((())))))))) " + C.GRAY + " @",
padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + colorIris + " ((((((((-))))))))) " + C.GRAY + " @@", padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + colorIris + " ((((((((-))))))))) " + C.GRAY + " @@",
padd + C.GRAY + "@@@&&" + colorIris + " ((((((({ })))))))) " + C.GRAY + " &&@@@", padd + C.GRAY + "@@@&&" + colorIris + " ((((((({ })))))))) " + C.GRAY + " &&@@@",
padd + C.GRAY + "@@" + colorIris + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@", padd + C.GRAY + "@@" + colorIris + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@",
padd + C.GRAY + "@" + colorIris + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@", padd + C.GRAY + "@" + colorIris + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@",
padd + C.GRAY + "" + colorIris + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@", padd + C.GRAY + "" + colorIris + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@",
padd + C.GRAY + "" + colorIris + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@", padd + C.GRAY + "" + colorIris + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@" padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
}; };
setupChecks(); setupChecks();
Iris.info("Java: " + getJava()); Iris.info("Java: " + getJava());
if (!instance.getServer().getVersion().contains("Purpur")) { if (!instance.getServer().getVersion().contains("Purpur")) {
if (instance.getServer().getVersion().contains("Spigot") && instance.getServer().getVersion().contains("Bukkit")) { if (instance.getServer().getVersion().contains("Spigot") && instance.getServer().getVersion().contains("Bukkit")) {
Iris.info(C.RED + " Iris requires paper or above to function properly.."); Iris.info(C.RED + " Iris requires paper or above to function properly..");
} else { } else {
Iris.info(C.YELLOW + "Purpur is recommended to use with iris."); Iris.info(C.YELLOW + "Purpur is recommended to use with iris.");
} }

View File

@ -24,12 +24,10 @@ import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONException; import com.volmit.iris.util.json.JSONException;
import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.ChronoLatch;
import lombok.Data; import lombok.Data;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List;
@SuppressWarnings("SynchronizeOnNonFinalField") @SuppressWarnings("SynchronizeOnNonFinalField")
@Data @Data
@ -196,6 +194,7 @@ public class IrisSettings {
public boolean disableTimeAndWeather = true; public boolean disableTimeAndWeather = true;
public boolean autoStartDefaultStudio = false; public boolean autoStartDefaultStudio = false;
} }
@Data @Data
public static class IrisWorldDump { public static class IrisWorldDump {
public int mcaCacheSize = 3; public int mcaCacheSize = 3;

View File

@ -91,7 +91,7 @@ public class CommandDeveloper implements DecreeExecutor {
for (File i : Objects.requireNonNull(tectonicplates.listFiles())) { for (File i : Objects.requireNonNull(tectonicplates.listFiles())) {
TectonicPlate.read(maxHeight, i); TectonicPlate.read(maxHeight, i);
c++; c++;
sender().sendMessage("Loaded count: " + c ); sender().sendMessage("Loaded count: " + c);
} }
@ -115,11 +115,11 @@ public class CommandDeveloper implements DecreeExecutor {
} }
@Decree(description = "test") @Decree(description = "test")
public void mca ( public void mca(
@Param(description = "String") World world) { @Param(description = "String") World world) {
try { try {
IrisWorldDump dump = new IrisWorldDump(world, sender()); IrisWorldDump dump = new IrisWorldDump(world, sender());
dump.start(); dump.start();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -128,7 +128,7 @@ public class CommandDeveloper implements DecreeExecutor {
} }
@Decree(description = "test") @Decree(description = "test")
public void devtest () { public void devtest() {
try { try {
for (File mcafile : new File("rrtrender1/region").listFiles()) { for (File mcafile : new File("rrtrender1/region").listFiles()) {
@ -200,7 +200,7 @@ public class CommandDeveloper implements DecreeExecutor {
if (!file.exists()) return; if (!file.exists()) return;
Engine engine = IrisToolbelt.access(world).getEngine(); Engine engine = IrisToolbelt.access(world).getEngine();
if(engine != null) { if (engine != null) {
int height = engine.getTarget().getHeight(); int height = engine.getTarget().getHeight();
VolmitSender sender = sender(); VolmitSender sender = sender();
new Thread(() -> { new Thread(() -> {
@ -232,13 +232,13 @@ public class CommandDeveloper implements DecreeExecutor {
} }
IO.delete(folder); IO.delete(folder);
sender.sendMessage(algorithm + " is " + Form.fileSize(size) + " big after compression"); sender.sendMessage(algorithm + " is " + Form.fileSize(size) + " big after compression");
sender.sendMessage(algorithm + " Took " + d2/amount + "ms to read"); sender.sendMessage(algorithm + " Took " + d2 / amount + "ms to read");
sender.sendMessage(algorithm + " Took " + d1/amount + "ms to write"); sender.sendMessage(algorithm + " Took " + d1 / amount + "ms to write");
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
}, "Compression Test").start(); }, "Compression Test").start();
} else { } else {
Iris.info(C.RED + "Engine is null!"); Iris.info(C.RED + "Engine is null!");
} }
} }

View File

@ -27,10 +27,8 @@ import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.decree.specialhandlers.NullableBiomeHandler; import com.volmit.iris.util.decree.specialhandlers.NullableBiomeHandler;
import com.volmit.iris.util.decree.specialhandlers.NullablePlayerHandler;
import com.volmit.iris.util.decree.specialhandlers.NullableRegionHandler; import com.volmit.iris.util.decree.specialhandlers.NullableRegionHandler;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import org.bukkit.Location;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import java.awt.*; import java.awt.*;
@ -57,11 +55,11 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the biome you specified", aliases = {"b"}, origin = DecreeOrigin.PLAYER) @Decree(description = "Edit the biome you specified", aliases = {"b"}, origin = DecreeOrigin.PLAYER)
public void biome(@Param(contextual = false, description = "The biome to edit", defaultValue = "---", customHandler = NullableBiomeHandler.class) IrisBiome biome ) { public void biome(@Param(contextual = false, description = "The biome to edit", defaultValue = "---", customHandler = NullableBiomeHandler.class) IrisBiome biome) {
if (noStudio()) { if (noStudio()) {
return; return;
} }
if(biome == null) { if (biome == null) {
try { try {
IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY() - player().getWorld().getMinHeight(), player().getLocation().getBlockZ()); IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY() - player().getWorld().getMinHeight(), player().getLocation().getBlockZ());
Desktop.getDesktop().open(b.getLoadFile()); Desktop.getDesktop().open(b.getLoadFile());
@ -98,7 +96,7 @@ public class CommandEdit implements DecreeExecutor {
if (noStudio()) { if (noStudio()) {
return; return;
} }
if(region == null) { if (region == null) {
try { try {
IrisRegion r = engine().getRegion(player().getLocation().getBlockX(), player().getLocation().getBlockZ()); IrisRegion r = engine().getRegion(player().getLocation().getBlockX(), player().getLocation().getBlockZ());
Desktop.getDesktop().open(r.getLoadFile()); Desktop.getDesktop().open(r.getLoadFile());

View File

@ -20,17 +20,13 @@ package com.volmit.iris.core.commands;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.datapack.DataVersion;
import com.volmit.iris.core.pregenerator.ChunkUpdater; import com.volmit.iris.core.pregenerator.ChunkUpdater;
import com.volmit.iris.core.safeguard.IrisSafeguard;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisBenchmarking; import com.volmit.iris.core.tools.IrisBenchmarking;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.engine.object.IrisWorld; import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator; import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator; import com.volmit.iris.engine.platform.DummyChunkGenerator;
@ -44,13 +40,10 @@ import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import io.lumine.mythic.bukkit.adapters.BukkitPlayer;
import lombok.Getter;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter; import org.apache.commons.io.filefilter.TrueFileFilter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -60,10 +53,8 @@ import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.io.Console;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -71,11 +62,14 @@ import java.util.List;
import static com.volmit.iris.Iris.service; import static com.volmit.iris.Iris.service;
import static com.volmit.iris.core.service.EditSVC.deletingWorld; import static com.volmit.iris.core.service.EditSVC.deletingWorld;
import static com.volmit.iris.core.tools.IrisBenchmarking.inProgress; import static com.volmit.iris.core.tools.IrisBenchmarking.inProgress;
import static com.volmit.iris.core.safeguard.ServerBootSFG.incompatibilities;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command") @Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
public class CommandIris implements DecreeExecutor { public class CommandIris implements DecreeExecutor {
public static boolean worldCreation = false;
String WorldEngine;
String worldNameToCheck = "YourWorldName";
VolmitSender sender = Iris.getSender();
private CommandStudio studio; private CommandStudio studio;
private CommandPregen pregen; private CommandPregen pregen;
private CommandLazyPregen lazyPregen; private CommandLazyPregen lazyPregen;
@ -87,10 +81,19 @@ public class CommandIris implements DecreeExecutor {
private CommandFind find; private CommandFind find;
private CommandSupport support; private CommandSupport support;
private CommandDeveloper developer; private CommandDeveloper developer;
public static boolean worldCreation = false;
String WorldEngine; public static boolean deleteDirectory(File dir) {
String worldNameToCheck = "YourWorldName"; if (dir.isDirectory()) {
VolmitSender sender = Iris.getSender(); File[] children = dir.listFiles();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDirectory(children[i]);
if (!success) {
return false;
}
}
}
return dir.delete();
}
@Decree(description = "Create a new world", aliases = {"+", "c"}) @Decree(description = "Create a new world", aliases = {"+", "c"})
public void create( public void create(
@ -104,16 +107,16 @@ public class CommandIris implements DecreeExecutor {
boolean vanillaheight boolean vanillaheight
) { ) {
if (name.equals("iris")) { if (name.equals("iris")) {
sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds."); sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds.");
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?"); sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
return; return;
} }
if (name.equals("Benchmark")) { if (name.equals("Benchmark")) {
sender().sendMessage(C.RED + "You cannot use the world name \"Benchmark\" for creating worlds as Iris uses this directory for Benchmarking Packs."); sender().sendMessage(C.RED + "You cannot use the world name \"Benchmark\" for creating worlds as Iris uses this directory for Benchmarking Packs.");
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?"); sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
return; return;
} }
if (new File(Bukkit.getWorldContainer(), name).exists()) { if (new File(Bukkit.getWorldContainer(), name).exists()) {
sender().sendMessage(C.RED + "That folder already exists!"); sender().sendMessage(C.RED + "That folder already exists!");
@ -171,16 +174,6 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
} }
//todo Move to React
@Decree(description = "Benchmark your server", origin = DecreeOrigin.CONSOLE)
public void serverbenchmark() throws InterruptedException {
if(!inProgress) {
IrisBenchmarking.runBenchmark();
} else {
Iris.info(C.RED + "Benchmark already is in progress.");
}
}
/* /*
/todo /todo
@Decree(description = "Benchmark a pack", origin = DecreeOrigin.CONSOLE) @Decree(description = "Benchmark a pack", origin = DecreeOrigin.CONSOLE)
@ -194,6 +187,16 @@ public class CommandIris implements DecreeExecutor {
IrisPackBenchmarking.runBenchmark(); IrisPackBenchmarking.runBenchmark();
} */ } */
//todo Move to React
@Decree(description = "Benchmark your server", origin = DecreeOrigin.CONSOLE)
public void serverbenchmark() throws InterruptedException {
if (!inProgress) {
IrisBenchmarking.runBenchmark();
} else {
Iris.info(C.RED + "Benchmark already is in progress.");
}
}
@Decree(description = "Print world height information", origin = DecreeOrigin.PLAYER) @Decree(description = "Print world height information", origin = DecreeOrigin.PLAYER)
public void height() { public void height() {
if (sender().isPlayer()) { if (sender().isPlayer()) {
@ -231,20 +234,20 @@ public class CommandIris implements DecreeExecutor {
if (sender().isPlayer()) { if (sender().isPlayer()) {
sender().sendMessage(C.BLUE + "Iris Worlds: "); sender().sendMessage(C.BLUE + "Iris Worlds: ");
for (World IrisWorld : IrisWorlds.copy()) { for (World IrisWorld : IrisWorlds.copy()) {
sender().sendMessage(C.IRIS + "- " +IrisWorld.getName()); sender().sendMessage(C.IRIS + "- " + IrisWorld.getName());
} }
sender().sendMessage(C.GOLD + "Bukkit Worlds: "); sender().sendMessage(C.GOLD + "Bukkit Worlds: ");
for (World BukkitWorld : BukkitWorlds.copy()) { for (World BukkitWorld : BukkitWorlds.copy()) {
sender().sendMessage(C.GRAY + "- " +BukkitWorld.getName()); sender().sendMessage(C.GRAY + "- " + BukkitWorld.getName());
} }
} else { } else {
Iris.info(C.BLUE + "Iris Worlds: "); Iris.info(C.BLUE + "Iris Worlds: ");
for (World IrisWorld : IrisWorlds.copy()) { for (World IrisWorld : IrisWorlds.copy()) {
Iris.info(C.IRIS + "- " +IrisWorld.getName()); Iris.info(C.IRIS + "- " + IrisWorld.getName());
} }
Iris.info(C.GOLD + "Bukkit Worlds: "); Iris.info(C.GOLD + "Bukkit Worlds: ");
for (World BukkitWorld : BukkitWorlds.copy()) { for (World BukkitWorld : BukkitWorlds.copy()) {
Iris.info(C.GRAY + "- " +BukkitWorld.getName()); Iris.info(C.GRAY + "- " + BukkitWorld.getName());
} }
} }
@ -280,13 +283,13 @@ public class CommandIris implements DecreeExecutor {
if (deleteDirectory(world.getWorldFolder())) { if (deleteDirectory(world.getWorldFolder())) {
sender().sendMessage(C.GREEN + "Successfully removed world folder"); sender().sendMessage(C.GREEN + "Successfully removed world folder");
} else { } else {
while(true){ while (true) {
if (deleteDirectory(world.getWorldFolder())){ if (deleteDirectory(world.getWorldFolder())) {
sender().sendMessage(C.GREEN + "Successfully removed world folder"); sender().sendMessage(C.GREEN + "Successfully removed world folder");
break; break;
} }
retries--; retries--;
if (retries == 0){ if (retries == 0) {
sender().sendMessage(C.RED + "Failed to remove world folder"); sender().sendMessage(C.RED + "Failed to remove world folder");
break; break;
} }
@ -297,19 +300,6 @@ public class CommandIris implements DecreeExecutor {
deletingWorld = false; deletingWorld = false;
} }
public static boolean deleteDirectory(File dir) {
if (dir.isDirectory()) {
File[] children = dir.listFiles();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDirectory(children[i]);
if (!success) {
return false;
}
}
}
return dir.delete();
}
@Decree(description = "Updates all chunk in the specified world") @Decree(description = "Updates all chunk in the specified world")
public void updater( public void updater(
@Param(description = "World to update chunks at") @Param(description = "World to update chunks at")
@ -507,7 +497,7 @@ public class CommandIris implements DecreeExecutor {
File worldFolder = new File(Bukkit.getWorldContainer().getPath() + "/" + s + "/iris/engine-data/"); File worldFolder = new File(Bukkit.getWorldContainer().getPath() + "/" + s + "/iris/engine-data/");
IOFileFilter jsonFilter = org.apache.commons.io.filefilter.FileFilterUtils.suffixFileFilter(".json"); IOFileFilter jsonFilter = org.apache.commons.io.filefilter.FileFilterUtils.suffixFileFilter(".json");
Collection<File> files = FileUtils.listFiles(worldFolder, jsonFilter, TrueFileFilter.INSTANCE); Collection<File> files = FileUtils.listFiles(worldFolder, jsonFilter, TrueFileFilter.INSTANCE);
if(files.size() != 1) { if (files.size() != 1) {
Iris.info(C.DARK_GRAY + "------------------------------------------"); Iris.info(C.DARK_GRAY + "------------------------------------------");
Iris.info(C.RED + "Failed to load " + C.GRAY + s + C.RED + ". No valid engine-data file was found."); Iris.info(C.RED + "Failed to load " + C.GRAY + s + C.RED + ". No valid engine-data file was found.");
Iris.info(C.DARK_GRAY + "------------------------------------------"); Iris.info(C.DARK_GRAY + "------------------------------------------");
@ -543,6 +533,7 @@ public class CommandIris implements DecreeExecutor {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true) @Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
public void evacuate( public void evacuate(
@Param(description = "Evacuate the world") @Param(description = "Evacuate the world")
@ -561,6 +552,7 @@ public class CommandIris implements DecreeExecutor {
File worldDirectory = new File(worldContainer, worldName); File worldDirectory = new File(worldContainer, worldName);
return worldDirectory.exists() && worldDirectory.isDirectory(); return worldDirectory.exists() && worldDirectory.isDirectory();
} }
private void checkForBukkitWorlds(String world) { private void checkForBukkitWorlds(String world) {
FileConfiguration fc = new YamlConfiguration(); FileConfiguration fc = new YamlConfiguration();
try { try {
@ -572,7 +564,7 @@ public class CommandIris implements DecreeExecutor {
List<String> worldsToLoad = Collections.singletonList(world); List<String> worldsToLoad = Collections.singletonList(world);
for (String s : section.getKeys(false)) { for (String s : section.getKeys(false)) {
if (!worldsToLoad.contains(s)) { if (!worldsToLoad.contains(s)) {
continue; continue;
} }
@ -603,6 +595,7 @@ public class CommandIris implements DecreeExecutor {
e.printStackTrace(); e.printStackTrace();
} }
} }
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
Iris.debug("Default World Generator Called for " + worldName + " using ID: " + id); Iris.debug("Default World Generator Called for " + worldName + " using ID: " + id);
if (worldName.equals("test")) { if (worldName.equals("test")) {

View File

@ -19,16 +19,11 @@
package com.volmit.iris.core.commands; package com.volmit.iris.core.commands;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.pregenerator.LazyPregenerator; import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -39,6 +34,7 @@ import java.io.IOException;
@Decree(name = "lazypregen", aliases = "lazy", description = "Pregenerate your Iris worlds!") @Decree(name = "lazypregen", aliases = "lazy", description = "Pregenerate your Iris worlds!")
public class CommandLazyPregen implements DecreeExecutor { public class CommandLazyPregen implements DecreeExecutor {
public String worldName; public String worldName;
@Decree(description = "Pregenerate a world") @Decree(description = "Pregenerate a world")
public void start( public void start(
@Param(description = "The radius of the pregen in blocks", aliases = "size") @Param(description = "The radius of the pregen in blocks", aliases = "size")
@ -51,7 +47,7 @@ public class CommandLazyPregen implements DecreeExecutor {
int cpm, int cpm,
@Param(aliases = "silent", description = "Silent generation", defaultValue = "false") @Param(aliases = "silent", description = "Silent generation", defaultValue = "false")
boolean silent boolean silent
) { ) {
worldName = world.getName(); worldName = world.getName();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName()); File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());

View File

@ -74,7 +74,8 @@ public class CommandObject implements DecreeExecutor {
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
//Prevent blocks being set in or bellow bedrock //Prevent blocks being set in or bellow bedrock
if (y <= world.getMinHeight() || block.getType() == Material.BEDROCK) return; if (y <= world.getMinHeight() || block.getType() == Material.BEDROCK)
return;
futureBlockChanges.put(block, block.getBlockData()); futureBlockChanges.put(block, block.getBlockData());
@ -428,7 +429,7 @@ public class CommandObject implements DecreeExecutor {
ObjectSVC service = Iris.service(ObjectSVC.class); ObjectSVC service = Iris.service(ObjectSVC.class);
int actualReverts = Math.min(service.getUndos().size(), amount); int actualReverts = Math.min(service.getUndos().size(), amount);
service.revertChanges(actualReverts); service.revertChanges(actualReverts);
sender().sendMessage(C.BLUE + "Reverted " + actualReverts + C.BLUE +" pastes!"); sender().sendMessage(C.BLUE + "Reverted " + actualReverts + C.BLUE + " pastes!");
} }
@Decree(description = "Gets an object wand and grabs the current WorldEdit selection.", aliases = "we", origin = DecreeOrigin.PLAYER, studio = true) @Decree(description = "Gets an object wand and grabs the current WorldEdit selection.", aliases = "we", origin = DecreeOrigin.PLAYER, studio = true)

View File

@ -19,9 +19,7 @@
package com.volmit.iris.core.commands; package com.volmit.iris.core.commands;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.PregeneratorJob; import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
@ -29,12 +27,10 @@ import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.Position2;
import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.awt.*; import java.awt.*;
import java.io.File;
@Decree(name = "pregen", aliases = "pregenerate", description = "Pregenerate your Iris worlds!") @Decree(name = "pregen", aliases = "pregenerate", description = "Pregenerate your Iris worlds!")
public class CommandPregen implements DecreeExecutor { public class CommandPregen implements DecreeExecutor {
@ -80,7 +76,7 @@ public class CommandPregen implements DecreeExecutor {
@Decree(description = "Stop the active pregeneration task", aliases = "x") @Decree(description = "Stop the active pregeneration task", aliases = "x")
public void stop() { public void stop() {
if (PregeneratorJob.shutdownInstance()) { if (PregeneratorJob.shutdownInstance()) {
Iris.info( C.BLUE + "Finishing up mca region..."); Iris.info(C.BLUE + "Finishing up mca region...");
} else { } else {
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop"); sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop");
} }

View File

@ -197,7 +197,8 @@ public class CommandStudio implements DecreeExecutor {
while (futures.isNotEmpty()) { while (futures.isNotEmpty()) {
try { try {
futures.remove(0).get(); futures.remove(0).get();
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException |
ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -335,7 +336,7 @@ public class CommandStudio implements DecreeExecutor {
return; return;
} }
var sender = sender(); var sender = sender();
int d = radius*2; int d = radius * 2;
KMap<String, KList<Position2>> data = new KMap<>(); KMap<String, KList<Position2>> data = new KMap<>();
var multiBurst = new MultiBurst("Distance Sampler", Thread.MIN_PRIORITY); var multiBurst = new MultiBurst("Distance Sampler", Thread.MIN_PRIORITY);
var executor = multiBurst.burst(radius * radius); var executor = multiBurst.burst(radius * radius);

View File

@ -31,7 +31,8 @@ public class CommandSupport implements DecreeExecutor {
@Decree(description = "report") @Decree(description = "report")
public void report() { public void report() {
try { try {
if (sender().isPlayer()) sender().sendMessage(C.GOLD + "Creating report.."); if (sender().isPlayer())
sender().sendMessage(C.GOLD + "Creating report..");
if (!sender().isPlayer()) Iris.info(C.GOLD + "Creating report.."); if (!sender().isPlayer()) Iris.info(C.GOLD + "Creating report..");
Hastebin.enviornment(sender()); Hastebin.enviornment(sender());

View File

@ -19,8 +19,6 @@
package com.volmit.iris.core.commands; package com.volmit.iris.core.commands;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.TurboPregenerator;
import com.volmit.iris.core.pregenerator.TurboPregenerator; import com.volmit.iris.core.pregenerator.TurboPregenerator;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Decree;
@ -36,6 +34,7 @@ import java.io.IOException;
@Decree(name = "turbopregen", aliases = "turbo", description = "Pregenerate your Iris worlds!") @Decree(name = "turbopregen", aliases = "turbo", description = "Pregenerate your Iris worlds!")
public class CommandTurboPregen implements DecreeExecutor { public class CommandTurboPregen implements DecreeExecutor {
public String worldName; public String worldName;
@Decree(description = "Pregenerate a world") @Decree(description = "Pregenerate a world")
public void start( public void start(
@Param(description = "The radius of the pregen in blocks", aliases = "size") @Param(description = "The radius of the pregen in blocks", aliases = "size")
@ -44,7 +43,7 @@ public class CommandTurboPregen implements DecreeExecutor {
World world, World world,
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") @Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
Vector center Vector center
) { ) {
worldName = world.getName(); worldName = world.getName();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName()); File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
@ -57,9 +56,9 @@ public class CommandTurboPregen implements DecreeExecutor {
} else { } else {
try { try {
TurboFile.delete(); TurboFile.delete();
} catch (Exception e){ } catch (Exception e) {
Iris.error("Failed to delete the old instance file of Turbo Pregen!"); Iris.error("Failed to delete the old instance file of Turbo Pregen!");
return; return;
} }
} }
} }
@ -119,7 +118,7 @@ public class CommandTurboPregen implements DecreeExecutor {
} else { } else {
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName()); File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File TurboFile = new File(worldDirectory, "turbogen.json"); File TurboFile = new File(worldDirectory, "turbogen.json");
if (TurboFile.exists()){ if (TurboFile.exists()) {
TurboPregenerator.loadTurboGenerator(world.getName()); TurboPregenerator.loadTurboGenerator(world.getName());
sender().sendMessage(C.YELLOW + "Started Turbo Pregen back up!"); sender().sendMessage(C.YELLOW + "Started Turbo Pregen back up!");
} else { } else {

View File

@ -18,8 +18,6 @@
package com.volmit.iris.core.commands; package com.volmit.iris.core.commands;
import org.bukkit.World;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.pregenerator.ChunkUpdater; import com.volmit.iris.core.pregenerator.ChunkUpdater;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
@ -29,6 +27,7 @@ import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import org.bukkit.World;
@Decree(name = "updater", origin = DecreeOrigin.BOTH, description = "Iris World Updater") @Decree(name = "updater", origin = DecreeOrigin.BOTH, description = "Iris World Updater")
public class CommandUpdater implements DecreeExecutor { public class CommandUpdater implements DecreeExecutor {
@ -45,7 +44,7 @@ public class CommandUpdater implements DecreeExecutor {
} }
chunkUpdater = new ChunkUpdater(world); chunkUpdater = new ChunkUpdater(world);
if (sender().isPlayer()) { if (sender().isPlayer()) {
sender().sendMessage(C.GREEN + "Updating " + world.getName() + C.GRAY + " Total chunks: " + Form.f(chunkUpdater.getChunks())); sender().sendMessage(C.GREEN + "Updating " + world.getName() + C.GRAY + " Total chunks: " + Form.f(chunkUpdater.getChunks()));
} else { } else {
Iris.info(C.GREEN + "Updating " + world.getName() + C.GRAY + " Total chunks: " + Form.f(chunkUpdater.getChunks())); Iris.info(C.GREEN + "Updating " + world.getName() + C.GRAY + " Total chunks: " + Form.f(chunkUpdater.getChunks()));
} }

View File

@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.edit.BlockSignal; import com.volmit.iris.core.edit.BlockSignal;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
@ -39,7 +38,6 @@ import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?") @Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?")

View File

@ -24,7 +24,6 @@ import com.volmit.iris.core.pregenerator.IrisPregenerator;
import com.volmit.iris.core.pregenerator.PregenListener; import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.pregenerator.PregeneratorMethod; import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
@ -45,8 +44,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer; import java.util.function.Consumer;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmarkInProgress;
public class PregeneratorJob implements PregenListener { public class PregeneratorJob implements PregenListener {
private static final Color COLOR_EXISTS = parseColor("#4d7d5b"); private static final Color COLOR_EXISTS = parseColor("#4d7d5b");
private static final Color COLOR_BLACK = parseColor("#4d7d5b"); private static final Color COLOR_BLACK = parseColor("#4d7d5b");

View File

@ -59,7 +59,8 @@ public class EcoItemsDataProvider extends ExternalDataProvider {
@Override @Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException { public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
EcoItem item = EcoItems.INSTANCE.getByID(itemId.key()); EcoItem item = EcoItems.INSTANCE.getByID(itemId.key());
if (item == null) throw new MissingResourceException("Failed to find Item!", itemId.namespace(), itemId.key()); if (item == null)
throw new MissingResourceException("Failed to find Item!", itemId.namespace(), itemId.key());
return itemStack.get(item).clone(); return itemStack.get(item).clone();
} }

View File

@ -58,7 +58,8 @@ public abstract class ExternalDataProvider {
public abstract ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException; public abstract ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException;
public void processUpdate(Engine engine, Block block, Identifier blockId) {} public void processUpdate(Engine engine, Block block, Identifier blockId) {
}
public abstract Identifier[] getBlockTypes(); public abstract Identifier[] getBlockTypes();

View File

@ -40,118 +40,118 @@ import java.util.MissingResourceException;
import java.util.function.Supplier; import java.util.function.Supplier;
public class HMCLeavesDataProvider extends ExternalDataProvider { public class HMCLeavesDataProvider extends ExternalDataProvider {
private Object apiInstance; private Object apiInstance;
private WrappedReturningMethod<Object, Material> worldBlockType; private WrappedReturningMethod<Object, Material> worldBlockType;
private WrappedReturningMethod<Object, Boolean> setCustomBlock; private WrappedReturningMethod<Object, Boolean> setCustomBlock;
private Map<String, Object> blockDataMap = Map.of(); private Map<String, Object> blockDataMap = Map.of();
private Map<String, Supplier<ItemStack>> itemDataField = Map.of(); private Map<String, Supplier<ItemStack>> itemDataField = Map.of();
public HMCLeavesDataProvider() { public HMCLeavesDataProvider() {
super("HMCLeaves"); super("HMCLeaves");
} }
@Override @Override
public String getPluginId() { public String getPluginId() {
return "HMCLeaves"; return "HMCLeaves";
} }
@Override @Override
public void init() { public void init() {
try { try {
worldBlockType = new WrappedReturningMethod<>((Class<Object>) Class.forName("io.github.fisher2911.hmcleaves.data.BlockData"), "worldBlockType"); worldBlockType = new WrappedReturningMethod<>((Class<Object>) Class.forName("io.github.fisher2911.hmcleaves.data.BlockData"), "worldBlockType");
apiInstance = getApiInstance(Class.forName("io.github.fisher2911.hmcleaves.api.HMCLeavesAPI")); apiInstance = getApiInstance(Class.forName("io.github.fisher2911.hmcleaves.api.HMCLeavesAPI"));
setCustomBlock = new WrappedReturningMethod<>((Class<Object>) apiInstance.getClass(), "setCustomBlock", Location.class, String.class, boolean.class); setCustomBlock = new WrappedReturningMethod<>((Class<Object>) apiInstance.getClass(), "setCustomBlock", Location.class, String.class, boolean.class);
Object config = getLeavesConfig(apiInstance.getClass()); Object config = getLeavesConfig(apiInstance.getClass());
blockDataMap = getMap(config, "blockDataMap"); blockDataMap = getMap(config, "blockDataMap");
itemDataField = getMap(config, "itemSupplierMap"); itemDataField = getMap(config, "itemSupplierMap");
} catch (Throwable e) { } catch (Throwable e) {
Iris.error("Failed to initialize HMCLeavesDataProvider: " + e.getMessage()); Iris.error("Failed to initialize HMCLeavesDataProvider: " + e.getMessage());
} }
} }
@Override @Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException { public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
Object o = blockDataMap.get(blockId.key()); Object o = blockDataMap.get(blockId.key());
if (o == null) if (o == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()); throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
Material material = worldBlockType.invoke(o, new Object[0]); Material material = worldBlockType.invoke(o, new Object[0]);
if (material == null) if (material == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()); throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
BlockData blockData = Bukkit.createBlockData(material); BlockData blockData = Bukkit.createBlockData(material);
if (IrisSettings.get().getGenerator().preventLeafDecay && blockData instanceof Leaves leaves) if (IrisSettings.get().getGenerator().preventLeafDecay && blockData instanceof Leaves leaves)
leaves.setPersistent(true); leaves.setPersistent(true);
return new IrisCustomData(blockData, ExternalDataSVC.buildState(blockId, state)); return new IrisCustomData(blockData, ExternalDataSVC.buildState(blockId, state));
} }
@Override @Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException { public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
if (!itemDataField.containsKey(itemId.key())) if (!itemDataField.containsKey(itemId.key()))
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key()); throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
return itemDataField.get(itemId.key()).get(); return itemDataField.get(itemId.key()).get();
} }
@Override @Override
public void processUpdate(Engine engine, Block block, Identifier blockId) { public void processUpdate(Engine engine, Block block, Identifier blockId) {
var pair = ExternalDataSVC.parseState(blockId); var pair = ExternalDataSVC.parseState(blockId);
blockId = pair.getA(); blockId = pair.getA();
Boolean result = setCustomBlock.invoke(apiInstance, new Object[]{block.getLocation(), blockId.key(), false}); Boolean result = setCustomBlock.invoke(apiInstance, new Object[]{block.getLocation(), blockId.key(), false});
if (result == null || !result) if (result == null || !result)
Iris.warn("Failed to set custom block! " + blockId.key() + " " + block.getX() + " " + block.getY() + " " + block.getZ()); Iris.warn("Failed to set custom block! " + blockId.key() + " " + block.getX() + " " + block.getY() + " " + block.getZ());
else if (IrisSettings.get().getGenerator().preventLeafDecay) { else if (IrisSettings.get().getGenerator().preventLeafDecay) {
BlockData blockData = block.getBlockData(); BlockData blockData = block.getBlockData();
if (blockData instanceof Leaves leaves) if (blockData instanceof Leaves leaves)
leaves.setPersistent(true); leaves.setPersistent(true);
} }
} }
@Override @Override
public Identifier[] getBlockTypes() { public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>(); KList<Identifier> names = new KList<>();
for (String name : blockDataMap.keySet()) { for (String name : blockDataMap.keySet()) {
try { try {
Identifier key = new Identifier("hmcleaves", name); Identifier key = new Identifier("hmcleaves", name);
if (getBlockData(key) != null) if (getBlockData(key) != null)
names.add(key); names.add(key);
} catch (MissingResourceException ignored) { } catch (MissingResourceException ignored) {
} }
} }
return names.toArray(new Identifier[0]); return names.toArray(new Identifier[0]);
} }
@Override @Override
public Identifier[] getItemTypes() { public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>(); KList<Identifier> names = new KList<>();
for (String name : itemDataField.keySet()) { for (String name : itemDataField.keySet()) {
try { try {
Identifier key = new Identifier("hmcleaves", name); Identifier key = new Identifier("hmcleaves", name);
if (getItemStack(key) != null) if (getItemStack(key) != null)
names.add(key); names.add(key);
} catch (MissingResourceException ignored) { } catch (MissingResourceException ignored) {
} }
} }
return names.toArray(new Identifier[0]); return names.toArray(new Identifier[0]);
} }
@Override @Override
public boolean isValidProvider(Identifier id, boolean isItem) { public boolean isValidProvider(Identifier id, boolean isItem) {
return (isItem ? itemDataField.keySet() : blockDataMap.keySet()).contains(id.key()); return (isItem ? itemDataField.keySet() : blockDataMap.keySet()).contains(id.key());
} }
private <C, T> Map<String, T> getMap(C config, String name) { private <C, T> Map<String, T> getMap(C config, String name) {
WrappedField<C, Map<String, T>> field = new WrappedField<>((Class<C>) config.getClass(), name); WrappedField<C, Map<String, T>> field = new WrappedField<>((Class<C>) config.getClass(), name);
return field.get(config); return field.get(config);
} }
private <A> A getApiInstance(Class<A> apiClass) { private <A> A getApiInstance(Class<A> apiClass) {
WrappedReturningMethod<A, A> instance = new WrappedReturningMethod<>(apiClass, "getInstance"); WrappedReturningMethod<A, A> instance = new WrappedReturningMethod<>(apiClass, "getInstance");
return instance.invoke(); return instance.invoke();
} }
private <A, C> C getLeavesConfig(Class<A> apiClass) { private <A, C> C getLeavesConfig(Class<A> apiClass) {
WrappedReturningMethod<A, A> instance = new WrappedReturningMethod<>(apiClass, "getInstance"); WrappedReturningMethod<A, A> instance = new WrappedReturningMethod<>(apiClass, "getInstance");
WrappedField<A, C> config = new WrappedField<>(apiClass, "config"); WrappedField<A, C> config = new WrappedField<>(apiClass, "config");
return config.get(instance.invoke()); return config.get(instance.invoke());
} }
} }

View File

@ -49,9 +49,11 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
int id = -1; int id = -1;
try { try {
id = Integer.parseInt(blockId.key()); id = Integer.parseInt(blockId.key());
} catch (NumberFormatException ignored) {} } catch (NumberFormatException ignored) {
}
CustomBlock block = api().getCustomBlocks().getBlock(id); CustomBlock block = api().getCustomBlocks().getBlock(id);
if (block == null) throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()); if (block == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
return block.getState().getBlockData(); return block.getState().getBlockData();
} }
@ -88,7 +90,8 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
ItemStack item = null; ItemStack item = null;
try { try {
item = future.get(); item = future.get();
} catch (InterruptedException | ExecutionException ignored) {} } catch (InterruptedException | ExecutionException ignored) {
}
if (item == null) if (item == null)
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key()); throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
return item; return item;

View File

@ -143,7 +143,8 @@ public class OraxenDataProvider extends ExternalDataProvider {
BiomeColor type = null; BiomeColor type = null;
try { try {
type = BiomeColor.valueOf(state.get("matchBiome").toUpperCase()); type = BiomeColor.valueOf(state.get("matchBiome").toUpperCase());
} catch (NullPointerException | IllegalArgumentException ignored) {} } catch (NullPointerException | IllegalArgumentException ignored) {
}
if (type != null) { if (type != null) {
var biomeColor = INMS.get().getBiomeColor(block.getLocation(), type); var biomeColor = INMS.get().getBiomeColor(block.getLocation(), type);

View File

@ -21,14 +21,11 @@ package com.volmit.iris.core.link;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.data.KCache;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.time.Duration;
import java.util.UUID;
public class WorldEditLink { public class WorldEditLink {
private static final AtomicCache<Boolean> active = new AtomicCache<>(); private static final AtomicCache<Boolean> active = new AtomicCache<>();
@ -49,7 +46,8 @@ public class WorldEditLink {
Object region = null; Object region = null;
try { try {
region = localSession.getClass().getDeclaredMethod("getSelection", Class.forName("com.sk89q.worldedit.world.World")).invoke(localSession, world); region = localSession.getClass().getDeclaredMethod("getSelection", Class.forName("com.sk89q.worldedit.world.World")).invoke(localSession, world);
} catch (InvocationTargetException ignored) {} } catch (InvocationTargetException ignored) {
}
if (region == null) return null; if (region == null) return null;
Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region); Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region);

View File

@ -27,9 +27,9 @@ import java.util.Map;
public class INMS { public class INMS {
private static final Map<String, String> REVISION = Map.of( private static final Map<String, String> REVISION = Map.of(
"1.20.5", "v1_20_R4", "1.20.5", "v1_20_R4",
"1.20.6", "v1_20_R4", "1.20.6", "v1_20_R4",
"1.21", "v1_21_R1" "1.21", "v1_21_R1"
); );
//@done //@done
private static final INMSBinding binding = bind(); private static final INMSBinding binding = bind();
@ -64,7 +64,7 @@ public class INMS {
Iris.info("Locating NMS Binding for " + code); Iris.info("Locating NMS Binding for " + code);
try { try {
Class<?> clazz = Class.forName("com.volmit.iris.core.nms."+code+".NMSBinding"); Class<?> clazz = Class.forName("com.volmit.iris.core.nms." + code + ".NMSBinding");
try { try {
Object b = clazz.getConstructor().newInstance(); Object b = clazz.getConstructor().newInstance();
if (b instanceof INMSBinding binding) { if (b instanceof INMSBinding binding) {
@ -75,7 +75,9 @@ public class INMS {
Iris.reportError(e); Iris.reportError(e);
e.printStackTrace(); e.printStackTrace();
} }
} catch (ClassNotFoundException|NoClassDefFoundError classNotFoundException) {} } catch (ClassNotFoundException |
NoClassDefFoundError classNotFoundException) {
}
Iris.info("Craftbukkit " + code + " <-> " + NMSBinding1X.class.getSimpleName() + " Successfully Bound"); Iris.info("Craftbukkit " + code + " <-> " + NMSBinding1X.class.getSimpleName() + " Successfully Bound");
Iris.warn("Note: Some features of Iris may not work the same since you are on an unsupported version of Minecraft."); Iris.warn("Note: Some features of Iris may not work the same since you are on an unsupported version of Minecraft.");

View File

@ -22,11 +22,18 @@ import java.util.Collection;
public interface IPackRepository { public interface IPackRepository {
void reload(); void reload();
void reloadWorldData(); void reloadWorldData();
void setSelected(Collection<String> packs); void setSelected(Collection<String> packs);
boolean addPack(String packId); boolean addPack(String packId);
boolean removePack(String packId); boolean removePack(String packId);
Collection<String> getAvailableIds(); Collection<String> getAvailableIds();
Collection<String> getSelectedIds(); Collection<String> getSelectedIds();
boolean isAvailable(String packId); boolean isAvailable(String packId);
} }

View File

@ -44,10 +44,6 @@ public enum DataVersion {
this.version = version; this.version = version;
} }
public IDataFixer get() {
return cache.computeIfAbsent(this, k -> constructor.get());
}
public static IDataFixer getDefault() { public static IDataFixer getDefault() {
return INMS.get().getDataVersion().get(); return INMS.get().getDataVersion().get();
} }
@ -55,4 +51,8 @@ public enum DataVersion {
public static DataVersion getLatest() { public static DataVersion getLatest() {
return values()[values().length - 1]; return values()[values().length - 1];
} }
public IDataFixer get() {
return cache.computeIfAbsent(this, k -> constructor.get());
}
} }

View File

@ -33,7 +33,7 @@ public class DataFixerV1206 implements IDataFixer {
public JSONObject fixCustomBiome(IrisBiomeCustom biome, JSONObject json) { public JSONObject fixCustomBiome(IrisBiomeCustom biome, JSONObject json) {
int spawnRarity = biome.getSpawnRarity(); int spawnRarity = biome.getSpawnRarity();
if (spawnRarity > 0) { if (spawnRarity > 0) {
json.put("creature_spawn_probability", Math.min(spawnRarity/20d, 0.9999999)); json.put("creature_spawn_probability", Math.min(spawnRarity / 20d, 0.9999999));
} }
var spawns = biome.getSpawns(); var spawns = biome.getSpawns();
@ -46,8 +46,8 @@ public class DataFixerV1206 implements IDataFixer {
JSONObject o = new JSONObject(); JSONObject o = new JSONObject();
o.put("type", "minecraft:" + i.getType().name().toLowerCase()); o.put("type", "minecraft:" + i.getType().name().toLowerCase());
o.put("weight", i.getWeight()); o.put("weight", i.getWeight());
o.put("minCount", Math.min(i.getMinCount()/20d, 0)); o.put("minCount", Math.min(i.getMinCount() / 20d, 0));
o.put("maxCount", Math.min(i.getMaxCount()/20d, 0.9999999)); o.put("maxCount", Math.min(i.getMaxCount() / 20d, 0.9999999));
g.put(o); g.put(o);
} }

View File

@ -52,7 +52,6 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
public class NMSBinding1X implements INMSBinding { public class NMSBinding1X implements INMSBinding {
@ -252,7 +251,7 @@ public class NMSBinding1X implements INMSBinding {
@Override @Override
public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) { public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) {
return null; return null;
} }
@Override @Override

View File

@ -22,17 +22,19 @@ import com.volmit.iris.core.nms.container.IPackRepository;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
class PackRepository1X implements IPackRepository { class PackRepository1X implements IPackRepository {
@Override @Override
public void reload() {} public void reload() {
}
@Override @Override
public void reloadWorldData() {} public void reloadWorldData() {
}
@Override @Override
public void setSelected(Collection<String> packs) {} public void setSelected(Collection<String> packs) {
}
@Override @Override
public boolean addPack(String packId) { public boolean addPack(String packId) {

View File

@ -33,7 +33,6 @@ import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -41,9 +40,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
public class ChunkUpdater { public class ChunkUpdater {
private AtomicBoolean paused;
private AtomicBoolean cancelled;
private KMap<Chunk, Long> lastUse;
private final RollingSequence chunksPerSecond; private final RollingSequence chunksPerSecond;
private final AtomicInteger worldheightsize; private final AtomicInteger worldheightsize;
private final AtomicInteger worldwidthsize; private final AtomicInteger worldwidthsize;
@ -51,6 +47,12 @@ public class ChunkUpdater {
private final AtomicInteger totalMaxChunks; private final AtomicInteger totalMaxChunks;
private final AtomicInteger totalMcaregions; private final AtomicInteger totalMcaregions;
private final AtomicInteger position; private final AtomicInteger position;
private final Object pauseLock;
private final Engine engine;
private final World world;
private AtomicBoolean paused;
private AtomicBoolean cancelled;
private KMap<Chunk, Long> lastUse;
private AtomicInteger chunksProcessed; private AtomicInteger chunksProcessed;
private AtomicInteger chunksUpdated; private AtomicInteger chunksUpdated;
private AtomicLong startTime; private AtomicLong startTime;
@ -58,10 +60,7 @@ public class ChunkUpdater {
private ExecutorService chunkExecutor; private ExecutorService chunkExecutor;
private ScheduledExecutorService scheduler; private ScheduledExecutorService scheduler;
private CompletableFuture future; private CompletableFuture future;
private CountDownLatch latch; private CountDownLatch latch;
private final Object pauseLock;
private final Engine engine;
private final World world;
public ChunkUpdater(World world) { public ChunkUpdater(World world) {
this.engine = IrisToolbelt.access(world).getEngine(); this.engine = IrisToolbelt.access(world).getEngine();
@ -235,7 +234,8 @@ public class ChunkUpdater {
}); });
try { try {
latch.await(); latch.await();
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {
}
} }
if (!c.isGenerated()) { if (!c.isGenerated()) {
generated.set(false); generated.set(false);
@ -248,7 +248,8 @@ public class ChunkUpdater {
futures.removeIf(Future::isDone); futures.removeIf(Future::isDone);
try { try {
Thread.sleep(50); Thread.sleep(50);
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {
}
} }
return generated.get(); return generated.get();
} }

View File

@ -55,6 +55,8 @@ import java.util.regex.Pattern;
public class IrisPregenerator { public class IrisPregenerator {
private static AtomicInteger generated;
private static AtomicInteger totalChunks;
private final String saveFile = "regions.json"; private final String saveFile = "regions.json";
private final PregenTask task; private final PregenTask task;
private final PregeneratorMethod generator; private final PregeneratorMethod generator;
@ -66,18 +68,16 @@ public class IrisPregenerator {
private final RollingSequence chunksPerMinute; private final RollingSequence chunksPerMinute;
private final RollingSequence regionsPerMinute; private final RollingSequence regionsPerMinute;
private final KList<Integer> chunksPerSecondHistory; private final KList<Integer> chunksPerSecondHistory;
private static AtomicInteger generated;
private final AtomicInteger generatedLast; private final AtomicInteger generatedLast;
private final AtomicInteger generatedLastMinute; private final AtomicInteger generatedLastMinute;
private static AtomicInteger totalChunks;
private final AtomicLong startTime; private final AtomicLong startTime;
private final ChronoLatch minuteLatch; private final ChronoLatch minuteLatch;
private final AtomicReference<String> currentGeneratorMethod; private final AtomicReference<String> currentGeneratorMethod;
private Set<Position2> generatedRegions;
private final KSet<Position2> retry; private final KSet<Position2> retry;
private final KSet<Position2> net; private final KSet<Position2> net;
private final ChronoLatch cl; private final ChronoLatch cl;
private final ChronoLatch saveLatch = new ChronoLatch(30000); private final ChronoLatch saveLatch = new ChronoLatch(30000);
private Set<Position2> generatedRegions;
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) { public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
generatedRegions = ConcurrentHashMap.newKeySet(); generatedRegions = ConcurrentHashMap.newKeySet();
@ -99,7 +99,7 @@ public class IrisPregenerator {
generatedLast = new AtomicInteger(0); generatedLast = new AtomicInteger(0);
generatedLastMinute = new AtomicInteger(0); generatedLastMinute = new AtomicInteger(0);
totalChunks = new AtomicInteger(0); totalChunks = new AtomicInteger(0);
if(!IrisPackBenchmarking.benchmarkInProgress) { if (!IrisPackBenchmarking.benchmarkInProgress) {
loadCompletedRegions(); loadCompletedRegions();
IrisToolbelt.access(generator.getWorld()).getEngine().saveEngineData(); IrisToolbelt.access(generator.getWorld()).getEngine().saveEngineData();
} }
@ -216,7 +216,7 @@ public class IrisPregenerator {
if (!matcher.find()) continue; if (!matcher.find()) continue;
int x = Integer.parseInt(matcher.group(1)); int x = Integer.parseInt(matcher.group(1));
int z = Integer.parseInt(matcher.group(2)); int z = Integer.parseInt(matcher.group(2));
Position2 pos = new Position2(x,z); Position2 pos = new Position2(x, z);
generatedRegions.add(pos); generatedRegions.add(pos);
MCAFile mca = MCAUtil.read(file, 0); MCAFile mca = MCAUtil.read(file, 0);
@ -252,7 +252,7 @@ public class IrisPregenerator {
Position2 pos = new Position2(x, z); Position2 pos = new Position2(x, z);
if (generatedRegions.contains(pos)) { if (generatedRegions.contains(pos)) {
if(regions) { if (regions) {
listener.onRegionGenerated(x, z); listener.onRegionGenerated(x, z);
generated.addAndGet(1024); generated.addAndGet(1024);
} }
@ -299,7 +299,7 @@ public class IrisPregenerator {
} }
public void saveCompletedRegions() { public void saveCompletedRegions() {
if(IrisPackBenchmarking.benchmarkInProgress) return; if (IrisPackBenchmarking.benchmarkInProgress) return;
Gson gson = new Gson(); Gson gson = new Gson();
try (Writer writer = new FileWriter(generator.getWorld().getWorldFolder().getPath() + "/" + saveFile)) { try (Writer writer = new FileWriter(generator.getWorld().getWorldFolder().getPath() + "/" + saveFile)) {
gson.toJson(new HashSet<>(generatedRegions), writer); gson.toJson(new HashSet<>(generatedRegions), writer);
@ -309,22 +309,23 @@ public class IrisPregenerator {
} }
public void loadCompletedRegions() { public void loadCompletedRegions() {
if(task.isResetCache()) { if (task.isResetCache()) {
File test = new File(generator.getWorld().getWorldFolder().getPath() + "/" + saveFile); File test = new File(generator.getWorld().getWorldFolder().getPath() + "/" + saveFile);
if(!test.delete()) { if (!test.delete()) {
Iris.info(C.RED + "Failed to reset region cache "); Iris.info(C.RED + "Failed to reset region cache ");
} }
} }
Gson gson = new Gson(); Gson gson = new Gson();
try (Reader reader = new FileReader(generator.getWorld().getWorldFolder().getPath() + "/" + saveFile)) { try (Reader reader = new FileReader(generator.getWorld().getWorldFolder().getPath() + "/" + saveFile)) {
Type setType = new TypeToken<HashSet<Position2>>(){}.getType(); Type setType = new TypeToken<HashSet<Position2>>() {
}.getType();
Set<Position2> loadedSet = gson.fromJson(reader, setType); Set<Position2> loadedSet = gson.fromJson(reader, setType);
if (loadedSet != null) { if (loadedSet != null) {
generatedRegions.clear(); generatedRegions.clear();
generatedRegions.addAll(loadedSet); generatedRegions.addAll(loadedSet);
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// all fine // all fine
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -42,32 +42,31 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.HashMap;
import java.util.Map;
public class LazyPregenerator extends Thread implements Listener { public class LazyPregenerator extends Thread implements Listener {
private static final Map<String, LazyPregenJob> jobs = new HashMap<>();
@Getter @Getter
private static LazyPregenerator instance; private static LazyPregenerator instance;
private static AtomicInteger lazyGeneratedChunks;
private final LazyPregenJob job; private final LazyPregenJob job;
private final File destination; private final File destination;
private final int maxPosition; private final int maxPosition;
private World world;
private final long rate; private final long rate;
private final ChronoLatch latch; private final ChronoLatch latch;
private static AtomicInteger lazyGeneratedChunks;
private final AtomicInteger generatedLast; private final AtomicInteger generatedLast;
private final AtomicInteger lazyTotalChunks; private final AtomicInteger lazyTotalChunks;
private final AtomicLong startTime; private final AtomicLong startTime;
private final RollingSequence chunksPerSecond; private final RollingSequence chunksPerSecond;
private final RollingSequence chunksPerMinute; private final RollingSequence chunksPerMinute;
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
private static final Map<String, LazyPregenJob> jobs = new HashMap<>(); private World world;
public LazyPregenerator(LazyPregenJob job, File destination) { public LazyPregenerator(LazyPregenJob job, File destination) {
this.job = job; this.job = job;
@ -106,6 +105,26 @@ public class LazyPregenerator extends Thread implements Listener {
} }
} }
public static void setPausedLazy(World world) {
LazyPregenJob job = jobs.get(world.getName());
if (isPausedLazy(world)) {
job.paused = false;
} else {
job.paused = true;
}
if (job.paused) {
Iris.info(C.BLUE + "LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedLazy(World world) {
LazyPregenJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
@EventHandler @EventHandler
public void on(WorldUnloadEvent e) { public void on(WorldUnloadEvent e) {
if (e.getWorld().equals(world)) { if (e.getWorld().equals(world)) {
@ -164,8 +183,6 @@ public class LazyPregenerator extends Thread implements Listener {
// todo broken // todo broken
} }
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
private void tickGenerate(Position2 chunk) { private void tickGenerate(Position2 chunk) {
executorService.submit(() -> { executorService.submit(() -> {
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
@ -184,7 +201,8 @@ public class LazyPregenerator extends Thread implements Listener {
} }
try { try {
latch.await(); latch.await();
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {
}
lazyGeneratedChunks.addAndGet(1); lazyGeneratedChunks.addAndGet(1);
}); });
} }
@ -220,26 +238,6 @@ public class LazyPregenerator extends Thread implements Listener {
}); });
} }
public static void setPausedLazy(World world) {
LazyPregenJob job = jobs.get(world.getName());
if (isPausedLazy(world)){
job.paused = false;
} else {
job.paused = true;
}
if ( job.paused) {
Iris.info(C.BLUE + "LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedLazy(World world) {
LazyPregenJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
public void shutdownInstance(World world) throws IOException { public void shutdownInstance(World world) throws IOException {
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Shutting down.."); Iris.info("LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Shutting down..");
LazyPregenJob job = jobs.get(world.getName()); LazyPregenJob job = jobs.get(world.getName());
@ -260,7 +258,7 @@ public class LazyPregenerator extends Thread implements Listener {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
while (lazyFile.exists()){ while (lazyFile.exists()) {
lazyFile.delete(); lazyFile.delete();
J.sleep(1000); J.sleep(1000);
} }
@ -284,6 +282,10 @@ public class LazyPregenerator extends Thread implements Listener {
@Data @Data
@Builder @Builder
public static class LazyPregenJob { public static class LazyPregenJob {
@Builder.Default
boolean silent = false;
@Builder.Default
boolean paused = false;
private String world; private String world;
@Builder.Default @Builder.Default
private int healingPosition = 0; private int healingPosition = 0;
@ -295,10 +297,6 @@ public class LazyPregenerator extends Thread implements Listener {
private int radiusBlocks = 5000; private int radiusBlocks = 5000;
@Builder.Default @Builder.Default
private int position = 0; private int position = 0;
@Builder.Default
boolean silent = false;
@Builder.Default
boolean paused = false;
} }
} }

View File

@ -18,7 +18,6 @@
package com.volmit.iris.core.pregenerator; package com.volmit.iris.core.pregenerator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import org.bukkit.World; import org.bukkit.World;

View File

@ -20,7 +20,6 @@ package com.volmit.iris.core.pregenerator;
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.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
@ -39,20 +38,21 @@ import io.papermc.lib.PaperLib;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import org.apache.logging.log4j.core.util.ExecutorServices;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.checkerframework.checker.units.qual.N;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array; import java.util.HashMap;
import java.util.*; import java.util.Map;
import java.util.concurrent.*; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -60,14 +60,14 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.IntStream; import java.util.stream.IntStream;
public class TurboPregenerator extends Thread implements Listener { public class TurboPregenerator extends Thread implements Listener {
private static final Map<String, TurboPregenJob> jobs = new HashMap<>();
@Getter @Getter
private static TurboPregenerator instance; private static TurboPregenerator instance;
private static AtomicInteger turboGeneratedChunks;
private final TurboPregenJob job; private final TurboPregenJob job;
private final File destination; private final File destination;
private final int maxPosition; private final int maxPosition;
private World world;
private final ChronoLatch latch; private final ChronoLatch latch;
private static AtomicInteger turboGeneratedChunks;
private final AtomicInteger generatedLast; private final AtomicInteger generatedLast;
private final AtomicLong cachedLast; private final AtomicLong cachedLast;
private final RollingSequence cachePerSecond; private final RollingSequence cachePerSecond;
@ -75,14 +75,15 @@ public class TurboPregenerator extends Thread implements Listener {
private final AtomicLong startTime; private final AtomicLong startTime;
private final RollingSequence chunksPerSecond; private final RollingSequence chunksPerSecond;
private final RollingSequence chunksPerMinute; private final RollingSequence chunksPerMinute;
private final HyperLock hyperLock;
private final ExecutorService executorService = Executors.newFixedThreadPool(10);
private World world;
private KList<Position2> queue; private KList<Position2> queue;
private ConcurrentHashMap<Integer, Position2> cache; private ConcurrentHashMap<Integer, Position2> cache;
private AtomicInteger maxWaiting; private AtomicInteger maxWaiting;
private ReentrantLock cachinglock; private ReentrantLock cachinglock;
private AtomicBoolean caching; private AtomicBoolean caching;
private final HyperLock hyperLock;
private MultiBurst burst; private MultiBurst burst;
private static final Map<String, TurboPregenJob> jobs = new HashMap<>();
public TurboPregenerator(TurboPregenJob job, File destination) { public TurboPregenerator(TurboPregenJob job, File destination) {
this.job = job; this.job = job;
@ -129,6 +130,26 @@ public class TurboPregenerator extends Thread implements Listener {
} }
public static void setPausedTurbo(World world) {
TurboPregenJob job = jobs.get(world.getName());
if (isPausedTurbo(world)) {
job.paused = false;
} else {
job.paused = true;
}
if (job.paused) {
Iris.info(C.BLUE + "TurboGen: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "TurboGen: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedTurbo(World world) {
TurboPregenJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
@EventHandler @EventHandler
public void on(WorldUnloadEvent e) { public void on(WorldUnloadEvent e) {
if (e.getWorld().equals(world)) { if (e.getWorld().equals(world)) {
@ -242,7 +263,6 @@ public class TurboPregenerator extends Thread implements Listener {
// todo broken // todo broken
} }
private final ExecutorService executorService = Executors.newFixedThreadPool(10);
private void tickGenerate(Position2 chunk) { private void tickGenerate(Position2 chunk) {
executorService.submit(() -> { executorService.submit(() -> {
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
@ -284,26 +304,6 @@ public class TurboPregenerator extends Thread implements Listener {
}); });
} }
public static void setPausedTurbo(World world) {
TurboPregenJob job = jobs.get(world.getName());
if (isPausedTurbo(world)) {
job.paused = false;
} else {
job.paused = true;
}
if (job.paused) {
Iris.info(C.BLUE + "TurboGen: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "TurboGen: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedTurbo(World world) {
TurboPregenJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
public void shutdownInstance(World world) throws IOException { public void shutdownInstance(World world) throws IOException {
Iris.info("turboGen: " + C.IRIS + world.getName() + C.BLUE + " Shutting down.."); Iris.info("turboGen: " + C.IRIS + world.getName() + C.BLUE + " Shutting down..");
TurboPregenJob job = jobs.get(world.getName()); TurboPregenJob job = jobs.get(world.getName());
@ -348,13 +348,13 @@ public class TurboPregenerator extends Thread implements Listener {
@Data @Data
@Builder @Builder
public static class TurboPregenJob { public static class TurboPregenJob {
@Builder.Default
boolean paused = false;
private String world; private String world;
@Builder.Default @Builder.Default
private int radiusBlocks = 5000; private int radiusBlocks = 5000;
@Builder.Default @Builder.Default
private int position = 0; private int position = 0;
@Builder.Default
boolean paused = false;
} }
} }

View File

@ -19,8 +19,6 @@
package com.volmit.iris.core.pregenerator.methods; package com.volmit.iris.core.pregenerator.methods;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.IHeadless;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.pregenerator.PregenListener; import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.pregenerator.PregeneratorMethod; import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
@ -32,13 +30,12 @@ import com.volmit.iris.util.math.M;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import java.util.*; import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap; import java.util.Map;
import java.util.concurrent.ForkJoinPool; import java.util.Objects;
import java.util.concurrent.Future; import java.util.concurrent.Future;
public class AsyncPregenMethod implements PregeneratorMethod { public class AsyncPregenMethod implements PregeneratorMethod {

View File

@ -48,13 +48,15 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
} }
@Override @Override
public void init() {} public void init() {
}
@Override @Override
public void close() { public void close() {
try { try {
semaphore.acquire(max); semaphore.acquire(max);
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {
}
try { try {
headless.close(); headless.close();
} catch (IOException e) { } catch (IOException e) {
@ -64,7 +66,8 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
} }
@Override @Override
public void save() {} public void save() {
}
@Override @Override
public boolean supportsRegions(int x, int z, PregenListener listener) { public boolean supportsRegions(int x, int z, PregenListener listener) {
@ -77,7 +80,8 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
} }
@Override @Override
public void generateRegion(int x, int z, PregenListener listener) {} public void generateRegion(int x, int z, PregenListener listener) {
}
@Override @Override
public void generateChunk(int x, int z, PregenListener listener) { public void generateChunk(int x, int z, PregenListener listener) {

View File

@ -28,7 +28,6 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;

View File

@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitScheduler;
public class ModesSFG { public class ModesSFG {
public static void selectMode() { public static void selectMode() {

View File

@ -24,6 +24,7 @@ import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import javax.tools.JavaCompiler; import javax.tools.JavaCompiler;
import javax.tools.ToolProvider; import javax.tools.ToolProvider;
import java.io.File; import java.io.File;
@ -38,8 +39,6 @@ import java.util.Map;
import java.util.StringJoiner; import java.util.StringJoiner;
import static com.volmit.iris.Iris.getJavaVersion; import static com.volmit.iris.Iris.getJavaVersion;
import static com.volmit.iris.Iris.instance;
import static com.volmit.iris.core.safeguard.IrisSafeguard.*;
public class ServerBootSFG { public class ServerBootSFG {
public static final Map<String, Boolean> incompatibilities = new HashMap<>(); public static final Map<String, Boolean> incompatibilities = new HashMap<>();
@ -48,13 +47,13 @@ public class ServerBootSFG {
public static boolean isJRE = false; public static boolean isJRE = false;
public static boolean hasPrivileges = true; public static boolean hasPrivileges = true;
public static boolean unsuportedversion = false; public static boolean unsuportedversion = false;
protected static boolean safeguardPassed;
public static boolean passedserversoftware = true; public static boolean passedserversoftware = true;
public static String allIncompatibilities;
protected static boolean safeguardPassed;
protected static int count; protected static int count;
protected static byte severityLow; protected static byte severityLow;
protected static byte severityMedium; protected static byte severityMedium;
protected static byte severityHigh; protected static byte severityHigh;
public static String allIncompatibilities;
public static void BootCheck() { public static void BootCheck() {
Iris.info("Checking for possible conflicts.."); Iris.info("Checking for possible conflicts..");
@ -123,7 +122,7 @@ public class ServerBootSFG {
// severityMedium++; // severityMedium++;
// } Some servers dont like this // } Some servers dont like this
if (!enoughDiskSpace()){ if (!enoughDiskSpace()) {
hasEnoughDiskSpace = false; hasEnoughDiskSpace = false;
joiner.add("Insufficient Disk Space"); joiner.add("Insufficient Disk Space");
severityMedium++; severityMedium++;
@ -155,9 +154,11 @@ public class ServerBootSFG {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
// If the compiler is null, it means this is a JRE environment, not a JDK. // If the compiler is null, it means this is a JRE environment, not a JDK.
return compiler != null; return compiler != null;
} catch (Exception ignored) {} } catch (Exception ignored) {
}
return false; return false;
} }
public static boolean hasPrivileges() { public static boolean hasPrivileges() {
Path pv = Paths.get(Bukkit.getWorldContainer() + "iristest.json"); Path pv = Paths.get(Bukkit.getWorldContainer() + "iristest.json");
try (FileChannel fc = FileChannel.open(pv, StandardOpenOption.CREATE, StandardOpenOption.DELETE_ON_CLOSE, StandardOpenOption.READ, StandardOpenOption.WRITE)) { try (FileChannel fc = FileChannel.open(pv, StandardOpenOption.CREATE, StandardOpenOption.DELETE_ON_CLOSE, StandardOpenOption.READ, StandardOpenOption.WRITE)) {
@ -173,7 +174,7 @@ public class ServerBootSFG {
public static boolean enoughDiskSpace() { public static boolean enoughDiskSpace() {
File freeSpace = new File(Bukkit.getWorldContainer() + "."); File freeSpace = new File(Bukkit.getWorldContainer() + ".");
double gigabytes = freeSpace.getFreeSpace() / (1024.0 * 1024.0 * 1024.0); double gigabytes = freeSpace.getFreeSpace() / (1024.0 * 1024.0 * 1024.0);
if (gigabytes > 3){ if (gigabytes > 3) {
return true; return true;
} else { } else {
return false; return false;

View File

@ -37,7 +37,7 @@ public class onCommandWarning implements Listener {
VolmitSender sender = new VolmitSender(player); VolmitSender sender = new VolmitSender(player);
boolean perm = sender.hasPermission("iris.all") || sender.isOp(); boolean perm = sender.hasPermission("iris.all") || sender.isOp();
if (perm) { if (perm) {
sender.sendMessage(C.DARK_GRAY + "[" + C.RED + "!" + C.DARK_GRAY+ "]" + C.DARK_RED + "Iris is running unstably! Please resolve this."); sender.sendMessage(C.DARK_GRAY + "[" + C.RED + "!" + C.DARK_GRAY + "]" + C.DARK_RED + "Iris is running unstably! Please resolve this.");
} }
} }
} }

View File

@ -125,12 +125,12 @@ public class BoardSVC implements IrisService, BoardProvider {
int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight(); int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight();
int z = player.getLocation().getBlockZ(); int z = player.getLocation().getBlockZ();
if(IrisSettings.get().getGeneral().debug){ if (IrisSettings.get().getGeneral().debug) {
lines.add("&7&m "); lines.add("&7&m ");
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0)); lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize())); lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount()); lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount());
lines.add(C.LIGHT_PURPLE + "Carving" + C.GRAY + ": " + engine.getMantle().isCarved(x,y,z)); lines.add(C.LIGHT_PURPLE + "Carving" + C.GRAY + ": " + engine.getMantle().isCarved(x, y, z));
lines.add("&7&m "); lines.add("&7&m ");
lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName()); lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName());

View File

@ -32,8 +32,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.event.world.WorldUnloadEvent;
public class EditSVC implements IrisService { public class EditSVC implements IrisService {
private KMap<World, BlockEditor> editors;
public static boolean deletingWorld = false; public static boolean deletingWorld = false;
private KMap<World, BlockEditor> editors;
@Override @Override
public void onEnable() { public void onEnable() {

View File

@ -33,7 +33,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.*; import java.util.Arrays;
import java.util.MissingResourceException;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Data @Data
@ -41,6 +43,29 @@ public class ExternalDataSVC implements IrisService {
private KList<ExternalDataProvider> providers = new KList<>(), activeProviders = new KList<>(); private KList<ExternalDataProvider> providers = new KList<>(), activeProviders = new KList<>();
public static Pair<Identifier, KMap<String, String>> parseState(Identifier key) {
if (!key.key().contains("[") || !key.key().contains("]")) {
return new Pair<>(key, new KMap<>());
}
String state = key.key().split("\\Q[\\E")[1].split("\\Q]\\E")[0];
KMap<String, String> stateMap = new KMap<>();
if (!state.isEmpty()) {
Arrays.stream(state.split(",")).forEach(s -> stateMap.put(s.split("=")[0], s.split("=")[1]));
}
return new Pair<>(new Identifier(key.namespace(), key.key().split("\\Q[\\E")[0]), stateMap);
}
public static Identifier buildState(Identifier key, KMap<String, String> state) {
if (state.isEmpty()) {
return key;
}
String path = state.entrySet()
.stream()
.map(e -> e.getKey() + "=" + e.getValue())
.collect(Collectors.joining(",", key.key() + "[", "]"));
return new Identifier(key.namespace(), path);
}
@Override @Override
public void onEnable() { public void onEnable() {
Iris.info("Loading ExternalDataProvider..."); Iris.info("Loading ExternalDataProvider...");
@ -144,27 +169,4 @@ public class ExternalDataSVC implements IrisService {
activeProviders.forEach(p -> names.add(p.getItemTypes())); activeProviders.forEach(p -> names.add(p.getItemTypes()));
return names.toArray(new Identifier[0]); return names.toArray(new Identifier[0]);
} }
public static Pair<Identifier, KMap<String, String>> parseState(Identifier key) {
if (!key.key().contains("[") || !key.key().contains("]")) {
return new Pair<>(key, new KMap<>());
}
String state = key.key().split("\\Q[\\E")[1].split("\\Q]\\E")[0];
KMap<String, String> stateMap = new KMap<>();
if (!state.isEmpty()) {
Arrays.stream(state.split(",")).forEach(s -> stateMap.put(s.split("=")[0], s.split("=")[1]));
}
return new Pair<>(new Identifier(key.namespace(), key.key().split("\\Q[\\E")[0]), stateMap);
}
public static Identifier buildState(Identifier key, KMap<String, String> state) {
if (state.isEmpty()) {
return key;
}
String path = state.entrySet()
.stream()
.map(e -> e.getKey() + "=" + e.getValue())
.collect(Collectors.joining(",", key.key() + "[", "]"));
return new Identifier(key.namespace(), path);
}
} }

View File

@ -240,7 +240,7 @@ public class TreeSVC implements IrisService {
boolean isUseAll = worldAccess.getEngine().getDimension().getTreeSettings().getMode().equals(IrisTreeModes.ALL); boolean isUseAll = worldAccess.getEngine().getDimension().getTreeSettings().getMode().equals(IrisTreeModes.ALL);
// Retrieve objectPlacements of type `species` from biome // Retrieve objectPlacements of type `species` from biome
IrisBiome biome = worldAccess.getEngine().getBiome(location.getBlockX(), location.getBlockY()-worldAccess.getTarget().getWorld().minHeight(), location.getBlockZ()); IrisBiome biome = worldAccess.getEngine().getBiome(location.getBlockX(), location.getBlockY() - worldAccess.getTarget().getWorld().minHeight(), location.getBlockZ());
placements.addAll(matchObjectPlacements(biome.getObjects(), size, type)); placements.addAll(matchObjectPlacements(biome.getObjects(), size, type));
// Add more or find any in the region // Add more or find any in the region

View File

@ -34,7 +34,6 @@ import com.volmit.iris.util.misc.E;
import com.volmit.iris.util.plugin.IrisService; import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.S;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -56,7 +55,7 @@ import java.util.Objects;
public class WandSVC implements IrisService { public class WandSVC implements IrisService {
private static final Particle CRIT_MAGIC = E.getOrDefault(Particle.class, "CRIT_MAGIC", "CRIT"); private static final Particle CRIT_MAGIC = E.getOrDefault(Particle.class, "CRIT_MAGIC", "CRIT");
private static final Particle REDSTONE = E.getOrDefault(Particle.class, "REDSTONE", "DUST"); private static final Particle REDSTONE = E.getOrDefault(Particle.class, "REDSTONE", "DUST");
private static ItemStack dust; private static ItemStack dust;
private static ItemStack wand; private static ItemStack wand;
@ -197,7 +196,8 @@ public class WandSVC implements IrisService {
meta.setLore(new ArrayList<>()); //Reset the lore on this too so we can compare them meta.setLore(new ArrayList<>()); //Reset the lore on this too so we can compare them
stack.setItemMeta(meta); //We dont need to clone the item as items from .get are cloned stack.setItemMeta(meta); //We dont need to clone the item as items from .get are cloned
if (wand.isSimilar(stack)) return s; //If the name, material and NBT is the same if (wand.isSimilar(stack))
return s; //If the name, material and NBT is the same
} }
return -1; return -1;
} }

View File

@ -21,9 +21,7 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import oshi.SystemInfo; import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory; import oshi.hardware.GlobalMemory;
import oshi.hardware.HWDiskStore;
import oshi.software.os.OperatingSystem; import oshi.software.os.OperatingSystem;
import java.io.*; import java.io.*;
@ -35,18 +33,17 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.zip.Deflater; import java.util.zip.Deflater;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static com.google.common.math.LongMath.isPrime; import static com.google.common.math.LongMath.isPrime;
import static com.volmit.iris.util.misc.getHardware.getCPUModel; import static com.volmit.iris.util.misc.getHardware.getCPUModel;
public class IrisBenchmarking { public class IrisBenchmarking {
public static boolean inProgress = false;
static String ServerOS; static String ServerOS;
static String filePath = "benchmark.dat"; static String filePath = "benchmark.dat";
static double avgWriteSpeedMBps; static double avgWriteSpeedMBps;
@ -72,7 +69,6 @@ public class IrisBenchmarking {
static double elapsedTimeNs; static double elapsedTimeNs;
static boolean Winsat = false; static boolean Winsat = false;
static boolean WindowsDiskSpeed = false; static boolean WindowsDiskSpeed = false;
public static boolean inProgress = false;
static double startTime; static double startTime;
// Good enough for now. . . // Good enough for now. . .
@ -202,7 +198,7 @@ public class IrisBenchmarking {
Iris.info("- Sequential 64.0 Write: " + C.BLUE + formatDouble(avgWriteSpeedMBps) + " Mbps"); Iris.info("- Sequential 64.0 Write: " + C.BLUE + formatDouble(avgWriteSpeedMBps) + " Mbps");
Iris.info("- Sequential 64.0 Read: " + C.BLUE + formatDouble(avgReadSpeedMBps) + " Mbps"); Iris.info("- Sequential 64.0 Read: " + C.BLUE + formatDouble(avgReadSpeedMBps) + " Mbps");
} else { } else {
// Iris.info("Disk Model: " + getDiskModel()); // Iris.info("Disk Model: " + getDiskModel());
Iris.info(C.GREEN + "- Running in Native Mode"); Iris.info(C.GREEN + "- Running in Native Mode");
Iris.info("- Average Write Speed: " + C.GREEN + formatDouble(avgWriteSpeedMBps) + " Mbps"); Iris.info("- Average Write Speed: " + C.GREEN + formatDouble(avgWriteSpeedMBps) + " Mbps");
Iris.info("- Average Read Speed: " + C.GREEN + formatDouble(avgReadSpeedMBps) + " Mbps"); Iris.info("- Average Read Speed: " + C.GREEN + formatDouble(avgReadSpeedMBps) + " Mbps");

View File

@ -19,19 +19,16 @@
package com.volmit.iris.core.tools; package com.volmit.iris.core.tools;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.nbt.io.NBTUtil; import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.io.NamedTag; import com.volmit.iris.util.nbt.io.NamedTag;
import com.volmit.iris.util.nbt.tag.*; import com.volmit.iris.util.nbt.tag.*;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.reflect.V;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -53,8 +50,8 @@ public class IrisConverter {
File[] fileList = folder.listFiles(filter); File[] fileList = folder.listFiles(filter);
ExecutorService executorService = Executors.newFixedThreadPool(1); ExecutorService executorService = Executors.newFixedThreadPool(1);
executorService.submit(() -> { executorService.submit(() -> {
for (File schem : fileList) { for (File schem : fileList) {
try { try {
PrecisionStopwatch p = new PrecisionStopwatch(); PrecisionStopwatch p = new PrecisionStopwatch();
boolean largeObject = false; boolean largeObject = false;
NamedTag tag = null; NamedTag tag = null;
@ -66,241 +63,240 @@ public class IrisConverter {
} }
CompoundTag compound = (CompoundTag) tag.getTag(); CompoundTag compound = (CompoundTag) tag.getTag();
if (compound.containsKey("Palette") && compound.containsKey("Width") && compound.containsKey("Height") && compound.containsKey("Length")) { if (compound.containsKey("Palette") && compound.containsKey("Width") && compound.containsKey("Height") && compound.containsKey("Length")) {
int objW = ((ShortTag) compound.get("Width")).getValue(); int objW = ((ShortTag) compound.get("Width")).getValue();
int objH = ((ShortTag) compound.get("Height")).getValue(); int objH = ((ShortTag) compound.get("Height")).getValue();
int objD = ((ShortTag) compound.get("Length")).getValue(); int objD = ((ShortTag) compound.get("Length")).getValue();
int mv = objW * objH * objD; int mv = objW * objH * objD;
AtomicInteger v = new AtomicInteger(0); AtomicInteger v = new AtomicInteger(0);
AtomicInteger fv = new AtomicInteger(0); AtomicInteger fv = new AtomicInteger(0);
if (mv > 500_000) { if (mv > 500_000) {
largeObject = true; largeObject = true;
Iris.info(C.GRAY + "Converting.. "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob")); Iris.info(C.GRAY + "Converting.. " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
Iris.info(C.GRAY + "- It may take a while"); Iris.info(C.GRAY + "- It may take a while");
if (sender.isPlayer()) { if (sender.isPlayer()) {
J.a(() -> { J.a(() -> {
// while (v.get() != mv) { // while (v.get() != mv) {
// double pr = ((double) v.get() / (double ) mv); // double pr = ((double) v.get() / (double ) mv);
// sender.sendProgress(pr, "Converting"); // sender.sendProgress(pr, "Converting");
// J.sleep(16); // J.sleep(16);
// } // }
}); });
}
}
CompoundTag paletteTag = (CompoundTag) compound.get("Palette");
Map<Integer, BlockData> blockmap = new HashMap<>(paletteTag.size(), 0.9f);
for (Map.Entry<String, Tag<?>> entry : paletteTag.getValue().entrySet()) {
String blockName = entry.getKey();
BlockData bd = Bukkit.createBlockData(blockName);
Tag<?> blockTag = entry.getValue();
int blockId = ((IntTag) blockTag).getValue();
blockmap.put(blockId, bd);
}
ByteArrayTag byteArray = (ByteArrayTag) compound.get("BlockData");
byte[] originalBlockArray = byteArray.getValue();
int b = 0;
int a = 0;
Map<Integer, Byte> y = new HashMap<>();
Map<Integer, Byte> x = new HashMap<>();
Map<Integer, Byte> z = new HashMap<>();
// Height adjustments
for (int h = 0; h < objH; h++) {
if (b == 0) {
y.put(h, (byte) 0);
}
if (b > 0) {
y.put(h, (byte) 1);
}
a = 0;
b = 0;
for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
} }
} }
}
fv.set(0);
// Width adjustments CompoundTag paletteTag = (CompoundTag) compound.get("Palette");
for (int w = 0; w < objW; w++) { Map<Integer, BlockData> blockmap = new HashMap<>(paletteTag.size(), 0.9f);
if (b == 0) { for (Map.Entry<String, Tag<?>> entry : paletteTag.getValue().entrySet()) {
x.put(w, (byte) 0); String blockName = entry.getKey();
BlockData bd = Bukkit.createBlockData(blockName);
Tag<?> blockTag = entry.getValue();
int blockId = ((IntTag) blockTag).getValue();
blockmap.put(blockId, bd);
} }
if (b > 0) {
x.put(w, (byte) 1); ByteArrayTag byteArray = (ByteArrayTag) compound.get("BlockData");
byte[] originalBlockArray = byteArray.getValue();
int b = 0;
int a = 0;
Map<Integer, Byte> y = new HashMap<>();
Map<Integer, Byte> x = new HashMap<>();
Map<Integer, Byte> z = new HashMap<>();
// Height adjustments
for (int h = 0; h < objH; h++) {
if (b == 0) {
y.put(h, (byte) 0);
}
if (b > 0) {
y.put(h, (byte) 1);
}
a = 0;
b = 0;
for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if (db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
} }
a = 0; fv.set(0);
b = 0;
// Width adjustments
for (int w = 0; w < objW; w++) {
if (b == 0) {
x.put(w, (byte) 0);
}
if (b > 0) {
x.put(w, (byte) 1);
}
a = 0;
b = 0;
for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if (db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
// Depth adjustments
for (int d = 0; d < objD; d++) {
if (b == 0) {
z.put(d, (byte) 0);
}
if (b > 0) {
z.put(d, (byte) 1);
}
a = 0;
b = 0;
for (int h = 0; h < objH; h++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if (db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
int CorrectObjH = getCorrectY(y, objH);
int CorrectObjW = getCorrectX(x, objW);
int CorrectObjD = getCorrectZ(z, objD);
//IrisObject object = new IrisObject(CorrectObjW, CorrectObjH, CorrectObjH);
IrisObject object = new IrisObject(objW, objH, objD);
Vector originalVector = new Vector(objW, objH, objD);
int[] yc = null;
int[] xc = null;
int[] zc = null;
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : y.keySet()) {
if (y.get(i) == 0) {
o++;
}
if (y.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
yc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : x.keySet()) {
if (x.get(i) == 0) {
o++;
}
if (x.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
xc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : z.keySet()) {
if (z.get(i) == 0) {
o++;
}
if (z.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
zc = new int[]{fo, so};
int h1, h2, w1, w2, v1 = 0, volume = objW * objH * objD;
Map<Integer, Integer> blockLocationMap = new LinkedHashMap<>();
boolean hasAir = false;
int pos = 0;
for (int i : originalBlockArray) {
blockLocationMap.put(pos, i);
pos++;
}
for (int h = 0; h < objH; h++) { for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) { for (int d = 0; d < objD; d++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]); for (int w = 0; w < objW; w++) {
if(db.getAsString().contains("minecraft:air")) { BlockData bd = blockmap.get((int) originalBlockArray[v.get()]);
a++; if (!bd.getMaterial().isAir()) {
} else { object.setUnsigned(w, h, d, bd);
b++; }
v.getAndAdd(1);
} }
fv.getAndAdd(1);
} }
} }
}
fv.set(0);
// Depth adjustments
for (int d = 0; d < objD; d++) { try {
if (b == 0) { object.write(new File(folder, schem.getName().replace(".schem", ".iob")));
z.put(d, (byte) 0); } catch (IOException e) {
Iris.info(C.RED + "Failed to save: " + schem.getName());
throw new RuntimeException(e);
} }
if (b > 0) { if (sender.isPlayer()) {
z.put(d, (byte) 1); if (largeObject) {
} sender.sendMessage(C.IRIS + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis()));
a = 0; } else {
b = 0; sender.sendMessage(C.IRIS + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
for (int h = 0; h < objH; h++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
} }
} }
}
fv.set(0);
int CorrectObjH = getCorrectY(y, objH);
int CorrectObjW = getCorrectX(x, objW);
int CorrectObjD = getCorrectZ(z, objD);
//IrisObject object = new IrisObject(CorrectObjW, CorrectObjH, CorrectObjH);
IrisObject object = new IrisObject(objW, objH, objD);
Vector originalVector = new Vector(objW,objH,objD);
int[] yc = null;
int[] xc = null;
int[] zc = null;
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : y.keySet()) {
if (y.get(i) == 0) {
o++;
}
if (y.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
yc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : x.keySet()) {
if (x.get(i) == 0) {
o++;
}
if (x.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
xc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : z.keySet()) {
if (z.get(i) == 0) {
o++;
}
if (z.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
zc = new int[]{fo, so};
int h1, h2, w1, w2, v1 = 0, volume = objW * objH * objD;
Map<Integer, Integer> blockLocationMap = new LinkedHashMap<>();
boolean hasAir = false;
int pos = 0;
for (int i : originalBlockArray) {
blockLocationMap.put(pos, i);
pos++;
}
for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) {
BlockData bd = blockmap.get((int) originalBlockArray[v.get()]);
if (!bd.getMaterial().isAir()) {
object.setUnsigned(w, h, d, bd);
}
v.getAndAdd(1);
}
}
}
try {
object.write(new File(folder, schem.getName().replace(".schem", ".iob")));
} catch (IOException e) {
Iris.info(C.RED + "Failed to save: " + schem.getName());
throw new RuntimeException(e);
}
if (sender.isPlayer()) {
if (largeObject) { if (largeObject) {
sender.sendMessage(C.IRIS + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis())); Iris.info(C.GRAY + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis()));
} else { } else {
sender.sendMessage(C.IRIS + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob")); Iris.info(C.GRAY + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
} }
// schem.delete();
} }
if (largeObject) { } catch (Exception e) {
Iris.info(C.GRAY + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis())); Iris.info(C.RED + "Failed to convert: " + schem.getName());
} else { if (sender.isPlayer()) {
Iris.info(C.GRAY + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob")); sender.sendMessage(C.RED + "Failed to convert: " + schem.getName());
} }
// schem.delete(); e.printStackTrace();
Iris.reportError(e);
} }
} catch (Exception e) {
Iris.info(C.RED + "Failed to convert: " + schem.getName());
if (sender.isPlayer()) {
sender.sendMessage(C.RED + "Failed to convert: " + schem.getName());
}
e.printStackTrace();
Iris.reportError(e);
} }
}
}); });
} }
@ -356,7 +352,7 @@ public class IrisConverter {
} }
if (y.get(i) == 1) { if (y.get(i) == 1) {
c++; c++;
if(c == 1){ if (c == 1) {
fo = o; fo = o;
} }
o = 0; o = 0;
@ -377,7 +373,7 @@ public class IrisConverter {
} }
if (x.get(i) == 1) { if (x.get(i) == 1) {
c++; c++;
if(c == 1){ if (c == 1) {
fo = o; fo = o;
} }
o = 0; o = 0;
@ -398,7 +394,7 @@ public class IrisConverter {
} }
if (z.get(i) == 1) { if (z.get(i) == 1) {
c++; c++;
if(c == 1){ if (c == 1) {
fo = o; fo = o;
} }
o = 0; o = 0;

View File

@ -21,7 +21,6 @@ package com.volmit.iris.core.tools;
import com.google.common.util.concurrent.AtomicDouble; import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
@ -98,7 +97,8 @@ public class IrisCreator {
yml.save(BUKKIT_YML); yml.save(BUKKIT_YML);
return true; return true;
} }
public static boolean worldLoaded(){
public static boolean worldLoaded() {
return true; return true;
} }
@ -154,7 +154,7 @@ public class IrisCreator {
} }
return finalAccess1.getEngine().getGenerated(); return finalAccess1.getEngine().getGenerated();
}; };
if(!benchmark) { if (!benchmark) {
if (finalAccess1 == null) return; if (finalAccess1 == null) return;
int req = finalAccess1.getSpawnChunks().join(); int req = finalAccess1.getSpawnChunks().join();

View File

@ -24,9 +24,6 @@ import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.NoiseProvider; import com.volmit.iris.util.function.NoiseProvider;

View File

@ -36,7 +36,6 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.exceptions.IrisException; import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter; import lombok.Getter;
@ -58,14 +57,14 @@ import java.util.Collections;
public class IrisPackBenchmarking { public class IrisPackBenchmarking {
@Getter @Getter
public static IrisPackBenchmarking instance; public static IrisPackBenchmarking instance;
public static boolean benchmarkInProgress = false; public static boolean benchmarkInProgress = false;
private IrisDimension IrisDimension; private final boolean headless;
private int radius; private final boolean gui;
private final boolean headless;
private final boolean gui;
private boolean finished = false;
private Engine engine;
PrecisionStopwatch stopwatch; PrecisionStopwatch stopwatch;
private IrisDimension IrisDimension;
private int radius;
private boolean finished = false;
private Engine engine;
public IrisPackBenchmarking(IrisDimension dimension, int r, boolean headless, boolean gui) { public IrisPackBenchmarking(IrisDimension dimension, int r, boolean headless, boolean gui) {
instance = this; instance = this;
@ -114,14 +113,14 @@ public class IrisPackBenchmarking {
File profilers = new File("plugins" + File.separator + "Iris" + File.separator + "packbenchmarks"); File profilers = new File("plugins" + File.separator + "Iris" + File.separator + "packbenchmarks");
profilers.mkdir(); profilers.mkdir();
File results = new File(profilers, IrisDimension.getName() + " " + LocalDateTime.now(Clock.systemDefaultZone()).toString().replace(':', '-') + ".txt"); File results = new File(profilers, IrisDimension.getName() + " " + LocalDateTime.now(Clock.systemDefaultZone()).toString().replace(':', '-') + ".txt");
results.getParentFile().mkdirs(); results.getParentFile().mkdirs();
KMap<String, Double> metrics = engine.getMetrics().pull(); KMap<String, Double> metrics = engine.getMetrics().pull();
try (FileWriter writer = new FileWriter(results)) { try (FileWriter writer = new FileWriter(results)) {
writer.write("-----------------\n"); writer.write("-----------------\n");
writer.write("Results:\n"); writer.write("Results:\n");
writer.write("Dimension: " + IrisDimension.getName() + "\n"); writer.write("Dimension: " + IrisDimension.getName() + "\n");
writer.write("- Date of Benchmark: " + LocalDateTime.now(Clock.systemDefaultZone()) + "\n"); writer.write("- Date of Benchmark: " + LocalDateTime.now(Clock.systemDefaultZone()) + "\n");
writer.write("\n"); writer.write("\n");
writer.write("Metrics"); writer.write("Metrics");
for (String m : metrics.k()) { for (String m : metrics.k()) {
@ -129,7 +128,7 @@ public class IrisPackBenchmarking {
writer.write("- " + m + ": " + i); writer.write("- " + m + ": " + i);
} }
writer.write("- " + metrics); writer.write("- " + metrics);
writer.write("Benchmark: " + LocalDateTime.now(Clock.systemDefaultZone()) + "\n"); writer.write("Benchmark: " + LocalDateTime.now(Clock.systemDefaultZone()) + "\n");
writer.write("- Total time: " + time + "\n"); writer.write("- Total time: " + time + "\n");
writer.write("- Average CPS: " + calculateAverage(cps) + "\n"); writer.write("- Average CPS: " + calculateAverage(cps) + "\n");
writer.write(" - Median CPS: " + calculateMedian(cps) + "\n"); writer.write(" - Median CPS: " + calculateMedian(cps) + "\n");
@ -151,7 +150,8 @@ public class IrisPackBenchmarking {
e.printStackTrace(); e.printStackTrace();
} }
} }
private Engine createBenchmark(){
private Engine createBenchmark() {
try { try {
if (headless) { if (headless) {
Iris.info("Using headless benchmark!"); Iris.info("Using headless benchmark!");
@ -184,17 +184,17 @@ public class IrisPackBenchmarking {
} }
} }
private void startBenchmark(){ private void startBenchmark() {
int x = 0; int x = 0;
int z = 0; int z = 0;
IrisToolbelt.pregenerate(PregenTask IrisToolbelt.pregenerate(PregenTask
.builder() .builder()
.gui(gui) .gui(gui)
.center(new Position2(x, z)) .center(new Position2(x, z))
.width(radius) .width(radius)
.height(radius) .height(radius)
.build(), headless ? new HeadlessPregenMethod(engine) : new HybridPregenMethod(engine.getWorld().realWorld(), .build(), headless ? new HeadlessPregenMethod(engine) : new HybridPregenMethod(engine.getWorld().realWorld(),
IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())), engine); IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())), engine);
} }
private double calculateAverage(KList<Integer> list) { private double calculateAverage(KList<Integer> list) {

View File

@ -20,7 +20,8 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator; import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;

View File

@ -21,7 +21,6 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
@ -72,7 +71,7 @@ public class IrisWorldDump {
this.world = world; this.world = world;
this.sender = sender; this.sender = sender;
this.MCADirectory = new File(world.getWorldFolder(), "region"); this.MCADirectory = new File(world.getWorldFolder(), "region");
this.dumps = new File("plugins" + File.separator + "iris", "dumps"); this.dumps = new File("plugins" + File.separator + "iris", "dumps");
this.worldDump = new File(dumps, world.getName()); this.worldDump = new File(dumps, world.getName());
this.mcaCacheSize = IrisSettings.get().getWorldDump().mcaCacheSize; this.mcaCacheSize = IrisSettings.get().getWorldDump().mcaCacheSize;
this.regionsProcessed = new AtomicInteger(0); this.regionsProcessed = new AtomicInteger(0);
@ -134,38 +133,23 @@ public class IrisWorldDump {
} }
public class blockData {
@Getter
@Setter
private String block;
private int biome;
private int height;
public blockData(String b, int bm, int h) {
this.block = b;
this.height = h;
this.biome = bm;
}
}
private void dump() { private void dump() {
Iris.info("Starting the dump process."); Iris.info("Starting the dump process.");
int threads = Runtime.getRuntime().availableProcessors(); int threads = Runtime.getRuntime().availableProcessors();
AtomicInteger f = new AtomicInteger(); AtomicInteger f = new AtomicInteger();
for (File mcaFile : MCADirectory.listFiles()) { for (File mcaFile : MCADirectory.listFiles()) {
if (mcaFile.getName().endsWith(".mca")) { if (mcaFile.getName().endsWith(".mca")) {
executor.submit(() -> { executor.submit(() -> {
try { try {
processMCARegion( MCAUtil.read(mcaFile)); processMCARegion(MCAUtil.read(mcaFile));
} catch (Exception e) { } catch (Exception e) {
f.getAndIncrement(); f.getAndIncrement();
Iris.error("Failed to read mca file"); Iris.error("Failed to read mca file");
e.printStackTrace(); e.printStackTrace();
} }
}); });
}
} }
}
} }
private void processMCARegion(MCAFile mca) { private void processMCARegion(MCAFile mca) {
@ -256,4 +240,18 @@ public class IrisWorldDump {
); );
} }
public class blockData {
@Getter
@Setter
private String block;
private int biome;
private int height;
public blockData(String b, int bm, int h) {
this.block = b;
this.height = h;
this.biome = bm;
}
}
} }

View File

@ -30,7 +30,7 @@ import org.bukkit.util.Vector;
import java.awt.*; import java.awt.*;
public class WandSelection { public class WandSelection {
private static final Particle REDSTONE = E.getOrDefault(Particle.class, "REDSTONE", "DUST"); private static final Particle REDSTONE = E.getOrDefault(Particle.class, "REDSTONE", "DUST");
private final Cuboid c; private final Cuboid c;
private final Player p; private final Player p;

View File

@ -288,7 +288,6 @@ public class IrisComplex implements DataProvider {
return biome; return biome;
} }
private record DPair(double x, double z) {}
private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, KSet<IrisGenerator> generators, double x, double z, long seed) { private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, KSet<IrisGenerator> generators, double x, double z, long seed) {
if (generators.isEmpty()) { if (generators.isEmpty()) {
return 0; return 0;
@ -389,4 +388,7 @@ public class IrisComplex implements DataProvider {
public void close() { public void close() {
} }
private record DPair(double x, double z) {
}
} }

View File

@ -47,7 +47,6 @@ import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterStructurePOI; import com.volmit.iris.util.matter.MatterStructurePOI;
import com.volmit.iris.util.misc.E;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
@ -55,7 +54,6 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -66,7 +64,10 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -97,6 +98,7 @@ public class IrisEngine implements Engine {
private final AtomicBoolean cleaning; private final AtomicBoolean cleaning;
private final ChronoLatch cleanLatch; private final ChronoLatch cleanLatch;
private final SeedManager seedManager; private final SeedManager seedManager;
private final ReentrantLock dataLock;
private EngineMode mode; private EngineMode mode;
private EngineExecutionEnvironment execution; private EngineExecutionEnvironment execution;
private EngineWorldManager worldManager; private EngineWorldManager worldManager;
@ -109,7 +111,6 @@ public class IrisEngine implements Engine {
private double maxBiomeLayerDensity; private double maxBiomeLayerDensity;
private double maxBiomeDecoratorDensity; private double maxBiomeDecoratorDensity;
private IrisComplex complex; private IrisComplex complex;
private final ReentrantLock dataLock;
public IrisEngine(EngineTarget target, boolean studio) { public IrisEngine(EngineTarget target, boolean studio) {
this.studio = studio; this.studio = studio;
@ -145,6 +146,26 @@ public class IrisEngine implements Engine {
Iris.debug("Engine Initialized " + getCacheID()); Iris.debug("Engine Initialized " + getCacheID());
} }
@SuppressWarnings("unchecked")
private static Map<Class<? extends IrisEngineService>, Constructor<? extends IrisEngineService>> scanServices() {
JarScanner js = new JarScanner(Iris.instance.getJarFile(), "com.volmit.iris.engine.service");
J.attempt(js::scan);
KMap<Class<? extends IrisEngineService>, Constructor<? extends IrisEngineService>> map = new KMap<>();
js.getClasses()
.stream()
.filter(IrisEngineService.class::isAssignableFrom)
.map(c -> (Class<? extends IrisEngineService>) c)
.forEach(c -> {
try {
map.put(c, c.getConstructor(Engine.class));
} catch (NoSuchMethodException e) {
Iris.warn("Failed to load service " + c.getName() + " due to missing constructor");
}
});
return Collections.unmodifiableMap(map);
}
private void verifySeed() { private void verifySeed() {
if (getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) { if (getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) {
target.getWorld().setRawWorldSeed(getEngineData().getSeed()); target.getWorld().setRawWorldSeed(getEngineData().getSeed());
@ -182,7 +203,8 @@ public class IrisEngine implements Engine {
SERVICES.forEach((s, c) -> { SERVICES.forEach((s, c) -> {
try { try {
services.put(s, c.newInstance(this)); services.put(s, c.newInstance(this));
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { } catch (InstantiationException | IllegalAccessException |
InvocationTargetException e) {
Iris.error("Failed to create service " + s.getName()); Iris.error("Failed to create service " + s.getName());
e.printStackTrace(); e.printStackTrace();
} }
@ -286,7 +308,7 @@ public class IrisEngine implements Engine {
data.getStatistics().setIrisCreationVersion(Iris.instance.getIrisVersion()); data.getStatistics().setIrisCreationVersion(Iris.instance.getIrisVersion());
data.getStatistics().setMCVersion(Iris.instance.getMCVersion()); data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
data.getStatistics().setIrisToUpgradedVersion(Iris.instance.getIrisVersion()); data.getStatistics().setIrisToUpgradedVersion(Iris.instance.getIrisVersion());
if (data.getStatistics().getIrisCreationVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) { if (data.getStatistics().getIrisCreationVersion() == -1 || data.getStatistics().getMCVersion() == -1) {
Iris.error("Failed to setup Engine Data!"); Iris.error("Failed to setup Engine Data!");
} }
IO.writeAll(f, new Gson().toJson(data)); IO.writeAll(f, new Gson().toJson(data));
@ -532,7 +554,7 @@ public class IrisEngine implements Engine {
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true); getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
getMetrics().getTotal().put(p.getMilliseconds()); getMetrics().getTotal().put(p.getMilliseconds());
addGenerated(x,z); addGenerated(x, z);
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
fail("Failed to generate " + x + ", " + z, e); fail("Failed to generate " + x + ", " + z, e);
@ -599,24 +621,4 @@ public class IrisEngine implements Engine {
} }
return true; return true;
} }
@SuppressWarnings("unchecked")
private static Map<Class<? extends IrisEngineService>, Constructor<? extends IrisEngineService>> scanServices() {
JarScanner js = new JarScanner(Iris.instance.getJarFile(), "com.volmit.iris.engine.service");
J.attempt(js::scan);
KMap<Class<? extends IrisEngineService>, Constructor<? extends IrisEngineService>> map = new KMap<>();
js.getClasses()
.stream()
.filter(IrisEngineService.class::isAssignableFrom)
.map(c -> (Class<? extends IrisEngineService>) c)
.forEach(c -> {
try {
map.put(c, c.getConstructor(Engine.class));
} catch (NoSuchMethodException e) {
Iris.warn("Failed to load service " + c.getName() + " due to missing constructor");
}
});
return Collections.unmodifiableMap(map);
}
} }

View File

@ -31,7 +31,6 @@ import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.BurstExecutor;

View File

@ -552,7 +552,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
public void execute(Future<Chunk> chunkFuture) { public void execute(Future<Chunk> chunkFuture) {
try { try {
chunkFuture.get(); chunkFuture.get();
} catch (InterruptedException | ExecutionException ignored) { } catch (InterruptedException |
ExecutionException ignored) {
} }
} }

View File

@ -382,7 +382,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
try { try {
Bukkit.getPluginManager().callEvent(new IrisLootEvent(this, block, slot, tables)); Bukkit.getPluginManager().callEvent(new IrisLootEvent(this, block, slot, tables));
if (!tables.isEmpty()){ if (!tables.isEmpty()) {
Iris.debug("IrisLootEvent has been accessed"); Iris.debug("IrisLootEvent has been accessed");
} }
@ -958,5 +958,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
J.a(() -> getMantle().cleanupChunk(x, z)); J.a(() -> getMantle().cleanupChunk(x, z));
} }
} }
<T extends IrisEngineService> T getService(Class<T> clazz); <T extends IrisEngineService> T getService(Class<T> clazz);
} }

View File

@ -40,11 +40,13 @@ public class IrisLootEvent extends Event {
this.slot = slot; this.slot = slot;
this.tables = tables; this.tables = tables;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -141,7 +141,8 @@ public interface Locator<T> {
(at.getZ() << 4) + 8, false), (at.getZ() << 4) + 8, false),
(at.getZ() << 4) + 8)); (at.getZ() << 4) + 8));
} }
} catch (WrongEngineBroException | InterruptedException | ExecutionException e) { } catch (WrongEngineBroException | InterruptedException |
ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
} }
}) { }) {

View File

@ -60,7 +60,7 @@ public class HeightmapObjectPlacer implements IObjectPlacer {
@Override @Override
public boolean isCarved(int x, int y, int z) { public boolean isCarved(int x, int y, int z) {
return oplacer.isCarved(x,y,z); return oplacer.isCarved(x, y, z);
} }
public boolean isSolid(int param1Int1, int param1Int2, int param1Int3) { public boolean isSolid(int param1Int1, int param1Int2, int param1Int3) {

View File

@ -52,7 +52,8 @@ public class WorldObjectPlacer implements IObjectPlacer {
public WorldObjectPlacer(World world) { public WorldObjectPlacer(World world) {
var a = IrisToolbelt.access(world); var a = IrisToolbelt.access(world);
if (a == null || a.getEngine() == null) throw new IllegalStateException(world.getName() + " is not an Iris World!"); if (a == null || a.getEngine() == null)
throw new IllegalStateException(world.getName() + " is not an Iris World!");
this.world = world; this.world = world;
this.engine = a.getEngine(); this.engine = a.getEngine();
this.mantle = engine.getMantle(); this.mantle = engine.getMantle();
@ -72,7 +73,8 @@ public class WorldObjectPlacer implements IObjectPlacer {
public void set(int x, int y, int z, BlockData d) { public void set(int x, int y, int z, BlockData d) {
Block block = world.getBlockAt(x, y + world.getMinHeight(), z); Block block = world.getBlockAt(x, y + world.getMinHeight(), z);
if (y <= world.getMinHeight() || block.getType() == Material.BEDROCK) return; if (y <= world.getMinHeight() || block.getType() == Material.BEDROCK)
return;
InventorySlotType slot = null; InventorySlotType slot = null;
if (B.isStorageChest(d)) { if (B.isStorageChest(d)) {
slot = InventorySlotType.STORAGE; slot = InventorySlotType.STORAGE;
@ -85,7 +87,7 @@ public class WorldObjectPlacer implements IObjectPlacer {
try { try {
Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, slot, tables)); Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, slot, tables));
if (!tables.isEmpty()){ if (!tables.isEmpty()) {
Iris.debug("IrisLootEvent has been accessed"); Iris.debug("IrisLootEvent has been accessed");
} }

View File

@ -195,7 +195,10 @@ public class PlannedPiece {
} }
} }
public record ParentConnection(PlannedPiece parent, IrisJigsawPieceConnector parentConnector, PlannedPiece self, IrisJigsawPieceConnector connector) { public record ParentConnection(PlannedPiece parent,
IrisJigsawPieceConnector parentConnector,
PlannedPiece self,
IrisJigsawPieceConnector connector) {
public IrisPosition getTargetPosition() { public IrisPosition getTargetPosition() {
var pos = parent.realPositions.get(parentConnector); var pos = parent.realPositions.get(parentConnector);
if (pos == null) return null; if (pos == null) return null;

View File

@ -25,7 +25,6 @@ import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.placer.WorldObjectPlacer; import com.volmit.iris.engine.framework.placer.WorldObjectPlacer;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisCustomData;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@ -78,7 +77,7 @@ public class PlannedStructure {
public boolean place(IObjectPlacer placer, Mantle e, Engine eng) { public boolean place(IObjectPlacer placer, Mantle e, Engine eng) {
IrisObjectPlacement options = new IrisObjectPlacement(); IrisObjectPlacement options = new IrisObjectPlacement();
options.setRotation(IrisObjectRotation.of(0,0,0)); options.setRotation(IrisObjectRotation.of(0, 0, 0));
int startHeight = pieces.get(0).getPosition().getY(); int startHeight = pieces.get(0).getPosition().getY();
boolean placed = false; boolean placed = false;

View File

@ -22,6 +22,7 @@ import com.volmit.iris.util.plugin.VolmitSender;
public class VMJavaFX { public class VMJavaFX {
private VolmitSender sender; private VolmitSender sender;
public VMJavaFX(VolmitSender user) { public VMJavaFX(VolmitSender user) {
this.sender = user; this.sender = user;
@ -46,5 +47,4 @@ public class VMJavaFX {
} }
} }

View File

@ -23,7 +23,6 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineTarget; import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.framework.SeedManager;
import com.volmit.iris.engine.mantle.components.MantleJigsawComponent; import com.volmit.iris.engine.mantle.components.MantleJigsawComponent;
import com.volmit.iris.engine.mantle.components.MantleObjectComponent; import com.volmit.iris.engine.mantle.components.MantleObjectComponent;
import com.volmit.iris.engine.object.IObjectPlacer; import com.volmit.iris.engine.object.IObjectPlacer;
@ -179,7 +178,8 @@ public interface EngineMantle extends IObjectPlacer {
default void trim(int limit) { default void trim(int limit) {
getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAlive()), limit); getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAlive()), limit);
} }
default int unloadTectonicPlate(int tectonicLimit){
default int unloadTectonicPlate(int tectonicLimit) {
return getMantle().unloadTectonicPlate(tectonicLimit); return getMantle().unloadTectonicPlate(tectonicLimit);
} }
@ -195,32 +195,32 @@ public interface EngineMantle extends IObjectPlacer {
@ChunkCoordinates @ChunkCoordinates
default void generateMatter(int x, int z, boolean multicore, ChunkContext context) { default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
//synchronized (this) { //synchronized (this) {
if (!getEngine().getDimension().isUseMantle()) { if (!getEngine().getDimension().isUseMantle()) {
return; return;
} }
int s = getRealRadius(); int s = getRealRadius();
BurstExecutor burst = burst().burst(multicore); BurstExecutor burst = burst().burst(multicore);
MantleWriter writer = getMantle().write(this, x, z, s * 2); MantleWriter writer = getMantle().write(this, x, z, s * 2);
for (int i = -s; i <= s; i++) { for (int i = -s; i <= s; i++) {
for (int j = -s; j <= s; j++) { for (int j = -s; j <= s; j++) {
int xx = i + x; int xx = i + x;
int zz = j + z; int zz = j + z;
burst.queue(() -> { burst.queue(() -> {
IrisContext.touch(getEngine().getContext()); IrisContext.touch(getEngine().getContext());
getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> { getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> {
MantleChunk mc = getMantle().getChunk(xx, zz); MantleChunk mc = getMantle().getChunk(xx, zz);
for (MantleComponent k : getComponents()) { for (MantleComponent k : getComponents()) {
generateMantleComponent(writer, xx, zz, k, mc, context); generateMantleComponent(writer, xx, zz, k, mc, context);
} }
});
}); });
} });
} }
}
burst.complete(); burst.complete();
// } // }
} }
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc, ChunkContext context) { default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc, ChunkContext context) {
@ -261,7 +261,8 @@ public interface EngineMantle extends IObjectPlacer {
default int getLoadedRegionCount() { default int getLoadedRegionCount() {
return getMantle().getLoadedRegionCount(); return getMantle().getLoadedRegionCount();
} }
default long getLastUseMapMemoryUsage(){
default long getLastUseMapMemoryUsage() {
return getMantle().LastUseMapMemoryUsage(); return getMantle().LastUseMapMemoryUsage();
} }
@ -296,13 +297,15 @@ public interface EngineMantle extends IObjectPlacer {
} }
} }
default long getToUnload(){ default long getToUnload() {
return getMantle().getToUnload().size(); return getMantle().getToUnload().size();
} }
default long getNotQueuedLoadedRegions(){
default long getNotQueuedLoadedRegions() {
return getMantle().getLoadedRegions().size() - getMantle().getToUnload().size(); return getMantle().getLoadedRegions().size() - getMantle().getToUnload().size();
} }
default double getTectonicDuration(){
default double getTectonicDuration() {
return getMantle().getAdjustedIdleDuration().get(); return getMantle().getAdjustedIdleDuration().get();
} }
} }

View File

@ -85,7 +85,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
@ChunkCoordinates @ChunkCoordinates
private boolean placeStructures(MantleWriter writer, long seed, int x, int z, KList<IrisJigsawStructurePlacement> structures, private boolean placeStructures(MantleWriter writer, long seed, int x, int z, KList<IrisJigsawStructurePlacement> structures,
KSet<Position2> cachedRegions, KMap<String, KSet<Position2>> cache, KMap<Position2, Double> distanceCache) { KSet<Position2> cachedRegions, KMap<String, KSet<Position2>> cache, KMap<Position2, Double> distanceCache) {
IrisJigsawStructurePlacement i = pick(structures, seed, x, z); IrisJigsawStructurePlacement i = pick(structures, seed, x, z);
if (i == null || checkMinDistances(i.collectMinDistances(), x, z, cachedRegions, cache, distanceCache)) if (i == null || checkMinDistances(i.collectMinDistances(), x, z, cachedRegions, cache, distanceCache))
return false; return false;
@ -119,7 +119,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
double minDist = minDistances.get(structure); double minDist = minDistances.get(structure);
minDist = minDist * minDist; minDist = minDist * minDist;
for (Position2 sPos : cache.get(structure)) { for (Position2 sPos : cache.get(structure)) {
double dist = distanceCache.computeIfAbsent(sPos, position2 -> position2.distance(pos)); double dist = distanceCache.computeIfAbsent(sPos, position2 -> position2.distance(pos));
if (minDist > dist) return true; if (minDist > dist) return true;
} }
} }
@ -148,7 +148,8 @@ public class MantleJigsawComponent extends IrisMantleComponent {
IrisJigsawStructurePlacement i = pick(biome.getJigsawStructures(), seed, x, z); IrisJigsawStructurePlacement i = pick(biome.getJigsawStructures(), seed, x, z);
if (i == null) i = pick(region.getJigsawStructures(), seed, x, z); if (i == null) i = pick(region.getJigsawStructures(), seed, x, z);
if (i == null) i = pick(getDimension().getJigsawStructures(), seed, x, z); if (i == null)
i = pick(getDimension().getJigsawStructures(), seed, x, z);
return i != null ? getData().getJigsawStructureLoader().load(i.getStructure()) : null; return i != null ? getData().getJigsawStructureLoader().load(i.getStructure()) : null;
} }

View File

@ -23,7 +23,10 @@ import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.mantle.IrisMantleComponent; import com.volmit.iris.engine.mantle.IrisMantleComponent;
import com.volmit.iris.engine.mantle.MantleWriter; import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.context.ChunkContext; import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;

View File

@ -170,6 +170,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@Desc("Collection of ores to be generated") @Desc("Collection of ores to be generated")
@ArrayType(type = IrisOreGenerator.class, min = 1) @ArrayType(type = IrisOreGenerator.class, min = 1)
private KList<IrisOreGenerator> ores = new KList<>(); private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) { public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) { if (ores.isEmpty()) {
return null; return null;

View File

@ -39,14 +39,14 @@ public class IrisBiomeGeneratorLink {
@RegistryListResource(IrisGenerator.class) @RegistryListResource(IrisGenerator.class)
@Desc("The generator id") @Desc("The generator id")
private String generator = "default"; private String generator = "default";
@DependsOn({ "min", "max" }) @DependsOn({"min", "max"})
@Required @Required
@MinNumber(-2032) // TODO: WARNING HEIGHT @MinNumber(-2032) // TODO: WARNING HEIGHT
@MaxNumber(2032) // TODO: WARNING HEIGHT @MaxNumber(2032) // TODO: WARNING HEIGHT
@Desc("The min block value (value + fluidHeight)") @Desc("The min block value (value + fluidHeight)")
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
private int min = 0; private int min = 0;
@DependsOn({ "min", "max" }) @DependsOn({"min", "max"})
@Required @Required
@MinNumber(-2032) // TODO: WARNING HEIGHT @MinNumber(-2032) // TODO: WARNING HEIGHT
@MaxNumber(2032) // TODO: WARNING HEIGHT @MaxNumber(2032) // TODO: WARNING HEIGHT
@ -80,7 +80,7 @@ public class IrisBiomeGeneratorLink {
} }
} }
return new int[] { min, max }; return new int[]{min, max};
} }
private int calculateHeight(Engine engine, int option) { private int calculateHeight(Engine engine, int option) {

View File

@ -82,7 +82,7 @@ public class IrisCavePlacer implements IRare {
} }
if (y == -1) { if (y == -1) {
if(!breakSurface) { if (!breakSurface) {
int eH = engine.getHeight(x, z); int eH = engine.getHeight(x, z);
if (caveStartHeight.getMax() > eH) { if (caveStartHeight.getMax() > eH) {
caveStartHeight.setMax(eH); caveStartHeight.setMax(eH);
@ -92,7 +92,7 @@ public class IrisCavePlacer implements IRare {
} }
try { try {
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint); cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
fail.set(true); fail.set(true);

View File

@ -70,9 +70,11 @@ public enum IrisDirection {
return switch (f) { return switch (f) {
case DOWN -> DOWN_NEGATIVE_Y; case DOWN -> DOWN_NEGATIVE_Y;
case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X; case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X;
case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z; case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST,
NORTH_WEST -> NORTH_NEGATIVE_Z;
case SELF, UP -> UP_POSITIVE_Y; case SELF, UP -> UP_POSITIVE_Y;
case SOUTH, SOUTH_EAST, SOUTH_SOUTH_EAST, SOUTH_SOUTH_WEST, SOUTH_WEST -> SOUTH_POSITIVE_Z; case SOUTH, SOUTH_EAST, SOUTH_SOUTH_EAST, SOUTH_SOUTH_WEST,
SOUTH_WEST -> SOUTH_POSITIVE_Z;
case WEST, WEST_NORTH_WEST, WEST_SOUTH_WEST -> WEST_NEGATIVE_X; case WEST, WEST_NORTH_WEST, WEST_SOUTH_WEST -> WEST_NEGATIVE_X;
}; };

View File

@ -23,7 +23,6 @@ import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import lombok.Data; import lombok.Data;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;

View File

@ -20,8 +20,6 @@ package com.volmit.iris.engine.object;
import lombok.Data; import lombok.Data;
import java.util.HashSet;
@Data @Data
public class IrisEngineStatistics { public class IrisEngineStatistics {
private int unsafeShutdown = 0; private int unsafeShutdown = 0;

View File

@ -468,7 +468,6 @@ public class IrisEntity extends IrisRegistrant {
} }
return INMS.get().spawnEntity(at, getType(), getReason()); return INMS.get().spawnEntity(at, getType(), getReason());
} }

View File

@ -28,7 +28,6 @@ import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.math.Vector3d; import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.matter.MatterMarker; import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.matter.slices.MarkerMatter; import com.volmit.iris.util.matter.slices.MarkerMatter;
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -38,9 +37,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.BoundingBox;
@Snippet("entity-spawn") @Snippet("entity-spawn")
@Accessors(chain = true) @Accessors(chain = true)

View File

@ -18,11 +18,7 @@
package com.volmit.iris.engine.object; package com.volmit.iris.engine.object;
import com.volmit.iris.engine.object.annotations.Desc; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;

View File

@ -19,13 +19,7 @@
package com.volmit.iris.engine.object; package com.volmit.iris.engine.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.annotations.ArrayType; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;

View File

@ -727,7 +727,7 @@ public class IrisObject extends IrisRegistrant {
Engine engine = rdata.getEngine(); Engine engine = rdata.getEngine();
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
for (int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) { for (int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) {
for (int j = y - Math.floorDiv(h, 2) + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) { for (int j = y - Math.floorDiv(h, 2) + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) {
for (int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) { for (int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) {
PlacedObject p = engine.getObjectPlacement(i, j, k); PlacedObject p = engine.getObjectPlacement(i, j, k);
if (p == null) continue; if (p == null) continue;

View File

@ -105,7 +105,8 @@ public class IrisObjectRotation {
var translate = piece.getPlacementOptions().getTranslate(); var translate = piece.getPlacementOptions().getTranslate();
var pos = rotate(new IrisPosition(translate.getX(), translate.getY(), translate.getZ())); var pos = rotate(new IrisPosition(translate.getX(), translate.getY(), translate.getZ()));
translate.setX(pos.getX()).setY(pos.getY()).setZ(pos.getZ()); translate.setX(pos.getX()).setY(pos.getY()).setZ(pos.getZ());
} catch (NullPointerException ignored) {} } catch (NullPointerException ignored) {
}
return piece; return piece;
} }

View File

@ -112,8 +112,17 @@ public class TileBanner implements TileData<Banner> {
public boolean isBanner(Material material) { public boolean isBanner(Material material) {
return switch (material) { return switch (material) {
case RED_BANNER, RED_WALL_BANNER, ORANGE_BANNER, ORANGE_WALL_BANNER, YELLOW_BANNER, YELLOW_WALL_BANNER, LIME_BANNER, LIME_WALL_BANNER, GREEN_BANNER, GREEN_WALL_BANNER, CYAN_BANNER, CYAN_WALL_BANNER, LIGHT_BLUE_BANNER, LIGHT_BLUE_WALL_BANNER, BLUE_BANNER, BLUE_WALL_BANNER, PURPLE_BANNER, PURPLE_WALL_BANNER, MAGENTA_BANNER, MAGENTA_WALL_BANNER, PINK_BANNER, PINK_WALL_BANNER, WHITE_BANNER, WHITE_WALL_BANNER, LIGHT_GRAY_BANNER, LIGHT_GRAY_WALL_BANNER, GRAY_BANNER, GRAY_WALL_BANNER, BLACK_BANNER, BLACK_WALL_BANNER, BROWN_BANNER, BROWN_WALL_BANNER -> case RED_BANNER, RED_WALL_BANNER, ORANGE_BANNER, ORANGE_WALL_BANNER,
true; YELLOW_BANNER, YELLOW_WALL_BANNER, LIME_BANNER,
LIME_WALL_BANNER, GREEN_BANNER, GREEN_WALL_BANNER, CYAN_BANNER,
CYAN_WALL_BANNER, LIGHT_BLUE_BANNER, LIGHT_BLUE_WALL_BANNER,
BLUE_BANNER, BLUE_WALL_BANNER, PURPLE_BANNER,
PURPLE_WALL_BANNER, MAGENTA_BANNER, MAGENTA_WALL_BANNER,
PINK_BANNER, PINK_WALL_BANNER, WHITE_BANNER, WHITE_WALL_BANNER,
LIGHT_GRAY_BANNER, LIGHT_GRAY_WALL_BANNER, GRAY_BANNER,
GRAY_WALL_BANNER,
BLACK_BANNER, BLACK_WALL_BANNER, BROWN_BANNER,
BROWN_WALL_BANNER -> true;
default -> false; default -> false;
}; };
} }

View File

@ -52,7 +52,8 @@ public interface TileData<T extends TileState> extends Cloneable {
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance(); @SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
d.fromBinary(s); d.fromBinary(s);
return d; return d;
} catch (InvocationTargetException | InstantiationException | IllegalAccessException | } catch (InvocationTargetException | InstantiationException |
IllegalAccessException |
NoSuchMethodException e) { NoSuchMethodException e) {
throw new IOException("Failed to create TileData instance due to missing type registrar!"); throw new IOException("Failed to create TileData instance due to missing type registrar!");
} }

View File

@ -21,7 +21,6 @@ package com.volmit.iris.engine.platform;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.safeguard.IrisSafeguard;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.IrisEngine; import com.volmit.iris.engine.IrisEngine;
import com.volmit.iris.engine.data.chunk.TerrainChunk; import com.volmit.iris.engine.data.chunk.TerrainChunk;
@ -33,7 +32,6 @@ import com.volmit.iris.engine.object.StudioMode;
import com.volmit.iris.engine.platform.studio.StudioGenerator; import com.volmit.iris.engine.platform.studio.StudioGenerator;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisBiomeStorage; import com.volmit.iris.util.data.IrisBiomeStorage;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder; import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder; import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
@ -140,14 +138,14 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
J.s(() -> { J.s(() -> {
Engine engine1 = getEngine(event.getWorld()); Engine engine1 = getEngine(event.getWorld());
if (engine1 != null) { if (engine1 != null) {
try { try {
INMS.get().inject(event.getWorld().getSeed(), engine1, event.getWorld()); INMS.get().inject(event.getWorld().getSeed(), engine1, event.getWorld());
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName()); Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
initialized = true; initialized = true;
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}, 10); }, 10);
} else { } else {
INMS.get().inject(event.getWorld().getSeed(), engine, event.getWorld()); INMS.get().inject(event.getWorld().getSeed(), engine, event.getWorld());

View File

@ -19,7 +19,6 @@
package com.volmit.iris.engine.platform; package com.volmit.iris.engine.platform;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.util.collection.KList;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.WorldInfo; import org.bukkit.generator.WorldInfo;

View File

@ -31,6 +31,36 @@ public class EngineStatusSVC extends IrisEngineService {
super(engine); super(engine);
} }
public static int getEngineCount() {
return Math.max(INSTANCES.size(), 1);
}
public static Status getStatus() {
synchronized (INSTANCES) {
long loadedChunks = 0;
long tectonicPlates = 0;
long activeTectonicPlates = 0;
long queuedTectonicPlates = 0;
long minTectonicUnloadDuration = Long.MAX_VALUE;
long maxTectonicUnloadDuration = Long.MIN_VALUE;
for (var service : INSTANCES) {
var world = service.engine.getWorld();
if (world.hasRealWorld())
loadedChunks += world.realWorld().getLoadedChunks().length;
if (world.hasHeadless())
loadedChunks += world.headless().getLoadedChunks();
tectonicPlates += service.engine.getMantle().getLoadedRegionCount();
activeTectonicPlates += service.engine.getMantle().getNotQueuedLoadedRegions();
queuedTectonicPlates += service.engine.getMantle().getToUnload();
minTectonicUnloadDuration = Math.min(minTectonicUnloadDuration, (long) service.engine.getMantle().getTectonicDuration());
maxTectonicUnloadDuration = Math.max(maxTectonicUnloadDuration, (long) service.engine.getMantle().getTectonicDuration());
}
return new Status(INSTANCES.size(), loadedChunks, MantleCleanerSVC.getTectonicLimit(), tectonicPlates, activeTectonicPlates, queuedTectonicPlates, minTectonicUnloadDuration, maxTectonicUnloadDuration);
}
}
@Override @Override
public void onEnable(boolean hotload) { public void onEnable(boolean hotload) {
if (hotload) return; if (hotload) return;
@ -48,33 +78,10 @@ public class EngineStatusSVC extends IrisEngineService {
} }
} }
public static int getEngineCount() { public record Status(int engineCount, long loadedChunks, int tectonicLimit,
return Math.max(INSTANCES.size(), 1); long tectonicPlates, long activeTectonicPlates,
long queuedTectonicPlates,
long minTectonicUnloadDuration,
long maxTectonicUnloadDuration) {
} }
public static Status getStatus() {
synchronized (INSTANCES) {
long loadedChunks = 0;
long tectonicPlates = 0;
long activeTectonicPlates = 0;
long queuedTectonicPlates = 0;
long minTectonicUnloadDuration = Long.MAX_VALUE;
long maxTectonicUnloadDuration = Long.MIN_VALUE;
for (var service : INSTANCES) {
var world = service.engine.getWorld();
if (world.hasRealWorld()) loadedChunks += world.realWorld().getLoadedChunks().length;
if (world.hasHeadless()) loadedChunks += world.headless().getLoadedChunks();
tectonicPlates += service.engine.getMantle().getLoadedRegionCount();
activeTectonicPlates += service.engine.getMantle().getNotQueuedLoadedRegions();
queuedTectonicPlates += service.engine.getMantle().getToUnload();
minTectonicUnloadDuration = Math.min(minTectonicUnloadDuration, (long) service.engine.getMantle().getTectonicDuration());
maxTectonicUnloadDuration = Math.max(maxTectonicUnloadDuration, (long) service.engine.getMantle().getTectonicDuration());
}
return new Status(INSTANCES.size(), loadedChunks, MantleCleanerSVC.getTectonicLimit(), tectonicPlates, activeTectonicPlates, queuedTectonicPlates, minTectonicUnloadDuration, maxTectonicUnloadDuration);
}
}
public record Status(int engineCount, long loadedChunks, int tectonicLimit, long tectonicPlates, long activeTectonicPlates, long queuedTectonicPlates, long minTectonicUnloadDuration, long maxTectonicUnloadDuration) {}
} }

View File

@ -35,29 +35,6 @@ import static com.volmit.iris.engine.service.EngineStatusSVC.getEngineCount;
public class MantleCleanerSVC extends IrisEngineService { public class MantleCleanerSVC extends IrisEngineService {
private static final AtomicInteger tectonicLimit = new AtomicInteger(30); private static final AtomicInteger tectonicLimit = new AtomicInteger(30);
private Ticker trimmer;
private Ticker unloader;
public MantleCleanerSVC(Engine engine) {
super(engine);
}
@Override
public void onEnable(boolean hotload) {
if (engine.isStudio() && !IrisSettings.get().getPerformance().trimMantleInStudio)
return;
if (trimmer == null || !trimmer.isAlive())
trimmer = createTrimmer(engine);
if (unloader == null || !unloader.isAlive())
unloader = createUnloader(engine);
}
@Override
public void onDisable(boolean hotload) {
if (hotload) return;
if (trimmer != null) trimmer.await();
if (unloader != null) unloader.await();
}
static { static {
tectonicLimit.set(2); tectonicLimit.set(2);
@ -68,6 +45,13 @@ public class MantleCleanerSVC extends IrisEngineService {
} }
} }
private Ticker trimmer;
private Ticker unloader;
public MantleCleanerSVC(Engine engine) {
super(engine);
}
public static int getTectonicLimit() { public static int getTectonicLimit() {
return tectonicLimit.get(); return tectonicLimit.get();
} }
@ -108,6 +92,23 @@ public class MantleCleanerSVC extends IrisEngineService {
}, "Iris Mantle Unloader - " + engine.getWorld().name()); }, "Iris Mantle Unloader - " + engine.getWorld().name());
} }
@Override
public void onEnable(boolean hotload) {
if (engine.isStudio() && !IrisSettings.get().getPerformance().trimMantleInStudio)
return;
if (trimmer == null || !trimmer.isAlive())
trimmer = createTrimmer(engine);
if (unloader == null || !unloader.isAlive())
unloader = createUnloader(engine);
}
@Override
public void onDisable(boolean hotload) {
if (hotload) return;
if (trimmer != null) trimmer.await();
if (unloader != null) unloader.await();
}
private static class Ticker extends Looper { private static class Ticker extends Looper {
private final LongSupplier supplier; private final LongSupplier supplier;
private final CountDownLatch exit = new CountDownLatch(1); private final CountDownLatch exit = new CountDownLatch(1);
@ -124,7 +125,8 @@ public class MantleCleanerSVC extends IrisEngineService {
long wait = -1; long wait = -1;
try { try {
wait = supplier.getAsLong(); wait = supplier.getAsLong();
} catch (Throwable ignored) {} } catch (Throwable ignored) {
}
if (wait < 0) exit.countDown(); if (wait < 0) exit.countDown();
return wait; return wait;
} }
@ -132,7 +134,8 @@ public class MantleCleanerSVC extends IrisEngineService {
public void await() { public void await() {
try { try {
exit.await(); exit.await();
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {
}
} }
} }
} }

View File

@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.link.Identifier; import com.volmit.iris.core.link.Identifier;
import com.volmit.iris.core.service.ExternalDataSVC; import com.volmit.iris.core.service.ExternalDataSVC;
import com.volmit.iris.engine.object.IrisCompat;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.misc.E; import com.volmit.iris.util.misc.E;
@ -50,10 +49,10 @@ public class B {
private static final Material SHORT_GRASS = E.getOrDefault(Material.class, "GRASS", "SHORT_GRASS"); private static final Material SHORT_GRASS = E.getOrDefault(Material.class, "GRASS", "SHORT_GRASS");
private static final BlockData AIR = AIR_MATERIAL.createBlockData(); private static final BlockData AIR = AIR_MATERIAL.createBlockData();
private static final IntSet foliageCache = buildFoliageCache(); private static final IntSet foliageCache = buildFoliageCache();
private static final IntSet decorantCache = buildDecorantCache();
private static final IntSet deepslateCache = buildDeepslateCache(); private static final IntSet deepslateCache = buildDeepslateCache();
private static final Int2IntMap normal2DeepslateCache = buildNormal2DeepslateCache(); private static final Int2IntMap normal2DeepslateCache = buildNormal2DeepslateCache();
private static final Int2IntMap deepslate2NormalCache = buildDeepslate2NormalCache(); private static final Int2IntMap deepslate2NormalCache = buildDeepslate2NormalCache();
private static final IntSet decorantCache = buildDecorantCache();
private static final IntSet storageCache = buildStorageCache(); private static final IntSet storageCache = buildStorageCache();
private static final IntSet storageChestCache = buildStorageChestCache(); private static final IntSet storageChestCache = buildStorageChestCache();
private static final IntSet litCache = buildLitCache(); private static final IntSet litCache = buildLitCache();

View File

@ -25,7 +25,8 @@ import java.util.Arrays;
public class DoubleArrayUtils { public class DoubleArrayUtils {
public static void shiftRight(double[] values, double push) { public static void shiftRight(double[] values, double push) {
if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1); if (values.length - 2 + 1 >= 0)
System.arraycopy(values, 0, values, 1, values.length - 2 + 1);
values[0] = push; values[0] = push;
} }

View File

@ -34,112 +34,112 @@ import org.jetbrains.annotations.Nullable;
@Data @Data
public class IrisCustomData implements BlockData { public class IrisCustomData implements BlockData {
private final @NonNull BlockData base; private final @NonNull BlockData base;
private final @NotNull Identifier custom; private final @NotNull Identifier custom;
@NotNull @NotNull
@Override @Override
public Material getMaterial() { public Material getMaterial() {
return base.getMaterial(); return base.getMaterial();
} }
@NotNull @NotNull
@Override @Override
public String getAsString() { public String getAsString() {
return base.getAsString(); return base.getAsString();
} }
@NotNull @NotNull
@Override @Override
public String getAsString(boolean b) { public String getAsString(boolean b) {
return base.getAsString(b); return base.getAsString(b);
} }
@NotNull @NotNull
@Override @Override
public BlockData merge(@NotNull BlockData blockData) { public BlockData merge(@NotNull BlockData blockData) {
return new IrisCustomData(base.merge(blockData), custom); return new IrisCustomData(base.merge(blockData), custom);
} }
@Override @Override
public boolean matches(@Nullable BlockData blockData) { public boolean matches(@Nullable BlockData blockData) {
if (blockData instanceof IrisCustomData b) if (blockData instanceof IrisCustomData b)
return custom.equals(b.custom) && base.matches(b.base); return custom.equals(b.custom) && base.matches(b.base);
return base.matches(blockData); return base.matches(blockData);
} }
@NotNull @NotNull
@Override @Override
public BlockData clone() { public BlockData clone() {
return new IrisCustomData(base.clone(), custom); return new IrisCustomData(base.clone(), custom);
} }
@NotNull @NotNull
@Override @Override
public SoundGroup getSoundGroup() { public SoundGroup getSoundGroup() {
return base.getSoundGroup(); return base.getSoundGroup();
} }
@Override @Override
public int getLightEmission() { public int getLightEmission() {
return base.getLightEmission(); return base.getLightEmission();
} }
@Override @Override
public boolean isOccluding() { public boolean isOccluding() {
return base.isOccluding(); return base.isOccluding();
} }
@Override @Override
public boolean requiresCorrectToolForDrops() { public boolean requiresCorrectToolForDrops() {
return base.requiresCorrectToolForDrops(); return base.requiresCorrectToolForDrops();
} }
@Override @Override
public boolean isPreferredTool(@NotNull ItemStack itemStack) { public boolean isPreferredTool(@NotNull ItemStack itemStack) {
return base.isPreferredTool(itemStack); return base.isPreferredTool(itemStack);
} }
@NotNull @NotNull
@Override @Override
public PistonMoveReaction getPistonMoveReaction() { public PistonMoveReaction getPistonMoveReaction() {
return base.getPistonMoveReaction(); return base.getPistonMoveReaction();
} }
@Override @Override
public boolean isSupported(@NotNull Block block) { public boolean isSupported(@NotNull Block block) {
return base.isSupported(block); return base.isSupported(block);
} }
@Override @Override
public boolean isSupported(@NotNull Location location) { public boolean isSupported(@NotNull Location location) {
return base.isSupported(location); return base.isSupported(location);
} }
@Override @Override
public boolean isFaceSturdy(@NotNull BlockFace blockFace, @NotNull BlockSupport blockSupport) { public boolean isFaceSturdy(@NotNull BlockFace blockFace, @NotNull BlockSupport blockSupport) {
return base.isFaceSturdy(blockFace, blockSupport); return base.isFaceSturdy(blockFace, blockSupport);
} }
@NotNull @NotNull
@Override @Override
public Material getPlacementMaterial() { public Material getPlacementMaterial() {
return base.getPlacementMaterial(); return base.getPlacementMaterial();
} }
@Override @Override
public void rotate(@NotNull StructureRotation structureRotation) { public void rotate(@NotNull StructureRotation structureRotation) {
base.rotate(structureRotation); base.rotate(structureRotation);
} }
@Override @Override
public void mirror(@NotNull Mirror mirror) { public void mirror(@NotNull Mirror mirror) {
base.mirror(mirror); base.mirror(mirror);
} }
@NotNull @NotNull
@Override @Override
public BlockState createBlockState() { public BlockState createBlockState() {
return base.createBlockState(); return base.createBlockState();
} }
} }

View File

@ -21,8 +21,6 @@ package com.volmit.iris.util.decree.specialhandlers;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.handlers.BiomeHandler; import com.volmit.iris.util.decree.handlers.BiomeHandler;
import com.volmit.iris.util.decree.handlers.PlayerHandler;
import org.bukkit.entity.Player;
public class NullableBiomeHandler extends BiomeHandler { public class NullableBiomeHandler extends BiomeHandler {

View File

@ -18,14 +18,10 @@
package com.volmit.iris.util.decree.specialhandlers; package com.volmit.iris.util.decree.specialhandlers;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.handlers.BiomeHandler;
import com.volmit.iris.util.decree.handlers.RegionHandler; import com.volmit.iris.util.decree.handlers.RegionHandler;
import javax.swing.plaf.synth.Region;
public class NullableRegionHandler extends RegionHandler { public class NullableRegionHandler extends RegionHandler {
@Override @Override

View File

@ -40,15 +40,17 @@ import com.volmit.iris.util.matter.MatterSlice;
import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.HyperLock; import com.volmit.iris.util.parallel.HyperLock;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.Looper;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import java.io.EOFException; import java.io.EOFException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.concurrent.*; import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -73,6 +75,15 @@ public class Mantle {
private final MultiBurst ioBurst; private final MultiBurst ioBurst;
private final AtomicBoolean ioTrim; private final AtomicBoolean ioTrim;
private final AtomicBoolean ioTectonicUnload; private final AtomicBoolean ioTectonicUnload;
@Getter
private final AtomicDouble adjustedIdleDuration = new AtomicDouble(0);
@Getter
private final AtomicInteger forceAggressiveThreshold = new AtomicInteger(30);
@Getter
private final AtomicLong oldestTectonicPlate = new AtomicLong(0);
private final ReentrantLock unloadLock = new ReentrantLock();
@Getter
private final KList<Long> toUnload = new KList<>();
/** /**
* Create a new mantle * Create a new mantle
@ -393,16 +404,6 @@ public class Mantle {
return numberOfEntries * bytesPerEntry; return numberOfEntries * bytesPerEntry;
} }
@Getter
private final AtomicDouble adjustedIdleDuration = new AtomicDouble(0);
@Getter
private final AtomicInteger forceAggressiveThreshold = new AtomicInteger(30);
@Getter
private final AtomicLong oldestTectonicPlate = new AtomicLong(0);
private final ReentrantLock unloadLock = new ReentrantLock();
@Getter
private final KList<Long> toUnload = new KList<>();
/** /**
* Save & unload regions that have not been used for more than the * Save & unload regions that have not been used for more than the
* specified amount of milliseconds * specified amount of milliseconds

View File

@ -28,8 +28,6 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter; import lombok.Getter;
import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream; import net.jpountz.lz4.LZ4BlockOutputStream;
import net.jpountz.lz4.LZ4FrameInputStream;
import net.jpountz.lz4.LZ4FrameOutputStream;
import java.io.*; import java.io.*;
import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.atomic.AtomicReferenceArray;

View File

@ -59,9 +59,11 @@ public enum Direction {
return switch (f) { return switch (f) {
case DOWN -> D; case DOWN -> D;
case EAST, EAST_SOUTH_EAST, EAST_NORTH_EAST -> E; case EAST, EAST_SOUTH_EAST, EAST_NORTH_EAST -> E;
case NORTH, NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST, NORTH_EAST -> N; case NORTH, NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST,
NORTH_EAST -> N;
case SELF, UP -> U; case SELF, UP -> U;
case SOUTH, SOUTH_WEST, SOUTH_SOUTH_WEST, SOUTH_SOUTH_EAST, SOUTH_EAST -> S; case SOUTH, SOUTH_WEST, SOUTH_SOUTH_WEST, SOUTH_SOUTH_EAST,
SOUTH_EAST -> S;
case WEST, WEST_SOUTH_WEST, WEST_NORTH_WEST -> W; case WEST, WEST_SOUTH_WEST, WEST_NORTH_WEST -> W;
}; };

View File

@ -19,14 +19,9 @@
package com.volmit.iris.util.math; package com.volmit.iris.util.math;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.nio.charset.StandardCharsets;
public class RNGV2 extends SecureRandom { public class RNGV2 extends SecureRandom {
private static final long serialVersionUID = 5222938581174415179L; private static final long serialVersionUID = 5222938581174415179L;

View File

@ -29,26 +29,26 @@ import java.io.IOException;
@Sliced @Sliced
public class IdentifierMatter extends RawMatter<Identifier> { public class IdentifierMatter extends RawMatter<Identifier> {
public IdentifierMatter() { public IdentifierMatter() {
this(1, 1, 1); this(1, 1, 1);
} }
public IdentifierMatter(int width, int height, int depth) { public IdentifierMatter(int width, int height, int depth) {
super(width, height, depth, Identifier.class); super(width, height, depth, Identifier.class);
} }
@Override @Override
public Palette<Identifier> getGlobalPalette() { public Palette<Identifier> getGlobalPalette() {
return null; return null;
} }
@Override @Override
public void writeNode(Identifier b, DataOutputStream dos) throws IOException { public void writeNode(Identifier b, DataOutputStream dos) throws IOException {
dos.writeUTF(b.toString()); dos.writeUTF(b.toString());
} }
@Override @Override
public Identifier readNode(DataInputStream din) throws IOException { public Identifier readNode(DataInputStream din) throws IOException {
return Identifier.fromString(din.readUTF()); return Identifier.fromString(din.readUTF());
} }
} }

View File

@ -29,7 +29,7 @@ import java.io.IOException;
@Sliced @Sliced
public class JigsawPieceMatter extends RawMatter<JigsawPieceContainer> { public class JigsawPieceMatter extends RawMatter<JigsawPieceContainer> {
public JigsawPieceMatter() { public JigsawPieceMatter() {
this(1,1,1); this(1, 1, 1);
} }
public JigsawPieceMatter(int width, int height, int depth) { public JigsawPieceMatter(int width, int height, int depth) {

View File

@ -36,7 +36,8 @@ import java.util.Set;
public class JigsawStructuresContainer { public class JigsawStructuresContainer {
private final Map<String, List<Position2>> map = new KMap<>(); private final Map<String, List<Position2>> map = new KMap<>();
public JigsawStructuresContainer() {} public JigsawStructuresContainer() {
}
public JigsawStructuresContainer(DataInputStream din) throws IOException { public JigsawStructuresContainer(DataInputStream din) throws IOException {
int s0 = din.readInt(); int s0 = din.readInt();

View File

@ -33,12 +33,9 @@ import oshi.SystemInfo;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.file.Files;
import java.util.List;
public class Hastebin { public class Hastebin {
@ -97,11 +94,11 @@ public class Hastebin {
for (String disk : disks) { for (String disk : disks) {
sb.append(" ").append(sb.append(disk)).append("\n"); sb.append(" ").append(sb.append(disk)).append("\n");
} }
sb.append(" -- == Interface Information == -- "+ "\n" ); sb.append(" -- == Interface Information == -- " + "\n");
for (String inter : interfaces) { for (String inter : interfaces) {
sb.append(" ").append(inter).append("\n"); sb.append(" ").append(inter).append("\n");
} }
sb.append(" -- == Display Information == -- "+ "\n" ); sb.append(" -- == Display Information == -- " + "\n");
for (String display : displays) { for (String display : displays) {
sb.append(display).append("\n"); sb.append(display).append("\n");
} }

View File

@ -22,13 +22,10 @@ package com.volmit.iris.util.misc;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import org.jetbrains.annotations.Nullable;
import oshi.SystemInfo; import oshi.SystemInfo;
import oshi.hardware.*; import oshi.hardware.*;
import oshi.software.os.FileSystem;
import oshi.software.os.OSFileStore; import oshi.software.os.OSFileStore;
import oshi.software.os.OperatingSystem; import oshi.software.os.OperatingSystem;
import oshi.util.EdidUtil;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.NetworkInterface; import java.net.NetworkInterface;
@ -36,7 +33,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class getHardware { public class getHardware {
public static String getServerOS() { public static String getServerOS() {
@ -44,10 +40,12 @@ public class getHardware {
OperatingSystem os = systemInfo.getOperatingSystem(); OperatingSystem os = systemInfo.getOperatingSystem();
return os.toString(); return os.toString();
} }
public static long getProcessMemory(){
public static long getProcessMemory() {
long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024); long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024);
return maxMemory; return maxMemory;
} }
public static long getProcessUsedMemory() { public static long getProcessUsedMemory() {
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
@ -58,7 +56,7 @@ public class getHardware {
return usedMemory / (1024 * 1024); return usedMemory / (1024 * 1024);
} }
public static long getAvailableProcessMemory(){ public static long getAvailableProcessMemory() {
long availableMemory = getHardware.getProcessMemory() - getHardware.getProcessUsedMemory(); long availableMemory = getHardware.getProcessMemory() - getHardware.getProcessUsedMemory();
return availableMemory; return availableMemory;
} }
@ -125,7 +123,7 @@ public class getHardware {
systemDisks.add(" - Mount: " + partition.getMount()); systemDisks.add(" - Mount: " + partition.getMount());
systemDisks.add(" - Label: " + partition.getLabel()); systemDisks.add(" - Label: " + partition.getLabel());
} }
systemDisks.add(C.DARK_GRAY + "-=" + C.BLUE +" Since Boot " + C.DARK_GRAY + "=- "); systemDisks.add(C.DARK_GRAY + "-=" + C.BLUE + " Since Boot " + C.DARK_GRAY + "=- ");
systemDisks.add("- Total Reads: " + Form.memSize(disk.getReadBytes())); systemDisks.add("- Total Reads: " + Form.memSize(disk.getReadBytes()));
systemDisks.add("- Total Writes: " + Form.memSize(disk.getWriteBytes())); systemDisks.add("- Total Writes: " + Form.memSize(disk.getWriteBytes()));
} }

View File

@ -20,9 +20,7 @@ package com.volmit.iris.util.nbt.mca;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.tools.IrisWorldDump;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.nbt.io.NBTDeserializer; import com.volmit.iris.util.nbt.io.NBTDeserializer;
import com.volmit.iris.util.nbt.io.NBTSerializer; import com.volmit.iris.util.nbt.io.NBTSerializer;
import com.volmit.iris.util.nbt.io.NamedTag; import com.volmit.iris.util.nbt.io.NamedTag;
@ -605,7 +603,8 @@ public class Chunk {
if (tileTicks != null) level.put("TileTicks", tileTicks); if (tileTicks != null) level.put("TileTicks", tileTicks);
if (liquidTicks != null) level.put("LiquidTicks", liquidTicks); if (liquidTicks != null) level.put("LiquidTicks", liquidTicks);
if (lights != null) level.put("Lights", lights); if (lights != null) level.put("Lights", lights);
if (liquidsToBeTicked != null) level.put("LiquidsToBeTicked", liquidsToBeTicked); if (liquidsToBeTicked != null)
level.put("LiquidsToBeTicked", liquidsToBeTicked);
if (toBeTicked != null) level.put("ToBeTicked", toBeTicked); if (toBeTicked != null) level.put("ToBeTicked", toBeTicked);
if (postProcessing != null) level.put("PostProcessing", postProcessing); if (postProcessing != null) level.put("PostProcessing", postProcessing);
level.putString("Status", status); level.putString("Status", status);

View File

@ -19,6 +19,7 @@
package com.volmit.iris.util.nbt.mca.palette; package com.volmit.iris.util.nbt.mca.palette;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
// todo Cool idea but im way to dumb for this for now // todo Cool idea but im way to dumb for this for now
public class MCABitStorageByteArray { public class MCABitStorageByteArray {
private final byte[] data; private final byte[] data;

View File

@ -20,7 +20,6 @@ package com.volmit.iris.util.nbt.mca.palette;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import java.util.BitSet;
import java.util.function.IntConsumer; import java.util.function.IntConsumer;
public class MCABitStorageLongArray { public class MCABitStorageLongArray {

Some files were not shown because too many files have changed in this diff Show More