diff --git a/build.gradle b/build.gradle index 65edfcc8..abf88836 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ ext { version = date + revision + buildNumber if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion - version = ""; + version = "unknown"; } description = """FastAsyncWorldEdit""" diff --git a/bukkit110/src/main/resources/plugin.yml b/bukkit110/src/main/resources/plugin.yml index e8caa71c..86452c4c 100644 --- a/bukkit110/src/main/resources/plugin.yml +++ b/bukkit110/src/main/resources/plugin.yml @@ -25,6 +25,6 @@ permissions: fawe.bypass: default: false fawe.admin: - default: false + default: op fawe.reload: default: false \ No newline at end of file diff --git a/bukkit1710/src/main/resources/plugin.yml b/bukkit1710/src/main/resources/plugin.yml index c8e333dd..1154dc8c 100644 --- a/bukkit1710/src/main/resources/plugin.yml +++ b/bukkit1710/src/main/resources/plugin.yml @@ -25,6 +25,6 @@ permissions: fawe.bypass: default: false fawe.admin: - default: false + default: op fawe.reload: default: false diff --git a/bukkit18/src/main/resources/plugin.yml b/bukkit18/src/main/resources/plugin.yml index 8153fc66..a652f1d0 100644 --- a/bukkit18/src/main/resources/plugin.yml +++ b/bukkit18/src/main/resources/plugin.yml @@ -25,6 +25,6 @@ permissions: fawe.bypass: default: false fawe.admin: - default: false + default: op fawe.reload: default: false diff --git a/bukkit19/src/main/resources/plugin.yml b/bukkit19/src/main/resources/plugin.yml index b3ff5a46..1613b081 100644 --- a/bukkit19/src/main/resources/plugin.yml +++ b/bukkit19/src/main/resources/plugin.yml @@ -28,8 +28,6 @@ permissions: fawe.bypass: default: false fawe.admin: - default: false - fawe.fixlighting: - default: false + default: op fawe.reload: default: false \ No newline at end of file diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java index ad04f8e4..771c9fde 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java @@ -2,7 +2,6 @@ package com.boydti.fawe.jnbt.anvil; import com.boydti.fawe.example.CharFaweChunk; import com.boydti.fawe.example.NMSMappedFaweQueue; -import com.boydti.fawe.example.NullFaweChunk; import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.RunnableVal; @@ -132,14 +131,18 @@ public class MCAQueue extends NMSMappedFaweQueue> 1; raf.seek(2); - last = -1; + last = Integer.MIN_VALUE; width = (int) raf.readChar(); height = (int) raf.readChar(); length = (int) raf.readChar(); @@ -93,7 +93,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { open(); } raf.seek(8); - last = -1; + last = Integer.MIN_VALUE; int ox = raf.readShort(); int oy = raf.readShort(); int oz = raf.readShort(); @@ -119,8 +119,12 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { try { if (!file.exists()) { file.getParentFile().mkdirs(); + file.createNewFile(); + } else { + PrintWriter writer = new PrintWriter(file); + writer.print(""); + writer.close(); } - file.createNewFile(); } catch (Exception e) { MainUtil.handleError(e); } @@ -133,7 +137,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { open(); } raf.seek(8); - last = -1; + last = Integer.MIN_VALUE; raf.writeShort(offset.getBlockX()); raf.writeShort(offset.getBlockY()); raf.writeShort(offset.getBlockZ()); @@ -154,7 +158,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { long size = width * height * length * 2l + HEADER_SIZE; raf.setLength(size); raf.seek(2); - last = -1; + last = Integer.MIN_VALUE; raf.writeChar(width); raf.writeChar(height); raf.writeChar(length); @@ -181,6 +185,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { public void close() { try { + raf.flush(); RandomAccessFile tmp = raf; raf = null; tmp.close(); @@ -202,7 +207,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { raf.setLength(size); // write length etc raf.seek(2); - last = -1; + last = Integer.MIN_VALUE; raf.writeChar(width); raf.writeChar(height); raf.writeChar(length); @@ -211,18 +216,18 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { } private void autoCloseTask() { - TaskManager.IMP.laterAsync(new Runnable() { - @Override - public void run() { - if (raf != null && System.currentTimeMillis() - lastAccessed > 10000) { - close(); - } else if (raf == null) { - return; - } else { - TaskManager.IMP.laterAsync(this, 200); - } - } - }, 200); +// TaskManager.IMP.laterAsync(new Runnable() { +// @Override +// public void run() { +// if (raf != null && System.currentTimeMillis() - lastAccessed > 10000) { +// close(); +// } else if (raf == null) { +// return; +// } else { +// TaskManager.IMP.laterAsync(this, 200); +// } +// } +// }, 200); } private int ylast; @@ -344,9 +349,12 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { lastAccessed = System.currentTimeMillis(); } last = i; - int combined = FaweCache.getData(raf.readChar()) + (id << 4); - raf.seekUnsafe(raf.getFilePointer() - 2); - raf.writeChar(combined); + // 00000000 00000000 + // [ id ]data + int id1 = raf.readCurrent(); + raf.write(id >> 4); + int id2 = raf.readCurrent(); + raf.write(((id & 0xFF) << 4) + (id2 & 0xFF)); } catch (Exception e) { MainUtil.handleError(e); } @@ -379,9 +387,10 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { lastAccessed = System.currentTimeMillis(); } last = i; - int combined = raf.readChar() + (add << 4); - raf.seekUnsafe(raf.getFilePointer() - 2); - raf.writeChar(combined); + // 00000000 00000000 + // [ id ]data + raf.write((raf.readCurrent() & 0xFF) + (add >> 4)); + raf.read1(); } catch (Exception e) { MainUtil.handleError(e); } @@ -398,9 +407,11 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { lastAccessed = System.currentTimeMillis(); } last = i; - int combined = (FaweCache.getId(raf.readChar()) << 4) + data; - raf.seekUnsafe(raf.getFilePointer() - 2); - raf.writeChar(combined); + // 00000000 00000000 + // [ id ]data + int id1 = raf.read1(); + int id2 = raf.readCurrent(); + raf.write((id2 & 0xF0) + data); } catch (Exception e) { MainUtil.handleError(e); } diff --git a/core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java b/core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java index 55c83140..a710436a 100644 --- a/core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java +++ b/core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java @@ -244,30 +244,30 @@ public class BufferedRandomAccessFile extends RandomAccessFile this.curr_ = pos; } - /* - * Seek and do not flush if within the current buffer when going backwards - * - Assumes no writes were made - * @param pos - * @throws IOException - */ - public void seekUnsafe(long pos) throws IOException - { - if (pos >= this.hi_ || pos < this.lo_) - { - // seeking outside of current buffer -- flush and read - this.flushBuffer(); - this.lo_ = pos & BuffMask_; // start at BuffSz boundary - this.maxHi_ = this.lo_ + (long) this.buff_.length; - if (this.diskPos_ != this.lo_) - { - super.seek(this.lo_); - this.diskPos_ = this.lo_; - } - int n = this.fillBuffer(); - this.hi_ = this.lo_ + (long) n; - } - this.curr_ = pos; - } +// /* +// * Seek and do not flush if within the current buffer when going backwards +// * - Assumes no writes were made +// * @param pos +// * @throws IOException +// */ +// public void seekUnsafe(long pos) throws IOException +// { +// if (pos >= this.hi_ || pos < this.lo_) +// { +// // seeking outside of current buffer -- flush and read +// this.flushBuffer(); +// this.lo_ = pos & BuffMask_; // start at BuffSz boundary +// this.maxHi_ = this.lo_ + (long) this.buff_.length; +// if (this.diskPos_ != this.lo_) +// { +// super.seek(this.lo_); +// this.diskPos_ = this.lo_; +// } +// int n = this.fillBuffer(); +// this.hi_ = this.lo_ + (long) n; +// } +// this.curr_ = pos; +// } public long getFilePointer() { @@ -341,6 +341,46 @@ public class BufferedRandomAccessFile extends RandomAccessFile return len; } + public byte readCurrent() throws IOException { + if (this.curr_ >= this.hi_) + { + // test for EOF + // if (this.hi < this.maxHi) return -1; + if (this.hitEOF_) + return -1; + + // slow path -- read another buffer + this.seek(this.curr_); + if (this.curr_ == this.hi_) + return -1; + } + byte res = this.buff_[(int) (this.curr_ - this.lo_)]; + return res; + } + + public void writeCurrent(byte b) throws IOException { + if (this.curr_ >= this.hi_) + { + if (this.hitEOF_ && this.hi_ < this.maxHi_) + { + // at EOF -- bump "hi" + this.hi_++; + } + else + { + // slow path -- write current buffer; read next one + this.seek(this.curr_); + if (this.curr_ == this.hi_) + { + // appending to EOF -- bump "hi" + this.hi_++; + } + } + } + this.buff_[(int) (this.curr_ - this.lo_)] = (byte) b; + this.dirty_ = true; + } + public void write(int b) throws IOException { if (this.curr_ >= this.hi_) diff --git a/core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java b/core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java index 012f406a..abb9f1f3 100644 --- a/core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java +++ b/core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java @@ -100,7 +100,7 @@ public class Schematic { if (allowUndo) { editSession = builder.build(); } else { - editSession = builder.changeSetNull().build(); + editSession = builder.changeSetNull().fastmode(true).build(); } Extent extent = clipboard; if (transform != null) { diff --git a/core/src/main/java/com/sk89q/worldedit/EditSession.java b/core/src/main/java/com/sk89q/worldedit/EditSession.java index 7b60d3de..75c4eb73 100644 --- a/core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -436,9 +436,16 @@ public class EditSession implements Extent { } } if (Settings.EXTENT.DEBUG) { - Fawe.debug("&cPotentially inefficient WorldEdit extent: " + toReturn.getClass().getName()); + Fawe.debug("&cPotentially unsafe extent blocked: " + toReturn.getClass().getName()); Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI"); + Fawe.debug("&8 - &7For block logging, it is recommended to use use BlocksHub"); Fawe.debug("&8 - &7To allow this plugin add it to the FAWE `allowed-plugins` list"); + Fawe.debug("&8 - &7To hide this message set `debug` to false in the config.yml"); + if (toReturn.getClass().getName().contains("CoreProtect")) { + Fawe.debug("Note on CoreProtect: "); + Fawe.debug(" - If you disable CoreProtect's WorldEdit logger (CP config) it still tries to add it (CP bug?)"); + Fawe.debug(" - Use BlocksHub and set `debug` false in the FAWE config"); + } } } return extent;