9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-22 16:49:14 +00:00

🧌 Fixed Color and Seed Issue.

This commit is contained in:
Vatuu
2023-04-02 21:10:44 +02:00
parent 6f9ad8b0eb
commit 502aa054f6
3 changed files with 52 additions and 43 deletions

View File

@@ -66,6 +66,7 @@ import org.bukkit.*;
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;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -301,8 +302,8 @@ public class Iris extends VolmitPlugin implements Listener {
msg(C.IRIS + string); msg(C.IRIS + string);
} }
public static void info(String string) { public static void info(String format, Object... args) {
msg(C.WHITE + string); msg(C.WHITE + String.format(format, args));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@@ -462,33 +463,38 @@ public class Iris extends VolmitPlugin implements Listener {
FileConfiguration fc = new YamlConfiguration(); FileConfiguration fc = new YamlConfiguration();
try { try {
fc.load(new File("bukkit.yml")); fc.load(new File("bukkit.yml"));
searching: ConfigurationSection section = fc.getConfigurationSection("worlds");
for (String i : fc.getKeys(true)) { if(section == null) {
if (i.startsWith("worlds.") && i.endsWith(".generator")) { return;
String worldName = i.split("\\Q.\\E")[1]; }
String generator = IrisSettings.get().getGenerator().getDefaultWorldType();
if (fc.getString(i).startsWith("Iris:")) { for(String s : section.getKeys(false)){
generator = fc.getString(i).split("\\Q:\\E")[1]; ConfigurationSection entry = section.getConfigurationSection(s);
} else if (fc.getString(i).equals("Iris")) { 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(); generator = IrisSettings.get().getGenerator().getDefaultWorldType();
} else { } else {
continue; continue;
} }
for (World j : Bukkit.getWorlds()) { Iris.info("2 World: %s | Generator: %s", s, generator);
if (j.getName().equals(worldName)) {
continue searching; if(Bukkit.getWorlds().stream().anyMatch(w -> w.getName().equals(s))) {
} continue;
} }
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 " + s + "' using Iris:" + generator + "...");
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + worldName + "' using Iris:" + generator); new WorldCreator(s)
World world = new WorldCreator(worldName) .generator(getDefaultWorldGenerator(s, generator))
.generator(getDefaultWorldGenerator(worldName, generator))
.environment(IrisData.loadAnyDimension(generator).getEnvironment()) .environment(IrisData.loadAnyDimension(generator).getEnvironment())
.createWorld(); .createWorld();
Iris.info(C.LIGHT_PURPLE + "Loaded " + worldName + "!"); Iris.info(C.LIGHT_PURPLE + "Loaded " + s + "!");
}
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -394,7 +394,6 @@ public class NMSBinding19_4 implements INMSBinding {
return f; return f;
} }
try { try {
f = storage.getClass().getDeclaredField("biome"); f = storage.getClass().getDeclaredField("biome");
f.setAccessible(true); f.setAccessible(true);
return f; return f;

View File

@@ -92,6 +92,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
@Setter @Setter
private StudioGenerator studioGenerator; private StudioGenerator studioGenerator;
private boolean initialized = false;
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) { public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
setup = new AtomicBoolean(false); setup = new AtomicBoolean(false);
studioGenerator = null; studioGenerator = null;
@@ -124,7 +126,9 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
@EventHandler @EventHandler
public void onWorldInit(WorldInitEvent event) { public void onWorldInit(WorldInitEvent event) {
try { try {
if (world.name().equals(event.getWorld().getName()) && world.getRawWorldSeed() == event.getWorld().getSeed()) { if(!initialized) {
world.setRawWorldSeed(event.getWorld().getSeed());
if (world.name().equals(event.getWorld().getName())) {
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle(); ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
Engine engine = getEngine(event.getWorld()); Engine engine = getEngine(event.getWorld());
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass(); Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
@@ -137,8 +141,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource); unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource); biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName()); Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
} else { initialized = true;
Iris.info("World " + event.getWorld().getName() + " is not an Iris world in this context"); }
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();