Undo/redo should not be allowed outside allowed regions by default.

Fixes #949
Dieser Commit ist enthalten in:
dordsor21 2021-07-10 14:14:34 +01:00
Ursprung 0434b86d8e
Commit 338be0ff31
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
3 geänderte Dateien mit 22 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -167,6 +167,11 @@ public class Settings extends Config {
"Should large edits require confirmation (>16384 chunks)", "Should large edits require confirmation (>16384 chunks)",
}) })
public boolean CONFIRM_LARGE = true; public boolean CONFIRM_LARGE = true;
@Comment({
"If undo and redo commands should be restricted to allowed regions",
" - Prevents scenarios where players can delete/reset a region, and then continue to undo/redo on it"
})
public boolean RESTRICT_HISTORY_TO_REGIONS = true;
@Comment({ @Comment({
"List of blocks to strip nbt from", "List of blocks to strip nbt from",
}) })
@ -523,6 +528,7 @@ public class Settings extends Config {
limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION); limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT; limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;
limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE; limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE;
limit.RESTRICT_HISTORY_TO_REGIONS &= newLimit.RESTRICT_HISTORY_TO_REGIONS;
if (limit.STRIP_NBT == null) { if (limit.STRIP_NBT == null) {
limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT); limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT);
} else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) { } else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) {

Datei anzeigen

@ -18,6 +18,7 @@ public class FaweLimit {
public int SPEED_REDUCTION = Integer.MAX_VALUE; public int SPEED_REDUCTION = Integer.MAX_VALUE;
public boolean FAST_PLACEMENT = false; public boolean FAST_PLACEMENT = false;
public boolean CONFIRM_LARGE = true; public boolean CONFIRM_LARGE = true;
public boolean RESTRICT_HISTORY_TO_REGIONS = true;
public Set<String> STRIP_NBT = null; public Set<String> STRIP_NBT = null;
public static FaweLimit MAX; public static FaweLimit MAX;
@ -108,6 +109,7 @@ public class FaweLimit {
MAX.MAX_EXPRESSION_MS = 50; MAX.MAX_EXPRESSION_MS = 50;
MAX.FAST_PLACEMENT = true; MAX.FAST_PLACEMENT = true;
MAX.CONFIRM_LARGE = true; MAX.CONFIRM_LARGE = true;
MAX.RESTRICT_HISTORY_TO_REGIONS = false;
MAX.STRIP_NBT = null; MAX.STRIP_NBT = null;
} }
@ -229,6 +231,7 @@ public class FaweLimit {
&& INVENTORY_MODE == 0 && INVENTORY_MODE == 0
&& SPEED_REDUCTION == 0 && SPEED_REDUCTION == 0
&& FAST_PLACEMENT && FAST_PLACEMENT
&& !RESTRICT_HISTORY_TO_REGIONS
&& (STRIP_NBT == null || STRIP_NBT.isEmpty()); && (STRIP_NBT == null || STRIP_NBT.isEmpty());
} }
@ -245,6 +248,7 @@ public class FaweLimit {
SPEED_REDUCTION = limit.SPEED_REDUCTION; SPEED_REDUCTION = limit.SPEED_REDUCTION;
FAST_PLACEMENT = limit.FAST_PLACEMENT; FAST_PLACEMENT = limit.FAST_PLACEMENT;
CONFIRM_LARGE = limit.CONFIRM_LARGE; CONFIRM_LARGE = limit.CONFIRM_LARGE;
RESTRICT_HISTORY_TO_REGIONS = limit.RESTRICT_HISTORY_TO_REGIONS;
STRIP_NBT = limit.STRIP_NBT; STRIP_NBT = limit.STRIP_NBT;
} }
@ -262,6 +266,7 @@ public class FaweLimit {
limit.MAX_HISTORY = MAX_HISTORY; limit.MAX_HISTORY = MAX_HISTORY;
limit.FAST_PLACEMENT = FAST_PLACEMENT; limit.FAST_PLACEMENT = FAST_PLACEMENT;
limit.CONFIRM_LARGE = CONFIRM_LARGE; limit.CONFIRM_LARGE = CONFIRM_LARGE;
limit.RESTRICT_HISTORY_TO_REGIONS = RESTRICT_HISTORY_TO_REGIONS;
limit.STRIP_NBT = STRIP_NBT; limit.STRIP_NBT = STRIP_NBT;
return limit; return limit;
} }

Datei anzeigen

@ -566,15 +566,17 @@ public class LocalSession implements TextureHolder {
loadSessionHistoryFromDisk(actor.getUniqueId(), world); loadSessionHistoryFromDisk(actor.getUniqueId(), world);
if (getHistoryNegativeIndex() < history.size()) { if (getHistoryNegativeIndex() < history.size()) {
ChangeSet changeSet = getChangeSet(history.get(getHistoryIndex())); ChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
try (EditSession newEditSession = new EditSessionBuilder(world) EditSessionBuilder builder = new EditSessionBuilder(world)
.allowedRegionsEverywhere() .checkMemory(false)
.checkMemory(false) .changeSetNull()
.changeSetNull() .fastmode(false)
.fastmode(false) .limitUnprocessed((Player)actor)
.limitUnprocessed((Player)actor) .player((Player)actor)
.player((Player)actor) .blockBag(getBlockBag((Player)actor));
.blockBag(getBlockBag((Player)actor)) if (!actor.getLimit().RESTRICT_HISTORY_TO_REGIONS) {
.build()) { builder.allowedRegionsEverywhere();
}
try (EditSession newEditSession = builder.build()) {
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO); newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO);
setDirty(); setDirty();
historyNegativeIndex++; historyNegativeIndex++;