Hotload datapacks on hotload (still needs restart)

This commit is contained in:
Daniel Mills 2021-07-16 00:15:13 -04:00
parent 2624315bd5
commit 695c4159dc
2 changed files with 14 additions and 9 deletions

View File

@ -82,11 +82,8 @@ public class Iris extends VolmitPlugin implements Listener {
installDataPacks();
}
private void installDataPacks() {
Iris.info("Checking Data Packs...");
boolean reboot = false;
File packs = new File("plugins/Iris/packs");
File dpacks = null;
public File getDatapacksFolder()
{
File props = new File("server.properties");
if (props.exists()) {
@ -95,8 +92,7 @@ public class Iris extends VolmitPlugin implements Listener {
for (String i : m) {
if (i.trim().startsWith("level-name=")) {
dpacks = new File(i.trim().split("\\Q=\\E")[1] + "/datapacks");
break;
return new File(i.trim().split("\\Q=\\E")[1] + "/datapacks");
}
}
} catch (IOException e) {
@ -105,12 +101,20 @@ public class Iris extends VolmitPlugin implements Listener {
}
}
return null;
}
private void installDataPacks() {
Iris.info("Checking Data Packs...");
boolean reboot = false;
File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if (dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
if (packs.exists()) {
for (File i : packs.listFiles()) {
if (i.isDirectory()) {

View File

@ -107,7 +107,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
try {
for (Player i : getTarget().getWorld().getPlayers()) {
new MortarSender(i, Iris.instance.getTag()).sendMessage("Dimension Hotloaded");
i.playSound(i.getLocation(), Sound.ITEM_BOTTLE_FILL, 1f, 1.25f);
i.playSound(i.getLocation(), Sound.BLOCK_BEACON_ACTIVATE, 1f, 1.25f);
}
} catch (Throwable e) {Iris.reportError(e);
@ -306,6 +306,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
populators.clear();
populators.addAll(compound.getPopulators());
hotloader = new ReactiveFolder(data.getDataFolder(), (a, c, d) -> hotload());
dim.installDataPack(() -> data, Iris.instance.getDatapacksFolder());
} catch (Throwable e) {Iris.reportError(e);
e.printStackTrace();
Iris.error("FAILED TO INITIALIZE DIMENSION FROM " + world.toString());