This commit is contained in:
Daniel Mills 2020-10-06 16:54:36 -04:00
parent 4f7d659700
commit 843b5d7154
8 changed files with 206 additions and 116 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>bytecode.ninja</groupId>
<artifactId>Iris</artifactId>
<version>1.0.3</version>
<version>1.0.5</version>
<name>Iris</name>
<properties>
<skip.copy>false</skip.copy>

View File

@ -7,6 +7,7 @@ import com.google.gson.Gson;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IO;
import com.volmit.iris.util.J;
import com.volmit.iris.util.JSONException;
import com.volmit.iris.util.JSONObject;
@ -21,6 +22,10 @@ public class IrisSettings
@Desc("Iris generator threads (must be 2 or higher). Threads in iris are not a perfect scale for performance as a lot of data has to be shared. 16 Threads is a good rule of thumb. Use 8 threads on a quad core processor.")
public int threads = 16;
@DontObfuscate
@Desc("The default world type incase iris doesnt have a dimension to use.")
public String defaultWorldType = "overworld";
@DontObfuscate
@Desc("Iris uses a lot of caching to speed up chunk generation. Setting this higher uses more memory, but may improve performance. Anything past 8,000 should be avoided because there is little benefit past this value.")
public int atomicCacheSize = 3000;
@ -65,12 +70,18 @@ public class IrisSettings
@Desc("Collects anonymous metrics for bstats")
public boolean metrics = true;
@DontObfuscate
@Desc("Skips preparing spawn by using nms to hijack the world init phase")
public boolean skipPrepareSpawnNMS = true;
@DontObfuscate
@Desc("Used to activate Iris")
public String activationCode = "";
public static IrisSettings get()
{
IrisSettings defaults = new IrisSettings();
JSONObject def = new JSONObject(new Gson().toJson(defaults));
if(settings == null)
{
settings = new IrisSettings();
@ -94,7 +105,37 @@ public class IrisSettings
{
try
{
settings = new Gson().fromJson(IO.readAll(s), IrisSettings.class);
String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class);
J.a(() ->
{
JSONObject j = new JSONObject(ss);
boolean u = false;
for(String i : def.keySet())
{
if(!j.has(i))
{
u = true;
j.put(i, def.get(i));
Iris.verbose("Adding new config key: " + i);
}
}
if(u)
{
try
{
IO.writeAll(s, j.toString(4));
Iris.info("Updated Configuration Files");
}
catch(Throwable e)
{
}
}
});
}
catch(JSONException | IOException e)

View File

@ -1,14 +1,11 @@
package com.volmit.iris.command;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
@ -17,11 +14,8 @@ import com.volmit.iris.gen.nms.NMSCreator;
import com.volmit.iris.gen.provisions.ProvisionBukkit;
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
import com.volmit.iris.gen.scaffold.TerrainTarget;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.manager.ProjectManager;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.util.Form;
import com.volmit.iris.util.IO;
import com.volmit.iris.util.J;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
@ -62,87 +56,9 @@ public class CommandIrisCreate extends MortarCommand
seed = i.startsWith("seed=") ? Long.valueOf(i.split("\\Q=\\E")[1]) : seed;
pregen = i.startsWith("pregen=") ? Integer.parseInt(i.split("\\Q=\\E")[1]) : pregen;
}
IrisDimension dim = Iris.proj.installIntoWorld(sender, type, folder);
sender.sendMessage("Looking for Package: " + type);
IrisDimension dim = Iris.globaldata.getDimensionLoader().load(type);
if(dim == null)
{
for(File i : Iris.proj.getWorkspaceFolder().listFiles())
{
if(i.isFile() && i.getName().equals(type + ".iris"))
{
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.workspaceName + " folder");
ZipUtil.unpack(i, iris);
break;
}
}
}
else
{
sender.sendMessage("Foind " + type + " dimension in " + ProjectManager.workspaceName + " folder. Repackaging");
ZipUtil.unpack(Iris.proj.compilePackage(sender, type, true, true), iris);
}
File dimf = new File(iris, "dimensions/" + type + ".json");
if(!dimf.exists() || !dimf.isFile())
{
Iris.globaldata.dump();
Iris.globaldata.preferFolder(null);
Iris.proj.downloadSearch(sender, type, false);
File downloaded = Iris.proj.getWorkspaceFolder(type);
for(File i : downloaded.listFiles())
{
if(i.isFile())
{
try
{
FileUtils.copyFile(i, new File(iris, i.getName()));
}
catch(IOException e)
{
e.printStackTrace();
}
}
else
{
try
{
FileUtils.copyDirectory(i, new File(iris, i.getName()));
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
IO.delete(downloaded);
}
if(!dimf.exists() || !dimf.isFile())
{
sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!");
return true;
}
IrisDataManager dm = new IrisDataManager(folder);
dim = dm.getDimensionLoader().load(type);
if(dim == null)
{
sender.sendMessage("Can't load the dimension! Failed!");
return true;
}
sender.sendMessage(worldName + " type installed. Generating Spawn Area...");
//@builder
ProvisionBukkit gen = Iris.instance.createProvisionBukkit(
IrisGenConfiguration.builder()
@ -190,8 +106,7 @@ public class CommandIrisCreate extends MortarCommand
WorldCreator wc = new WorldCreator(worldName).seed(seed).generator(gen).type(WorldType.NORMAL).environment(dim.getEnvironment());
World world = NMSCreator.createWorld(wc, false);
done.set(true);
sender.sendMessage(worldName + " Spawn Area generated.");
@ -218,7 +133,7 @@ public class CommandIrisCreate extends MortarCommand
Iris.linkMultiverseCore.addWorld(worldName, dimm, seedd + "");
sender.sendMessage("Added " + worldName + " to MultiverseCore.");
}
J.a(() ->
{
while(!b.get())

View File

@ -2,17 +2,20 @@ package com.volmit.iris.gen;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.gen.scaffold.TerrainTarget;
import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.util.B;
import com.volmit.iris.util.MortarSender;
import com.volmit.iris.util.RNG;
import lombok.Data;
@ -40,7 +43,23 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
if(!folder.exists())
{
Iris.error("Missing World iris/dimensions folder! (" + folder.getAbsolutePath() + ")");
setDimensionName("error-missing-dimension");
setDimensionName(IrisSettings.get().getDefaultWorldType());
Iris.proj.installIntoWorld(new MortarSender(Bukkit.getConsoleSender()), getDimensionName(), getTarget().getFolder());
return;
}
if(!folder.exists())
{
Iris.error("Missing World iris/dimensions folder! (" + folder.getAbsolutePath() + ")");
try
{
throw new RuntimeException("Cant find dimension data!");
}
catch(Throwable e)
{
fail(e);
}
return;
}
@ -53,9 +72,20 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
}
}
Iris.error("Missing World iris/dimensions/<dimension-name>.json file. Assuming overworld!");
setDimensionName("error-missing-dimension");
fail(new RuntimeException("Missing dimension folder/file in " + folder.getAbsolutePath()));
if(!folder.exists())
{
Iris.error("Missing World iris/dimensions folder! (" + folder.getAbsolutePath() + ")");
try
{
throw new RuntimeException("Cant find dimension data!");
}
catch(Throwable e)
{
fail(e);
}
return;
}
}
try
@ -69,6 +99,11 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
}
}
protected void useDefaultDimensionSetupNOW()
{
}
public void onPlayerLeft(Player p)
{

View File

@ -542,12 +542,22 @@ public class IrisTerrainProvider extends SkyTerrainProvider implements IrisConte
@Override
public boolean shouldGenerateCaves()
{
if(getDimension() == null)
{
return false;
}
return getDimension().isVanillaCaves();
}
@Override
public boolean shouldGenerateVanillaStructures()
{
if(getDimension() == null)
{
return false;
}
return getDimension().isVanillaStructures();
}

View File

@ -5,6 +5,7 @@ import org.bukkit.World;
import org.bukkit.WorldCreator;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
public class NMSCreator
{
@ -15,31 +16,34 @@ public class NMSCreator
public static World createWorld(WorldCreator creator, boolean loadSpawn)
{
try
if(IrisSettings.get().isSkipPrepareSpawnNMS())
{
String code = Iris.nmsTag();
try
{
String code = Iris.nmsTag();
if(code.equals("v1_16_R2"))
{
return NMSCreator162.createWorld(creator, loadSpawn);
if(code.equals("v1_16_R2"))
{
return NMSCreator162.createWorld(creator, loadSpawn);
}
else if(code.equals("v1_16_R1"))
{
return NMSCreator161.createWorld(creator, loadSpawn);
}
else if(code.equals("v1_15_R1"))
{
return NMSCreator151.createWorld(creator, loadSpawn);
}
else if(code.equals("v1_14_R1"))
{
return NMSCreator141.createWorld(creator, loadSpawn);
}
}
else if(code.equals("v1_16_R1"))
{
return NMSCreator161.createWorld(creator, loadSpawn);
}
else if(code.equals("v1_15_R1"))
{
return NMSCreator151.createWorld(creator, loadSpawn);
}
else if(code.equals("v1_14_R1"))
{
return NMSCreator141.createWorld(creator, loadSpawn);
}
}
catch(Throwable e)
{
catch(Throwable e)
{
}
}
return Bukkit.createWorld(creator);

View File

@ -66,6 +66,91 @@ public class ProjectManager
}
}
public IrisDimension installIntoWorld(MortarSender sender, String type, File folder)
{
sender.sendMessage("Looking for Package: " + type);
File iris = new File(folder, "iris");
IrisDimension dim = Iris.globaldata.getDimensionLoader().load(type);
if(dim == null)
{
for(File i : Iris.proj.getWorkspaceFolder().listFiles())
{
if(i.isFile() && i.getName().equals(type + ".iris"))
{
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.workspaceName + " folder");
ZipUtil.unpack(i, iris);
break;
}
}
}
else
{
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.workspaceName + " folder. Repackaging");
ZipUtil.unpack(Iris.proj.compilePackage(sender, type, true, true), iris);
}
File dimf = new File(iris, "dimensions/" + type + ".json");
if(!dimf.exists() || !dimf.isFile())
{
Iris.globaldata.dump();
Iris.globaldata.preferFolder(null);
Iris.proj.downloadSearch(sender, type, false);
File downloaded = Iris.proj.getWorkspaceFolder(type);
for(File i : downloaded.listFiles())
{
if(i.isFile())
{
try
{
FileUtils.copyFile(i, new File(iris, i.getName()));
}
catch(IOException e)
{
e.printStackTrace();
}
}
else
{
try
{
FileUtils.copyDirectory(i, new File(iris, i.getName()));
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
IO.delete(downloaded);
}
if(!dimf.exists() || !dimf.isFile())
{
sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!");
return null;
}
IrisDataManager dm = new IrisDataManager(folder);
dim = dm.getDimensionLoader().load(type);
if(dim == null)
{
sender.sendMessage("Can't load the dimension! Failed!");
return null;
}
sender.sendMessage(folder.getName() + " type installed. ");
return dim;
}
public void downloadSearch(MortarSender sender, String key, boolean trim)
{
String repo = getListing(false).get(key);

View File

@ -182,7 +182,7 @@ public class PregenJob implements Listener
{
chunkSpiraler.next();
if(isChunkWithin(chunkX, chunkZ))
if(isChunkWithin(chunkX, chunkZ) && consumer != null)
{
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.BLUE.darker().darker());
}