diff --git a/Clipboard-API.md b/Clipboard-API.md new file mode 100644 index 0000000..23fc589 --- /dev/null +++ b/Clipboard-API.md @@ -0,0 +1,40 @@ +With FAWE installed, you can register a new ClipboardFormat through the API +```Java +ClipboardFormat.addFormat(new AbstractClipboardFormat("FAWE", "fawe") { + @Override + public ClipboardReader getReader(InputStream inputStream) throws IOException { + return new FaweFormat(MainUtil.getCompressedIS(inputStream)); + } + + @Override + public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { + return getWriter(outputStream, 8); + } + + @Override + public boolean isFormat(File file) { + return file.getName().endsWith(".fawe") || file.getName().endsWith(".bd"); + } + + @Override + public String getExtension() { + return "fawe"; + } + + public ClipboardWriter getWriter(OutputStream os, int compression) throws IOException { + FaweFormat writer = new FaweFormat(new FaweOutputStream(os)); + writer.compress(compression); + return writer; + } + + public DiskOptimizedClipboard getUncompressedReadWrite(File file) throws IOException { + return new DiskOptimizedClipboard(file); + } + + public DiskOptimizedClipboard createUncompressedReadWrite(int width, int height, int length, File file) { + return new DiskOptimizedClipboard(width, height, length, file); + } +}); +``` + +The format will then be usable ingame: `//schem load `