mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-02 16:07:06 +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.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:")) {
|
|
||||||
generator = fc.getString(i).split("\\Q:\\E")[1];
|
|
||||||
} else if (fc.getString(i).equals("Iris")) {
|
|
||||||
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (World j : Bukkit.getWorlds()) {
|
for(String s : section.getKeys(false)){
|
||||||
if (j.getName().equals(worldName)) {
|
ConfigurationSection entry = section.getConfigurationSection(s);
|
||||||
continue searching;
|
if(!entry.contains("generator", true)) {
|
||||||
}
|
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 " + 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 + "!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -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;
|
||||||
|
@ -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,21 +126,23 @@ 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) {
|
||||||
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
|
world.setRawWorldSeed(event.getWorld().getSeed());
|
||||||
Engine engine = getEngine(event.getWorld());
|
if (world.name().equals(event.getWorld().getName())) {
|
||||||
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
|
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
|
||||||
Field biomeSource = getField(clazz, "b");
|
Engine engine = getEngine(event.getWorld());
|
||||||
biomeSource.setAccessible(true);
|
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
|
||||||
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
Field biomeSource = getField(clazz, "b");
|
||||||
unsafeField.setAccessible(true);
|
biomeSource.setAccessible(true);
|
||||||
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||||
CustomBiomeSource customBiomeSource = new CustomBiomeSource(event.getWorld().getSeed(), engine, event.getWorld());
|
unsafeField.setAccessible(true);
|
||||||
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
|
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
||||||
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
|
CustomBiomeSource customBiomeSource = new CustomBiomeSource(event.getWorld().getSeed(), engine, event.getWorld());
|
||||||
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
|
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
|
||||||
} else {
|
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
|
||||||
Iris.info("World " + event.getWorld().getName() + " is not an Iris world in this context");
|
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user