Implement Region.undo
Implement Region.redo Implement Region undoSession implement
Dieser Commit ist enthalten in:
Ursprung
09fd349e5d
Commit
5baa457d3f
@ -172,13 +172,6 @@ public class Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSessions() {
|
|
||||||
if (undoSessions == null) {
|
|
||||||
undoSessions = new SizedStack<>(20);
|
|
||||||
redoSessions = new SizedStack<>(20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) {
|
public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||||
if (!hasType(regionType)) {
|
if (!hasType(regionType)) {
|
||||||
return false;
|
return false;
|
||||||
@ -361,40 +354,44 @@ public class Region {
|
|||||||
|
|
||||||
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel);
|
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel);
|
||||||
|
|
||||||
|
EditSession editSession = null;
|
||||||
switch (regionType) {
|
switch (regionType) {
|
||||||
case BUILD:
|
case BUILD:
|
||||||
System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPointBuild);
|
System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPointBuild);
|
||||||
if (schematic != null) {
|
if (schematic != null) {
|
||||||
paste(schematic.load(), minPointBuild, pasteOptions);
|
editSession = paste(schematic.load(), minPointBuild, pasteOptions);
|
||||||
} else {
|
} else {
|
||||||
paste(prototype.getBuild().getSchematicFile(), minPointBuild, pasteOptions);
|
editSession = paste(prototype.getBuild().getSchematicFile(), minPointBuild, pasteOptions);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TESTBLOCK:
|
case TESTBLOCK:
|
||||||
System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPointTestblock);
|
System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPointTestblock);
|
||||||
if (schematic != null) {
|
if (schematic != null) {
|
||||||
paste(schematic.load(), minPointTestblock, pasteOptions);
|
editSession = paste(schematic.load(), minPointTestblock, pasteOptions);
|
||||||
} else {
|
} else {
|
||||||
paste(prototype.getTestblock().getSchematicFile(), minPointTestblock, pasteOptions);
|
editSession = paste(prototype.getTestblock().getSchematicFile(), minPointTestblock, pasteOptions);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPoint);
|
System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPoint);
|
||||||
if (schematic != null) {
|
if (schematic != null) {
|
||||||
paste(schematic.load(), minPoint, pasteOptions);
|
editSession = paste(schematic.load(), minPoint, pasteOptions);
|
||||||
} else {
|
} else {
|
||||||
paste(prototype.getSchematicFile(), minPoint, pasteOptions);
|
editSession = paste(prototype.getSchematicFile(), minPoint, pasteOptions);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initSessions();
|
||||||
|
undoSessions.push(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
private EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15));
|
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
|
private EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15));
|
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,4 +399,47 @@ public class Region {
|
|||||||
return this == GlobalRegion.getInstance();
|
return this == GlobalRegion.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initSessions() {
|
||||||
|
if (undoSessions == null) {
|
||||||
|
undoSessions = new SizedStack<>(20);
|
||||||
|
redoSessions = new SizedStack<>(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean undo() {
|
||||||
|
initSessions();
|
||||||
|
EditSession session = null;
|
||||||
|
try {
|
||||||
|
session = undoSessions.pop();
|
||||||
|
if (session == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
session.undo(session);
|
||||||
|
redoSessions.push(session);
|
||||||
|
return true;
|
||||||
|
} finally {
|
||||||
|
if (session != null) {
|
||||||
|
session.flushSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean redo() {
|
||||||
|
initSessions();
|
||||||
|
EditSession session = null;
|
||||||
|
try {
|
||||||
|
session = redoSessions.pop();
|
||||||
|
if (session == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
session.redo(session);
|
||||||
|
undoSessions.push(session);
|
||||||
|
return true;
|
||||||
|
} finally {
|
||||||
|
if (session != null) {
|
||||||
|
session.flushSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren