mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Fix clipboard upload/download
This commit is contained in:
parent
7c54f16d43
commit
f849caf655
@ -295,7 +295,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
@Command(aliases = {"download"}, desc = "Downloads your clipboard through the configured web interface")
|
@Command(aliases = {"download"}, desc = "Downloads your clipboard through the configured web interface")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({"worldedit.clipboard.download"})
|
@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);
|
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName);
|
BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName);
|
||||||
@ -356,8 +356,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
} else {
|
} else {
|
||||||
target = clipboard;
|
target = clipboard;
|
||||||
}
|
}
|
||||||
switch (format.getName()) {
|
if (format == BuiltInClipboardFormat.PNG) {
|
||||||
case "PNG":
|
|
||||||
try {
|
try {
|
||||||
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE);
|
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE);
|
||||||
ClipboardWriter writer = format.getWriter(baos);
|
ClipboardWriter writer = format.getWriter(baos);
|
||||||
@ -368,17 +367,12 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
url = null;
|
url = null;
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
case "SCHEMATIC":
|
|
||||||
if (Settings.IMP.WEB.URL.isEmpty()) {
|
if (Settings.IMP.WEB.URL.isEmpty()) {
|
||||||
BBC.SETTING_DISABLE.send(player, "web.url");
|
BBC.SETTING_DISABLE.send(player, "web.url");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
url = FaweAPI.upload(target, format);
|
url = FaweAPI.upload(target, format);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
url = null;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
BBC.GENERATING_LINK_FAILED.send(player);
|
BBC.GENERATING_LINK_FAILED.send(player);
|
||||||
|
@ -176,7 +176,7 @@ public interface ClipboardFormat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ public class ClipboardFormats {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
URL base = new URL(Settings.IMP.WEB.URL);
|
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 (input.startsWith("http")) {
|
||||||
if (!player.hasPermission("worldedit.schematic.load.asset")) {
|
if (!player.hasPermission("worldedit.schematic.load.asset")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user