Tweak some stuff

This commit is contained in:
Jesse Boyd 2017-01-15 22:15:22 +11:00
parent 55f95e5022
commit a7b29ab82f
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 30 additions and 36 deletions

View File

@ -88,7 +88,7 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
protected static MutableGenLayer genLayer; protected static MutableGenLayer genLayer;
protected static ChunkSection emptySection; protected static ChunkSection emptySection;
public static final IBlockData[] IBD_CACHE = new IBlockData[Character.MAX_VALUE]; public static final IBlockData[] IBD_CACHE = new IBlockData[Character.MAX_VALUE + 1];
static { static {
try { try {
@ -130,7 +130,7 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
setupAdapter(new com.boydti.fawe.bukkit.v1_11.FaweAdapter_1_11()); setupAdapter(new com.boydti.fawe.bukkit.v1_11.FaweAdapter_1_11());
Fawe.debug("Using adapter: " + adapter); Fawe.debug("Using adapter: " + adapter);
Fawe.debug("========================================="); Fawe.debug("=========================================");
for (int i = 0; i < Character.MAX_VALUE; i++) { for (int i = 0; i < IBD_CACHE.length; i++) {
try { try {
IBD_CACHE[i] = Block.getById(i >> 4).fromLegacyData(i & 0xF); IBD_CACHE[i] = Block.getById(i >> 4).fromLegacyData(i & 0xF);
} catch (Throwable ignore) {} } catch (Throwable ignore) {}

View File

@ -13,10 +13,6 @@ import org.primesoft.blockshub.api.IWorld;
public class LoggingChangeSet extends AbstractDelegateChangeSet { public class LoggingChangeSet extends AbstractDelegateChangeSet {
public static void main(String[] args) {
}
private static boolean initialized = false; private static boolean initialized = false;
public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) { public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) {

View File

@ -22,6 +22,21 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
this.parent = parent; this.parent = parent;
} }
@Override
public void addChangeTask(FaweQueue queue) {
super.addChangeTask(queue);
}
@Override
public boolean flushAsync() {
return super.flushAsync();
}
@Override
public boolean flush() {
return super.flush() && parent.flush();
}
public final FaweChangeSet getParent() { public final FaweChangeSet getParent() {
return parent; return parent;
} }
@ -36,16 +51,6 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
return parent.getWorld(); return parent.getWorld();
} }
@Override
public boolean flushAsync() {
return parent.flushAsync();
}
@Override
public boolean flush() {
return parent.flush();
}
@Override @Override
public void add(int x, int y, int z, int combinedFrom, int combinedTo) { public void add(int x, int y, int z, int combinedFrom, int combinedTo) {
parent.add(x, y, z, combinedFrom, combinedTo); parent.add(x, y, z, combinedFrom, combinedTo);
@ -145,9 +150,4 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) { public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
parent.add(x, y, z, combinedFrom, to); parent.add(x, y, z, combinedFrom, to);
} }
@Override
public void addChangeTask(FaweQueue queue) {
parent.addChangeTask(queue);
}
} }

View File

@ -35,10 +35,8 @@ public abstract class FaweChangeSet implements ChangeSet {
private final String worldName; private final String worldName;
private final boolean mainThread; private final boolean mainThread;
private final int layers; private final int layers;
protected final AtomicInteger waitingCombined = new AtomicInteger(0); protected AtomicInteger waitingCombined = new AtomicInteger(0);
private final AtomicInteger waitingAsync = new AtomicInteger(0); protected AtomicInteger waitingAsync = new AtomicInteger(0);
// private Object lockCombined = new Object();
// private Object lockAsync = new Object();
public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) { public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) {
if (Settings.IMP.HISTORY.USE_DISK) { if (Settings.IMP.HISTORY.USE_DISK) {
@ -220,7 +218,7 @@ public abstract class FaweChangeSet implements ChangeSet {
queue.setChangeTask(new RunnableVal2<FaweChunk, FaweChunk>() { queue.setChangeTask(new RunnableVal2<FaweChunk, FaweChunk>() {
@Override @Override
public void run(final FaweChunk previous, final FaweChunk next) { public void run(final FaweChunk previous, final FaweChunk next) {
waitingCombined.incrementAndGet(); FaweChangeSet.this.waitingCombined.incrementAndGet();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -263,7 +261,7 @@ public abstract class FaweChangeSet implements ChangeSet {
default: default:
char combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0; char combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0;
if (combinedIdCurrent != combinedIdPrevious) { if (combinedIdCurrent != combinedIdPrevious) {
synchronized (this) { synchronized (FaweChangeSet.this) {
add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent); add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent);
} }
} }
@ -277,14 +275,14 @@ public abstract class FaweChangeSet implements ChangeSet {
// Tiles created // Tiles created
Map<Short, CompoundTag> tiles = next.getTiles(); Map<Short, CompoundTag> tiles = next.getTiles();
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) { for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
synchronized (this) { synchronized (FaweChangeSet.this) {
addTileCreate(entry.getValue()); addTileCreate(entry.getValue());
} }
} }
// Tiles removed // Tiles removed
tiles = previous.getTiles(); tiles = previous.getTiles();
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) { for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
synchronized (this) { synchronized (FaweChangeSet.this) {
addTileRemove(entry.getValue()); addTileRemove(entry.getValue());
} }
} }
@ -294,14 +292,14 @@ public abstract class FaweChangeSet implements ChangeSet {
// Entities created // Entities created
Set<CompoundTag> entities = next.getEntities(); Set<CompoundTag> entities = next.getEntities();
for (CompoundTag entityTag : entities) { for (CompoundTag entityTag : entities) {
synchronized (this) { synchronized (FaweChangeSet.this) {
addEntityCreate(entityTag); addEntityCreate(entityTag);
} }
} }
// Entities removed // Entities removed
entities = previous.getEntities(); entities = previous.getEntities();
for (CompoundTag entityTag : entities) { for (CompoundTag entityTag : entities) {
synchronized (this) { synchronized (FaweChangeSet.this) {
addEntityRemove(entityTag); addEntityRemove(entityTag);
} }
} }
@ -309,12 +307,12 @@ public abstract class FaweChangeSet implements ChangeSet {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} finally { } finally {
if (waitingCombined.decrementAndGet() <= 0) { if (FaweChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
synchronized (waitingAsync) { synchronized (FaweChangeSet.this.waitingAsync) {
waitingAsync.notifyAll(); FaweChangeSet.this.waitingAsync.notifyAll();
} }
synchronized (waitingCombined) { synchronized (FaweChangeSet.this.waitingCombined) {
waitingCombined.notifyAll(); FaweChangeSet.this.waitingCombined.notifyAll();
} }
} }
} }