Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final Random random = new Random();
- private static final Map<String, Structure> structures = Maps.newHashMap(); //put("test", new Structure(..., 3))
- private final JavaPlugin source;
- public void restructuring() { // /<command>
- for (Map.Entry<String, Structure> entry : structures.entrySet()) {
- final Location location = entry.getValue().pasteLocation;
- final String schematic = String.format("%s_%d.schematic", entry.getKey(), random.nextInt(entry.getValue().maxRandom));
- final File file = new File(source.getDataFolder(), schematic);
- Logging.info("file exists: " + file.exists()); //always true
- paste(file, location.getWorld(), new org.bukkit.util.Vector(location.getBlockX(), location.getBlockY(), location.getBlockX()));
- }
- }
- public static void paste(File file, org.bukkit.World bworld, org.bukkit.util.Vector vector) {
- try {
- Vector position = new Vector(vector.getX(), vector.getY(), vector.getZ());
- World world = FaweAPI.getWorld(bworld.getName());
- ClipboardFormat.SCHEMATIC.load(file).paste(world, position, true, false, (Transform) null);
- } catch (IOException e) {
- Logging.severe("Could not paste " + file.getName(), e);
- }
- }
- private static class Structure {
- private final Location pasteLocation;
- private final int maxRandom;
- Structure(Location pasteLocation, int maxRandom) {
- this.pasteLocation = pasteLocation;
- this.maxRandom = maxRandom;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement