mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
🧌 Fixed Color and Seed Issue.
This commit is contained in:
parent
6f9ad8b0eb
commit
502aa054f6
@ -66,6 +66,7 @@ import org.bukkit.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -301,8 +302,8 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
msg(C.IRIS + string);
|
||||
}
|
||||
|
||||
public static void info(String string) {
|
||||
msg(C.WHITE + string);
|
||||
public static void info(String format, Object... args) {
|
||||
msg(C.WHITE + String.format(format, args));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -462,33 +463,38 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
FileConfiguration fc = new YamlConfiguration();
|
||||
try {
|
||||
fc.load(new File("bukkit.yml"));
|
||||
searching:
|
||||
for (String i : fc.getKeys(true)) {
|
||||
if (i.startsWith("worlds.") && i.endsWith(".generator")) {
|
||||
String worldName = i.split("\\Q.\\E")[1];
|
||||
String generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
if (fc.getString(i).startsWith("Iris:")) {
|
||||
generator = fc.getString(i).split("\\Q:\\E")[1];
|
||||
} else if (fc.getString(i).equals("Iris")) {
|
||||
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
ConfigurationSection section = fc.getConfigurationSection("worlds");
|
||||
if(section == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (World j : Bukkit.getWorlds()) {
|
||||
if (j.getName().equals(worldName)) {
|
||||
continue searching;
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Detected an Iris World in the bukkit yml '" + worldName + "' using Iris that was not loaded by bukkit. Good Guy Iris will load it up for you!");
|
||||
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + worldName + "' using Iris:" + generator);
|
||||
World world = new WorldCreator(worldName)
|
||||
.generator(getDefaultWorldGenerator(worldName, generator))
|
||||
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
|
||||
.createWorld();
|
||||
Iris.info(C.LIGHT_PURPLE + "Loaded " + worldName + "!");
|
||||
for(String s : section.getKeys(false)){
|
||||
ConfigurationSection entry = section.getConfigurationSection(s);
|
||||
if(!entry.contains("generator", true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String generator = entry.getString("generator");
|
||||
if(generator.startsWith("Iris:")) {
|
||||
generator = generator.split("\\Q:\\E")[1];
|
||||
} else if(generator.equalsIgnoreCase("Iris")) {
|
||||
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
Iris.info("2 World: %s | Generator: %s", s, generator);
|
||||
|
||||
if(Bukkit.getWorlds().stream().anyMatch(w -> w.getName().equals(s))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + s + "' using Iris:" + generator + "...");
|
||||
new WorldCreator(s)
|
||||
.generator(getDefaultWorldGenerator(s, generator))
|
||||
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
|
||||
.createWorld();
|
||||
Iris.info(C.LIGHT_PURPLE + "Loaded " + s + "!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -394,7 +394,6 @@ public class NMSBinding19_4 implements INMSBinding {
|
||||
return f;
|
||||
}
|
||||
try {
|
||||
|
||||
f = storage.getClass().getDeclaredField("biome");
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
|
@ -92,6 +92,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
@Setter
|
||||
private StudioGenerator studioGenerator;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
||||
setup = new AtomicBoolean(false);
|
||||
studioGenerator = null;
|
||||
@ -124,21 +126,23 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
@EventHandler
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
try {
|
||||
if (world.name().equals(event.getWorld().getName()) && world.getRawWorldSeed() == event.getWorld().getSeed()) {
|
||||
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
|
||||
Engine engine = getEngine(event.getWorld());
|
||||
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
|
||||
Field biomeSource = getField(clazz, "b");
|
||||
biomeSource.setAccessible(true);
|
||||
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
||||
CustomBiomeSource customBiomeSource = new CustomBiomeSource(event.getWorld().getSeed(), engine, event.getWorld());
|
||||
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
|
||||
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
|
||||
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
|
||||
} else {
|
||||
Iris.info("World " + event.getWorld().getName() + " is not an Iris world in this context");
|
||||
if(!initialized) {
|
||||
world.setRawWorldSeed(event.getWorld().getSeed());
|
||||
if (world.name().equals(event.getWorld().getName())) {
|
||||
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
|
||||
Engine engine = getEngine(event.getWorld());
|
||||
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
|
||||
Field biomeSource = getField(clazz, "b");
|
||||
biomeSource.setAccessible(true);
|
||||
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
||||
CustomBiomeSource customBiomeSource = new CustomBiomeSource(event.getWorld().getSeed(), engine, event.getWorld());
|
||||
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
|
||||
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
|
||||
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
x
Reference in New Issue
Block a user