diff --git a/core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java index 6a78dcc8..4ac3dcbc 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java @@ -12,8 +12,8 @@ import java.io.InputStream; public class FlattenBrush extends HeightBrush { - public FlattenBrush(InputStream stream, int rotation, double yscale, DoubleActionBrushTool tool, Clipboard clipboard) { - super(stream, rotation, yscale, tool, clipboard, ScalableHeightMap.Shape.CYLINDER); + public FlattenBrush(InputStream stream, int rotation, double yscale, DoubleActionBrushTool tool, Clipboard clipboard, ScalableHeightMap.Shape shape) { + super(stream, rotation, yscale, tool, clipboard, shape); } @Override diff --git a/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index bee8559c..1c9d2d45 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -34,6 +34,7 @@ import com.boydti.fawe.object.brush.HeightBrush; import com.boydti.fawe.object.brush.LineBrush; import com.boydti.fawe.object.brush.RecurseBrush; import com.boydti.fawe.object.brush.SplineBrush; +import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap; import com.boydti.fawe.object.mask.IdMask; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; @@ -366,44 +367,22 @@ public class BrushCommands { ) @CommandPermissions("worldedit.brush.height") public void heightBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - String filenamePng = (filename.endsWith(".png") ? filename : filename + ".png"); - File file = new File(Fawe.imp().getDirectory(), "heightmap" + File.separator + filenamePng); - InputStream stream = null; - if (!file.exists()) { - if (!filename.equals("#clipboard") && filename.length() >= 7) { - try { - URL url; - if (filename.startsWith("http")) { - url = new URL(filename); - if (!url.getHost().equals("i.imgur.com")) { - throw new FileNotFoundException(filename); - } - } else { - url = new URL("https://i.imgur.com/" + filenamePng); - } - ReadableByteChannel rbc = Channels.newChannel(url.openStream()); - stream = Channels.newInputStream(rbc); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } else if (!filename.equalsIgnoreCase("#clipboard")){ - try { - stream = new FileInputStream(file); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } + terrainBrush(player, session, radius, filename, rotation, yscale, true, ScalableHeightMap.Shape.CONE); + } - DoubleActionBrushTool tool = session.getDoubleActionBrushTool(player.getItemInHand()); - tool.setSize(radius); - try { - tool.setBrush(new HeightBrush(stream, rotation, yscale, tool, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null), "worldedit.brush.height"); - } catch (EmptyClipboardException ignore) { - tool.setBrush(new HeightBrush(stream, rotation, yscale, tool, null), "worldedit.brush.height"); - } - player.print(BBC.getPrefix() + BBC.BRUSH_HEIGHT.f(radius)); + @Command( + aliases = { "cliff", "flatcylinder" }, + usage = "[radius] [file|#clipboard|null] [rotation] [yscale]", + flags = "h", + desc = "Cliff brush", + help = + "This brush flattens terrain and creates cliffs.\n", + min = 1, + max = 4 + ) + @CommandPermissions("worldedit.brush.height") + public void cliffBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale) throws WorldEditException { + terrainBrush(player, session, radius, filename, rotation, yscale, true, ScalableHeightMap.Shape.CYLINDER); } @Command( @@ -418,6 +397,10 @@ public class BrushCommands { ) @CommandPermissions("worldedit.brush.height") public void flattenBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale) throws WorldEditException { + terrainBrush(player, session, radius, filename, rotation, yscale, true, ScalableHeightMap.Shape.CONE); + } + + private void terrainBrush(Player player, LocalSession session, double radius, String filename, int rotation, double yscale, boolean flat, ScalableHeightMap.Shape shape) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); String filenamePng = (filename.endsWith(".png") ? filename : filename + ".png"); File file = new File(Fawe.imp().getDirectory(), "heightmap" + File.separator + filenamePng); @@ -450,14 +433,24 @@ public class BrushCommands { DoubleActionBrushTool tool = session.getDoubleActionBrushTool(player.getItemInHand()); tool.setSize(radius); - try { - tool.setBrush(new FlattenBrush(stream, rotation, yscale, tool, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null), "worldedit.brush.height"); - } catch (EmptyClipboardException ignore) { - tool.setBrush(new FlattenBrush(stream, rotation, yscale, tool, null), "worldedit.brush.height"); + if (flat) { + try { + tool.setBrush(new FlattenBrush(stream, rotation, yscale, tool, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null, shape), "worldedit.brush.height"); + } catch (EmptyClipboardException ignore) { + tool.setBrush(new FlattenBrush(stream, rotation, yscale, tool, null, shape), "worldedit.brush.height"); + } + } else { + try { + tool.setBrush(new HeightBrush(stream, rotation, yscale, tool, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null), "worldedit.brush.height"); + } catch (EmptyClipboardException ignore) { + tool.setBrush(new HeightBrush(stream, rotation, yscale, tool, null), "worldedit.brush.height"); + } } player.print(BBC.getPrefix() + BBC.BRUSH_HEIGHT.f(radius)); } + + @Command( aliases = { "copypaste", "copy", "paste", "cp", "copypasta" }, usage = "[depth]",