diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index b8fe7c06f..70f9fb6d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -295,7 +295,7 @@ public class ClipboardCommands extends MethodCommands { @Command(aliases = {"download"}, desc = "Downloads your clipboard through the configured web interface") @Deprecated @CommandPermissions({"worldedit.clipboard.download"}) - public void download(final Player player, final LocalSession session, @Optional("schematic") final String formatName) throws CommandException, WorldEditException { + public void download(final Player player, final LocalSession session, @Optional("schem") final String formatName) throws CommandException, WorldEditException { final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName); @@ -356,29 +356,23 @@ public class ClipboardCommands extends MethodCommands { } else { target = clipboard; } - switch (format.getName()) { - case "PNG": - try { - FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE); - ClipboardWriter writer = format.getWriter(baos); - writer.write(target); - baos.flush(); - url = ImgurUtility.uploadImage(baos.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - url = null; - } - break; - case "SCHEMATIC": - if (Settings.IMP.WEB.URL.isEmpty()) { - BBC.SETTING_DISABLE.send(player, "web.url"); - return; - } - url = FaweAPI.upload(target, format); - break; - default: + if (format == BuiltInClipboardFormat.PNG) { + try { + FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE); + ClipboardWriter writer = format.getWriter(baos); + writer.write(target); + baos.flush(); + url = ImgurUtility.uploadImage(baos.toByteArray()); + } catch (IOException e) { + e.printStackTrace(); url = null; - break; + } + } else { + if (Settings.IMP.WEB.URL.isEmpty()) { + BBC.SETTING_DISABLE.send(player, "web.url"); + return; + } + url = FaweAPI.upload(target, format); } if (url == null) { BBC.GENERATING_LINK_FAILED.send(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java index c6213806f..bb2729a09 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java @@ -176,7 +176,7 @@ public interface ClipboardFormat { } } } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java index cfabef4c5..ae1f2c15b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java @@ -178,7 +178,7 @@ public class ClipboardFormats { return null; } URL base = new URL(Settings.IMP.WEB.URL); - input = new URL(base, "uploads/" + input.substring(4) + ".schematic").toString(); + input = new URL(base, "uploads/" + input.substring(4) + "." + format.getPrimaryFileExtension()).toString(); } if (input.startsWith("http")) { if (!player.hasPermission("worldedit.schematic.load.asset")) {