mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-12-04 13:33:35 +01:00
Load all known templates when loading.
This commit is contained in:
parent
4ea09eab68
commit
c30841440b
@ -30,7 +30,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.loot.LootTables;
|
import org.bukkit.loot.LootTables;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.bukkit.structure.Structure;
|
import org.bukkit.structure.Structure;
|
||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -66,8 +65,6 @@ public class NewAreaListener implements Listener {
|
|||||||
private record Item(String name, Structure structure, Location location, StructureRotation rot, Mirror mirror) {};
|
private record Item(String name, Structure structure, Location location, StructureRotation rot, Mirror mirror) {};
|
||||||
Pair<Integer, Integer> min = new Pair<Integer, Integer>(0,0);
|
Pair<Integer, Integer> min = new Pair<Integer, Integer>(0,0);
|
||||||
Pair<Integer, Integer> max = new Pair<Integer, Integer>(0,0);
|
Pair<Integer, Integer> max = new Pair<Integer, Integer>(0,0);
|
||||||
private BukkitTask task;
|
|
||||||
private int i;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,31 +90,22 @@ public class NewAreaListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workaround for https://hub.spigotmc.org/jira/browse/SPIGOT-7288
|
* Build a list of structures
|
||||||
* @param event event
|
* @param event event
|
||||||
*/
|
*/
|
||||||
@EventHandler()
|
@EventHandler()
|
||||||
public void onBentoBoxReady(BentoBoxReadyEvent event) {
|
public void onBentoBoxReady(BentoBoxReadyEvent event) {
|
||||||
World seedBase = Bukkit.getWorld("seed_base");
|
addon.saveResource("templates.yml", false);
|
||||||
if (seedBase == null) {
|
|
||||||
addon.logError("No seed base world!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
File templateFile = new File(addon.getDataFolder(), "templates.yml");
|
File templateFile = new File(addon.getDataFolder(), "templates.yml");
|
||||||
if (templateFile.exists()) {
|
if (templateFile.exists()) {
|
||||||
YamlConfiguration loader = YamlConfiguration.loadConfiguration(templateFile);
|
YamlConfiguration loader = YamlConfiguration.loadConfiguration(templateFile);
|
||||||
List<String> list = loader.getStringList("templates");
|
List<String> list = loader.getStringList("templates");
|
||||||
task = Bukkit.getScheduler().runTaskTimer(addon.getPlugin(), () -> {
|
for (String struct : list) {
|
||||||
if (i == list.size()) {
|
Structure s = Bukkit.getStructureManager().loadStructure(NamespacedKey.fromString(struct));
|
||||||
task.cancel();
|
if (s == null) {
|
||||||
return;
|
BentoBox.getInstance().log("Now loading group from: " + struct);
|
||||||
}
|
}
|
||||||
String struct = list.get(i++);
|
}
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "execute in " + seedBase.getName() + " run place template " + struct + " 10000 120 10000");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, 0, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1045
src/main/resources/templates.yml
Normal file
1045
src/main/resources/templates.yml
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user