mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
feat: Reduce any spam caused by exceptions thrown when writing history (#1976)
- Closes #1960
This commit is contained in:
parent
ccb31c0ecc
commit
8971d7064c
@ -47,6 +47,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
|||||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
|
private final AtomicInteger lastException = new AtomicInteger();
|
||||||
protected AtomicInteger waitingCombined = new AtomicInteger(0);
|
protected AtomicInteger waitingCombined = new AtomicInteger(0);
|
||||||
protected AtomicInteger waitingAsync = new AtomicInteger(0);
|
protected AtomicInteger waitingAsync = new AtomicInteger(0);
|
||||||
|
|
||||||
@ -369,8 +370,11 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
|||||||
if (completeNow) {
|
if (completeNow) {
|
||||||
throw t;
|
throw t;
|
||||||
} else {
|
} else {
|
||||||
|
int hash = t.getMessage().hashCode();
|
||||||
|
if (lastException.getAndSet(hash) != hash) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (AbstractChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
|
if (AbstractChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
|
||||||
synchronized (AbstractChangeSet.this.waitingAsync) {
|
synchronized (AbstractChangeSet.this.waitingAsync) {
|
||||||
|
@ -6,6 +6,7 @@ import com.fastasyncworldedit.core.history.change.MutableBlockChange;
|
|||||||
import com.fastasyncworldedit.core.history.change.MutableEntityChange;
|
import com.fastasyncworldedit.core.history.change.MutableEntityChange;
|
||||||
import com.fastasyncworldedit.core.history.change.MutableFullBlockChange;
|
import com.fastasyncworldedit.core.history.change.MutableFullBlockChange;
|
||||||
import com.fastasyncworldedit.core.history.change.MutableTileChange;
|
import com.fastasyncworldedit.core.history.change.MutableTileChange;
|
||||||
|
import com.fastasyncworldedit.core.internal.exception.FaweSmallEditUnsupportedException;
|
||||||
import com.fastasyncworldedit.core.internal.io.FaweInputStream;
|
import com.fastasyncworldedit.core.internal.io.FaweInputStream;
|
||||||
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
||||||
import com.fastasyncworldedit.core.util.MainUtil;
|
import com.fastasyncworldedit.core.util.MainUtil;
|
||||||
@ -146,8 +147,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
|||||||
@Override
|
@Override
|
||||||
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
||||||
if (y < 0 || y > 255) {
|
if (y < 0 || y > 255) {
|
||||||
throw new UnsupportedOperationException("y cannot be outside range 0-255 for " +
|
throw new FaweSmallEditUnsupportedException();
|
||||||
"small-edits=true");
|
|
||||||
}
|
}
|
||||||
int rx = -lx + (lx = x);
|
int rx = -lx + (lx = x);
|
||||||
int ry = -ly + (ly = y);
|
int ry = -ly + (ly = y);
|
||||||
@ -332,7 +332,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
|||||||
//x
|
//x
|
||||||
posDel.write(stream, x - originX, y, z - originZ);
|
posDel.write(stream, x - originX, y, z - originZ);
|
||||||
idDel.writeChange(stream, combinedFrom, combinedTo);
|
idDel.writeChange(stream, combinedFrom, combinedTo);
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,7 +358,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
|||||||
os.write((byte) (y + 128));
|
os.write((byte) (y + 128));
|
||||||
os.writeVarInt(from.getInternalId());
|
os.writeVarInt(from.getInternalId());
|
||||||
os.writeVarInt(to.getInternalId());
|
os.writeVarInt(to.getInternalId());
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -699,7 +699,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
|||||||
|
|
||||||
final Iterator<MutableBiomeChange> biomeChange = getBiomeIterator(dir);
|
final Iterator<MutableBiomeChange> biomeChange = getBiomeIterator(dir);
|
||||||
|
|
||||||
return new Iterator<Change>() {
|
return new Iterator<>() {
|
||||||
final Iterator<Change>[] iterators = new Iterator[]{tileCreate, tileRemove, entityCreate, entityRemove, blockChange, biomeChange};
|
final Iterator<Change>[] iterators = new Iterator[]{tileCreate, tileRemove, entityCreate, entityRemove, blockChange, biomeChange};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Iterator<Change> current = iterators[0];
|
Iterator<Change> current = iterators[0];
|
||||||
|
@ -91,6 +91,7 @@ public class FaweException extends RuntimeException {
|
|||||||
PLAYER_ONLY,
|
PLAYER_ONLY,
|
||||||
ACTOR_REQUIRED,
|
ACTOR_REQUIRED,
|
||||||
CLIPBOARD,
|
CLIPBOARD,
|
||||||
|
HISTORY,
|
||||||
OTHER
|
OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.fastasyncworldedit.core.internal.exception;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
|
|
||||||
|
public class FaweSmallEditUnsupportedException extends FaweException {
|
||||||
|
|
||||||
|
private static final Component message = TextComponent.of(
|
||||||
|
"y cannot be outside range 0-255 for small-edits=true. History will NOT work on edits outside this range.");
|
||||||
|
|
||||||
|
public FaweSmallEditUnsupportedException() {
|
||||||
|
super(message, Type.HISTORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user