diff --git a/src/main/java/com/alpsbte/plotsystem/core/system/plot/PlotHandler.java b/src/main/java/com/alpsbte/plotsystem/core/system/plot/PlotHandler.java index 0f8d1b56..675fc9fc 100644 --- a/src/main/java/com/alpsbte/plotsystem/core/system/plot/PlotHandler.java +++ b/src/main/java/com/alpsbte/plotsystem/core/system/plot/PlotHandler.java @@ -191,8 +191,8 @@ public static Location getPlotSpawnPoint(Plot plot) { (double) (PlotManager.getPlotSize(plot) / 2) + 0.5, -90, 90); - // Set spawn point 3 blocks above the highest center point - spawnLocation.setY(plot.getPlotWorld().getHighestBlockYAt((int) spawnLocation.getX(), (int) spawnLocation.getZ())); + // Set spawn point 1 block above the highest center point + spawnLocation.setY(plot.getPlotWorld().getHighestBlockYAt((int) spawnLocation.getX(), (int) spawnLocation.getZ()) + 1); return spawnLocation; } diff --git a/src/main/java/com/alpsbte/plotsystem/core/system/plot/generator/AbstractPlotGenerator.java b/src/main/java/com/alpsbte/plotsystem/core/system/plot/generator/AbstractPlotGenerator.java index 3751fbe7..0fbc0cd1 100644 --- a/src/main/java/com/alpsbte/plotsystem/core/system/plot/generator/AbstractPlotGenerator.java +++ b/src/main/java/com/alpsbte/plotsystem/core/system/plot/generator/AbstractPlotGenerator.java @@ -63,8 +63,8 @@ public AbstractPlotGenerator(@NotNull Plot plot, @NotNull Builder builder) { this.plot = plot; this.builder = builder; - CompletableFuture a = configureWorldGeneration(), b = generateWorld(), c = configureWorld(worldManager.getMVWorld(plot.getPlotWorld())), - d = generateOutlines(plot.getOutlinesSchematic()), e = createProtection(); + CompletableFuture a = configureWorldGeneration(), b = generateWorld(), c = generateOutlines(plot.getOutlinesSchematic()), + d = configureWorld(worldManager.getMVWorld(plot.getPlotWorld())), e = createProtection(); // TODO: Improve exceptions CompletableFuture plotGen = CompletableFuture.allOf(a, b, c, d, e); @@ -116,6 +116,35 @@ protected CompletableFuture generateWorld() { return CompletableFuture.completedFuture(true); } + /** + * Generates plot schematic and outlines + * @param plotSchematic - schematic file + * @return - true if generation was successful + */ + protected CompletableFuture generateOutlines(File plotSchematic) { + try { + if (plotSchematic != null) { + Vector buildingOutlinesCoordinates = PlotManager.getPlotCenter(plot); + + com.sk89q.worldedit.world.World weWorld = new BukkitWorld(plot.getPlotWorld()); + Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(plotSchematic)).read(weWorld.getWorldData()); + clipboard.setOrigin(clipboard.getOrigin().setY(clipboard.getMinimumPoint().getY())); // Set origin point to the center bottom of the schematic + + ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard, weWorld.getWorldData()); + EditSession editSession = PlotSystem.DependencyManager.getWorldEdit().getEditSessionFactory().getEditSession(weWorld, -1); + + Operation operation = clipboardHolder.createPaste(editSession, weWorld.getWorldData()).to(buildingOutlinesCoordinates).ignoreAirBlocks(false).build(); + Operations.complete(operation); + editSession.flushQueue(); + + return CompletableFuture.completedFuture(true); + } + } catch (IOException | WorldEditException ex) { + return CompletableFuture.completedFuture(false); + } + return CompletableFuture.completedFuture(false); + } + /** * Configures plot world * @param mvWorld - plot world @@ -142,39 +171,11 @@ protected CompletableFuture configureWorld(@NotNull MultiverseWorld mvW mvWorld.setAllowMonsterSpawn(false); mvWorld.setAutoLoad(false); mvWorld.setKeepSpawnInMemory(false); + mvWorld.setSpawnLocation(PlotHandler.getPlotSpawnPoint(getPlot())); return CompletableFuture.completedFuture(true); } - /** - * Generates plot schematic and outlines - * @param plotSchematic - schematic file - * @return - true if generation was successful - */ - protected CompletableFuture generateOutlines(File plotSchematic) { - try { - if (plotSchematic != null) { - Vector buildingOutlinesCoordinates = PlotManager.getPlotCenter(plot); - - com.sk89q.worldedit.world.World weWorld = new BukkitWorld(plot.getPlotWorld()); - Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(plotSchematic)).read(weWorld.getWorldData()); - clipboard.setOrigin(clipboard.getOrigin().setY(clipboard.getMinimumPoint().getY())); // Set origin point to the center bottom of the schematic - - ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard, weWorld.getWorldData()); - EditSession editSession = PlotSystem.DependencyManager.getWorldEdit().getEditSessionFactory().getEditSession(weWorld, -1); - - Operation operation = clipboardHolder.createPaste(editSession, weWorld.getWorldData()).to(buildingOutlinesCoordinates).ignoreAirBlocks(false).build(); - Operations.complete(operation); - editSession.flushQueue(); - - return CompletableFuture.completedFuture(true); - } - } catch (IOException | WorldEditException ex) { - return CompletableFuture.completedFuture(false); - } - return CompletableFuture.completedFuture(false); - } - /** * Creates plot protection * @return - true if protection was created successful