Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-07 00:22:51 +02:00
feat: Reduce any spam caused by exceptions thrown when writing history (#1976)
- Closes #1960
Dieser Commit ist enthalten in:
Ursprung
ccb31c0ecc
Commit
8971d7064c
@ -47,6 +47,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
private final World world;
|
||||
private final AtomicInteger lastException = new AtomicInteger();
|
||||
protected AtomicInteger waitingCombined = new AtomicInteger(0);
|
||||
protected AtomicInteger waitingAsync = new AtomicInteger(0);
|
||||
|
||||
@ -369,8 +370,11 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
if (completeNow) {
|
||||
throw t;
|
||||
} else {
|
||||
int hash = t.getMessage().hashCode();
|
||||
if (lastException.getAndSet(hash) != hash) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (AbstractChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
|
||||
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.MutableFullBlockChange;
|
||||
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.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
@ -146,8 +147,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
@Override
|
||||
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
||||
if (y < 0 || y > 255) {
|
||||
throw new UnsupportedOperationException("y cannot be outside range 0-255 for " +
|
||||
"small-edits=true");
|
||||
throw new FaweSmallEditUnsupportedException();
|
||||
}
|
||||
int rx = -lx + (lx = x);
|
||||
int ry = -ly + (ly = y);
|
||||
@ -332,7 +332,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
//x
|
||||
posDel.write(stream, x - originX, y, z - originZ);
|
||||
idDel.writeChange(stream, combinedFrom, combinedTo);
|
||||
} catch (Throwable e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -358,7 +358,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
os.write((byte) (y + 128));
|
||||
os.writeVarInt(from.getInternalId());
|
||||
os.writeVarInt(to.getInternalId());
|
||||
} catch (Throwable e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -699,7 +699,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
|
||||
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};
|
||||
int i = 0;
|
||||
Iterator<Change> current = iterators[0];
|
||||
|
@ -91,6 +91,7 @@ public class FaweException extends RuntimeException {
|
||||
PLAYER_ONLY,
|
||||
ACTOR_REQUIRED,
|
||||
CLIPBOARD,
|
||||
HISTORY,
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren