mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 23:01:07 +00:00
fix datapack dump + change target location
This commit is contained in:
@@ -469,7 +469,6 @@ 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();
|
||||||
ServerConfigurator.disableDataPack();
|
|
||||||
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();
|
||||||
@@ -477,6 +476,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||||
services.values().forEach(IrisService::onEnable);
|
services.values().forEach(IrisService::onEnable);
|
||||||
services.values().forEach(this::registerListener);
|
services.values().forEach(this::registerListener);
|
||||||
|
ServerConfigurator.setupDataPack();
|
||||||
installMainDimension();
|
installMainDimension();
|
||||||
if (!IrisSafeguard.instance.acceptUnstable && IrisSafeguard.instance.unstablemode) {
|
if (!IrisSafeguard.instance.acceptUnstable && IrisSafeguard.instance.unstablemode) {
|
||||||
Iris.info(C.RED + "World loading has been disabled until the incompatibility is resolved.");
|
Iris.info(C.RED + "World loading has been disabled until the incompatibility is resolved.");
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ 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
|
||||||
@@ -166,6 +167,7 @@ public class IrisSettings {
|
|||||||
public int spins = 7;
|
public int spins = 7;
|
||||||
public int spinb = 8;
|
public int spinb = 8;
|
||||||
public String cartographerMessage = "Iris does not allow cartographers in its world due to crashes.";
|
public String cartographerMessage = "Iris does not allow cartographers in its world due to crashes.";
|
||||||
|
public String[] dataPackPaths = new String[0];
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
|
|||||||
@@ -19,18 +19,20 @@
|
|||||||
package com.volmit.iris.core;
|
package com.volmit.iris.core;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
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.IrisBiome;
|
||||||
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
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 java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ServerConfigurator {
|
public class ServerConfigurator {
|
||||||
@@ -73,33 +75,50 @@ public class ServerConfigurator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<File> getDataPacksFolder() {
|
private static File[] getDataPacksFolder() {
|
||||||
if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) {
|
KList<File> files = new KList<>();
|
||||||
return new KList<File>().qadd(new File(Bukkit.getWorldContainer(), IrisSettings.get().getGeneral().forceMainWorld + "/datapacks"));
|
files.add(new File("plugins/Iris/datapack"));
|
||||||
}
|
Arrays.stream(IrisSettings.get().getGeneral().dataPackPaths)
|
||||||
KList<File> worlds = new KList<>();
|
.map(File::new)
|
||||||
Bukkit.getServer().getWorlds().forEach(w -> worlds.add(new File(w.getWorldFolder(), "datapacks")));
|
.forEach(files::add);
|
||||||
if (worlds.isEmpty()) {
|
return files.toArray(File[]::new);
|
||||||
worlds.add(new File(getMainWorldFolder(), "datapacks"));
|
|
||||||
}
|
|
||||||
return worlds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getMainWorldFolder() {
|
public static void setupDataPack() {
|
||||||
try {
|
File packs = new File("plugins/Iris/packs");
|
||||||
Properties prop = new Properties();
|
if (!packs.exists()) {
|
||||||
prop.load(new FileInputStream("server.properties"));
|
disableDataPack();
|
||||||
String world = prop.getProperty("level-name", "world");
|
return;
|
||||||
return new File(Bukkit.getWorldContainer(), world);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
for (File i : packs.listFiles()) {
|
||||||
|
if (!i.isDirectory()) continue;
|
||||||
|
|
||||||
|
Iris.verbose("Checking Pack: " + i.getPath());
|
||||||
|
IrisData data = IrisData.get(i);
|
||||||
|
File dims = new File(i, "dimensions");
|
||||||
|
|
||||||
|
if (dims.exists()) {
|
||||||
|
for (File j : dims.listFiles((f, s) -> s.endsWith(".json"))) {
|
||||||
|
if (!j.isFile()) continue;
|
||||||
|
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
|
||||||
|
if (dim == null) continue;
|
||||||
|
|
||||||
|
dim.getAllBiomes(() -> data)
|
||||||
|
.stream()
|
||||||
|
.map(IrisBiome::getCustomDerivitives)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.flatMap(KList::stream)
|
||||||
|
.forEach(b -> INMS.get().registerBiome(dim.getLoadKey(), b, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dumpDataPack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dumpDataPack() {
|
public static void dumpDataPack() {
|
||||||
if (!INMS.get().dumpRegistry(getDataPacksFolder().toArray(File[]::new)))
|
if (!INMS.get().dumpRegistry(getDataPacksFolder())) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
disableDataPack();
|
disableDataPack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -759,6 +759,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
@@ -802,6 +802,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
@@ -806,6 +806,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
@@ -804,6 +804,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
@@ -810,6 +810,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
@@ -817,6 +817,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
@@ -799,6 +799,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry
|
return registry
|
||||||
.registryKeySet()
|
.registryKeySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(id -> !id.location().getNamespace().equals("minecraft"))
|
||||||
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
.collect(Collectors.toMap(ResourceKey::location, id -> encode(codec, registry.get(id)).orElse(JsonNull.INSTANCE)));
|
||||||
} finally {
|
} finally {
|
||||||
changedRegistries.put(registryKey, false);
|
changedRegistries.put(registryKey, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user