Fixes #253 + other stuff
Fixes clipboard on disk Fixed hybrid MCAQueue hybrid get (tile/block/refresh) Fixed no NMS queue messages
This commit is contained in:
parent
f538fc5898
commit
814ac60823
@ -33,7 +33,7 @@ ext {
|
|||||||
|
|
||||||
version = date + revision + buildNumber
|
version = date + revision + buildNumber
|
||||||
if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion
|
if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion
|
||||||
version = "";
|
version = "unknown";
|
||||||
}
|
}
|
||||||
description = """FastAsyncWorldEdit"""
|
description = """FastAsyncWorldEdit"""
|
||||||
|
|
||||||
|
@ -25,6 +25,6 @@ permissions:
|
|||||||
fawe.bypass:
|
fawe.bypass:
|
||||||
default: false
|
default: false
|
||||||
fawe.admin:
|
fawe.admin:
|
||||||
default: false
|
default: op
|
||||||
fawe.reload:
|
fawe.reload:
|
||||||
default: false
|
default: false
|
@ -25,6 +25,6 @@ permissions:
|
|||||||
fawe.bypass:
|
fawe.bypass:
|
||||||
default: false
|
default: false
|
||||||
fawe.admin:
|
fawe.admin:
|
||||||
default: false
|
default: op
|
||||||
fawe.reload:
|
fawe.reload:
|
||||||
default: false
|
default: false
|
||||||
|
@ -25,6 +25,6 @@ permissions:
|
|||||||
fawe.bypass:
|
fawe.bypass:
|
||||||
default: false
|
default: false
|
||||||
fawe.admin:
|
fawe.admin:
|
||||||
default: false
|
default: op
|
||||||
fawe.reload:
|
fawe.reload:
|
||||||
default: false
|
default: false
|
||||||
|
@ -28,8 +28,6 @@ permissions:
|
|||||||
fawe.bypass:
|
fawe.bypass:
|
||||||
default: false
|
default: false
|
||||||
fawe.admin:
|
fawe.admin:
|
||||||
default: false
|
default: op
|
||||||
fawe.fixlighting:
|
|
||||||
default: false
|
|
||||||
fawe.reload:
|
fawe.reload:
|
||||||
default: false
|
default: false
|
@ -2,7 +2,6 @@ package com.boydti.fawe.jnbt.anvil;
|
|||||||
|
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||||
import com.boydti.fawe.example.NullFaweChunk;
|
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
@ -132,14 +131,18 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshChunk(FaweChunk fs) {
|
public void refreshChunk(FaweChunk fs) {
|
||||||
if (parent != null && !(fs instanceof MCAChunk) && !(fs instanceof NullFaweChunk) && parent instanceof NMSMappedFaweQueue) {
|
if (fs.getClass() != MCAChunk.class) {
|
||||||
((NMSMappedFaweQueue) parent).refreshChunk(fs);
|
parentNMS.refreshChunk(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTileEntity(FaweChunk sections, int x, int y, int z) {
|
public CompoundTag getTileEntity(FaweChunk sections, int x, int y, int z) {
|
||||||
|
if (sections.getClass() == MCAChunk.class) {
|
||||||
return sections.getTile(x, y, z);
|
return sections.getTile(x, y, z);
|
||||||
|
} else {
|
||||||
|
return parentNMS.getTileEntity(x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,7 +190,11 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCombinedId4Data(FaweChunk sections, int x, int y, int z) {
|
public int getCombinedId4Data(FaweChunk sections, int x, int y, int z) {
|
||||||
|
if (sections.getClass() == MCAChunk.class) {
|
||||||
return sections.getBlockCombinedId(x, y, z);
|
return sections.getBlockCombinedId(x, y, z);
|
||||||
|
} else {
|
||||||
|
return parentNMS.getCombinedId4Data(x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,11 +3,10 @@ package com.boydti.fawe.object.clipboard;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.io.BufferedRandomAccessFile;
|
|
||||||
import com.boydti.fawe.object.IntegerTrio;
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
import com.boydti.fawe.object.RunnableVal2;
|
import com.boydti.fawe.object.RunnableVal2;
|
||||||
|
import com.boydti.fawe.object.io.BufferedRandomAccessFile;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -21,6 +20,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -68,7 +68,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
raf.setLength(file.length());
|
raf.setLength(file.length());
|
||||||
long size = (raf.length() - HEADER_SIZE) >> 1;
|
long size = (raf.length() - HEADER_SIZE) >> 1;
|
||||||
raf.seek(2);
|
raf.seek(2);
|
||||||
last = -1;
|
last = Integer.MIN_VALUE;
|
||||||
width = (int) raf.readChar();
|
width = (int) raf.readChar();
|
||||||
height = (int) raf.readChar();
|
height = (int) raf.readChar();
|
||||||
length = (int) raf.readChar();
|
length = (int) raf.readChar();
|
||||||
@ -93,7 +93,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
raf.seek(8);
|
raf.seek(8);
|
||||||
last = -1;
|
last = Integer.MIN_VALUE;
|
||||||
int ox = raf.readShort();
|
int ox = raf.readShort();
|
||||||
int oy = raf.readShort();
|
int oy = raf.readShort();
|
||||||
int oz = raf.readShort();
|
int oz = raf.readShort();
|
||||||
@ -119,8 +119,12 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
try {
|
try {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
}
|
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
} else {
|
||||||
|
PrintWriter writer = new PrintWriter(file);
|
||||||
|
writer.print("");
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
@ -133,7 +137,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
raf.seek(8);
|
raf.seek(8);
|
||||||
last = -1;
|
last = Integer.MIN_VALUE;
|
||||||
raf.writeShort(offset.getBlockX());
|
raf.writeShort(offset.getBlockX());
|
||||||
raf.writeShort(offset.getBlockY());
|
raf.writeShort(offset.getBlockY());
|
||||||
raf.writeShort(offset.getBlockZ());
|
raf.writeShort(offset.getBlockZ());
|
||||||
@ -154,7 +158,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
long size = width * height * length * 2l + HEADER_SIZE;
|
long size = width * height * length * 2l + HEADER_SIZE;
|
||||||
raf.setLength(size);
|
raf.setLength(size);
|
||||||
raf.seek(2);
|
raf.seek(2);
|
||||||
last = -1;
|
last = Integer.MIN_VALUE;
|
||||||
raf.writeChar(width);
|
raf.writeChar(width);
|
||||||
raf.writeChar(height);
|
raf.writeChar(height);
|
||||||
raf.writeChar(length);
|
raf.writeChar(length);
|
||||||
@ -181,6 +185,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
|
raf.flush();
|
||||||
RandomAccessFile tmp = raf;
|
RandomAccessFile tmp = raf;
|
||||||
raf = null;
|
raf = null;
|
||||||
tmp.close();
|
tmp.close();
|
||||||
@ -202,7 +207,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
raf.setLength(size);
|
raf.setLength(size);
|
||||||
// write length etc
|
// write length etc
|
||||||
raf.seek(2);
|
raf.seek(2);
|
||||||
last = -1;
|
last = Integer.MIN_VALUE;
|
||||||
raf.writeChar(width);
|
raf.writeChar(width);
|
||||||
raf.writeChar(height);
|
raf.writeChar(height);
|
||||||
raf.writeChar(length);
|
raf.writeChar(length);
|
||||||
@ -211,18 +216,18 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void autoCloseTask() {
|
private void autoCloseTask() {
|
||||||
TaskManager.IMP.laterAsync(new Runnable() {
|
// TaskManager.IMP.laterAsync(new Runnable() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
if (raf != null && System.currentTimeMillis() - lastAccessed > 10000) {
|
// if (raf != null && System.currentTimeMillis() - lastAccessed > 10000) {
|
||||||
close();
|
// close();
|
||||||
} else if (raf == null) {
|
// } else if (raf == null) {
|
||||||
return;
|
// return;
|
||||||
} else {
|
// } else {
|
||||||
TaskManager.IMP.laterAsync(this, 200);
|
// TaskManager.IMP.laterAsync(this, 200);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, 200);
|
// }, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int ylast;
|
private int ylast;
|
||||||
@ -344,9 +349,12 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
lastAccessed = System.currentTimeMillis();
|
lastAccessed = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
last = i;
|
last = i;
|
||||||
int combined = FaweCache.getData(raf.readChar()) + (id << 4);
|
// 00000000 00000000
|
||||||
raf.seekUnsafe(raf.getFilePointer() - 2);
|
// [ id ]data
|
||||||
raf.writeChar(combined);
|
int id1 = raf.readCurrent();
|
||||||
|
raf.write(id >> 4);
|
||||||
|
int id2 = raf.readCurrent();
|
||||||
|
raf.write(((id & 0xFF) << 4) + (id2 & 0xFF));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
@ -379,9 +387,10 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
lastAccessed = System.currentTimeMillis();
|
lastAccessed = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
last = i;
|
last = i;
|
||||||
int combined = raf.readChar() + (add << 4);
|
// 00000000 00000000
|
||||||
raf.seekUnsafe(raf.getFilePointer() - 2);
|
// [ id ]data
|
||||||
raf.writeChar(combined);
|
raf.write((raf.readCurrent() & 0xFF) + (add >> 4));
|
||||||
|
raf.read1();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
@ -398,9 +407,11 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
lastAccessed = System.currentTimeMillis();
|
lastAccessed = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
last = i;
|
last = i;
|
||||||
int combined = (FaweCache.getId(raf.readChar()) << 4) + data;
|
// 00000000 00000000
|
||||||
raf.seekUnsafe(raf.getFilePointer() - 2);
|
// [ id ]data
|
||||||
raf.writeChar(combined);
|
int id1 = raf.read1();
|
||||||
|
int id2 = raf.readCurrent();
|
||||||
|
raf.write((id2 & 0xF0) + data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
|
@ -244,30 +244,30 @@ public class BufferedRandomAccessFile extends RandomAccessFile
|
|||||||
this.curr_ = pos;
|
this.curr_ = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// /*
|
||||||
* Seek and do not flush if within the current buffer when going backwards
|
// * Seek and do not flush if within the current buffer when going backwards
|
||||||
* - Assumes no writes were made
|
// * - Assumes no writes were made
|
||||||
* @param pos
|
// * @param pos
|
||||||
* @throws IOException
|
// * @throws IOException
|
||||||
*/
|
// */
|
||||||
public void seekUnsafe(long pos) throws IOException
|
// public void seekUnsafe(long pos) throws IOException
|
||||||
{
|
// {
|
||||||
if (pos >= this.hi_ || pos < this.lo_)
|
// if (pos >= this.hi_ || pos < this.lo_)
|
||||||
{
|
// {
|
||||||
// seeking outside of current buffer -- flush and read
|
// // seeking outside of current buffer -- flush and read
|
||||||
this.flushBuffer();
|
// this.flushBuffer();
|
||||||
this.lo_ = pos & BuffMask_; // start at BuffSz boundary
|
// this.lo_ = pos & BuffMask_; // start at BuffSz boundary
|
||||||
this.maxHi_ = this.lo_ + (long) this.buff_.length;
|
// this.maxHi_ = this.lo_ + (long) this.buff_.length;
|
||||||
if (this.diskPos_ != this.lo_)
|
// if (this.diskPos_ != this.lo_)
|
||||||
{
|
// {
|
||||||
super.seek(this.lo_);
|
// super.seek(this.lo_);
|
||||||
this.diskPos_ = this.lo_;
|
// this.diskPos_ = this.lo_;
|
||||||
}
|
// }
|
||||||
int n = this.fillBuffer();
|
// int n = this.fillBuffer();
|
||||||
this.hi_ = this.lo_ + (long) n;
|
// this.hi_ = this.lo_ + (long) n;
|
||||||
}
|
// }
|
||||||
this.curr_ = pos;
|
// this.curr_ = pos;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public long getFilePointer()
|
public long getFilePointer()
|
||||||
{
|
{
|
||||||
@ -341,6 +341,46 @@ public class BufferedRandomAccessFile extends RandomAccessFile
|
|||||||
return len;
|
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
|
public void write(int b) throws IOException
|
||||||
{
|
{
|
||||||
if (this.curr_ >= this.hi_)
|
if (this.curr_ >= this.hi_)
|
||||||
|
@ -100,7 +100,7 @@ public class Schematic {
|
|||||||
if (allowUndo) {
|
if (allowUndo) {
|
||||||
editSession = builder.build();
|
editSession = builder.build();
|
||||||
} else {
|
} else {
|
||||||
editSession = builder.changeSetNull().build();
|
editSession = builder.changeSetNull().fastmode(true).build();
|
||||||
}
|
}
|
||||||
Extent extent = clipboard;
|
Extent extent = clipboard;
|
||||||
if (transform != null) {
|
if (transform != null) {
|
||||||
|
@ -436,9 +436,16 @@ public class EditSession implements Extent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.EXTENT.DEBUG) {
|
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 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 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;
|
return extent;
|
||||||
|
Loading…
Reference in New Issue
Block a user