Fix for history database

fix history find y
correct purge time units
injected language is sql (@MattBDev is there a plugin or something for SQLite? I couldn't find any)
Dieser Commit ist enthalten in:
Jesse Boyd 2020-01-05 12:39:58 +00:00
Ursprung c05cdd8faa
Commit b173c85c78
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
2 geänderte Dateien mit 25 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -40,19 +40,19 @@ public class RollbackDatabase extends AsyncNotifyQueue {
private final World world;
private Connection connection;
private @Language("SQLite") String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `{0}edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL, `time` INT NOT NULL,`x1` INT NOT NULL,`x2` INT NOT NULL,`z1` INT NOT NULL,`z2` INT NOT NULL,`y1` INT NOT NULL, `y2` INT NOT NULL, `size` INT NOT NULL, `command` VARCHAR, PRIMARY KEY (player, id))";
private @Language("SQLite") String UPDATE_TABLE1 = "ALTER TABLE `{0}edits` ADD COLUMN `command` VARCHAR";
private @Language("SQLite") String UPDATE_TABLE2 = "alter table `{0}edits` add size int default 0 not null";
private @Language("SQLite") String INSERT_EDIT = "INSERT OR REPLACE INTO `{0}edits` (`player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
private @Language("SQLite") String PURGE = "DELETE FROM `{0}edits` WHERE `time`<?";
private @Language("SQLite") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
private @Language("SQLite") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
private @Language("SQLite") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
private @Language("SQLite") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("sql") String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `{0}edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL, `time` INT NOT NULL,`x1` INT NOT NULL,`x2` INT NOT NULL,`z1` INT NOT NULL,`z2` INT NOT NULL,`y1` INT NOT NULL, `y2` INT NOT NULL, `size` INT NOT NULL, `command` VARCHAR, PRIMARY KEY (player, id))";
private @Language("sql") String UPDATE_TABLE1 = "ALTER TABLE `{0}edits` ADD COLUMN `command` VARCHAR";
private @Language("sql") String UPDATE_TABLE2 = "alter table `{0}edits` add size int default 0 not null";
private @Language("sql") String INSERT_EDIT = "INSERT OR REPLACE INTO `{0}edits` (`player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
private @Language("sql") String PURGE = "DELETE FROM `{0}edits` WHERE `time`<?";
private @Language("sql") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
private @Language("sql") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
private @Language("sql") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
private @Language("sql") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
private @Language("sql") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("SQLite") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
private @Language("SQLite") String DELETE_EDIT_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("sql") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
private @Language("sql") String DELETE_EDIT_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `id`=?";
private ConcurrentLinkedQueue<RollbackOptimizedHistory> historyChanges = new ConcurrentLinkedQueue<>();
@ -84,7 +84,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
try {
init().get();
purge((int) TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS));
purge((int) TimeUnit.DAYS.toSeconds(Settings.IMP.HISTORY.DELETE_AFTER_DAYS));
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
@ -138,8 +138,8 @@ public class RollbackDatabase extends AsyncNotifyQueue {
int index = result.getInt("id");
int x1 = result.getInt("x1");
int x2 = result.getInt("x2");
int y1 = result.getInt("y1");
int y2 = result.getInt("y2");
int y1 = result.getByte("y1") + 128;
int y2 = result.getByte("y2") + 128;
int z1 = result.getInt("z1");
int z2 = result.getInt("z2");
CuboidRegion region = new CuboidRegion(BlockVector3.at(x1, y1, z1), BlockVector3.at(x2, y2, z2));

Datei anzeigen

@ -9,8 +9,6 @@ import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MainUtil;
@ -43,7 +41,7 @@ import java.util.UUID;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor, Closeable {
public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor, Closeable {
private World world;
private final String worldName;
@ -51,11 +49,11 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor, Close
protected AtomicInteger waitingAsync = new AtomicInteger(0);
protected boolean closed;
public FaweChangeSet(String world) {
public AbstractChangeSet(String world) {
this.worldName = world;
}
public FaweChangeSet(World world) {
public AbstractChangeSet(World world) {
this.world = world;
this.worldName = world.getName();
}
@ -270,7 +268,7 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor, Close
} else if (change.getClass() == EntityRemove.class) {
add((EntityRemove) change);
} else {
getLogger(FaweChangeSet.class).debug("Unknown change: " + change.getClass());
getLogger(AbstractChangeSet.class).debug("Unknown change: " + change.getClass());
}
}
@ -340,17 +338,17 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor, Close
}
public Future<?> addWriteTask(Runnable writeTask, boolean completeNow) {
FaweChangeSet.this.waitingCombined.incrementAndGet();
AbstractChangeSet.this.waitingCombined.incrementAndGet();
Runnable wrappedTask = () -> {
try {
writeTask.run();
} finally {
if (FaweChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
synchronized (FaweChangeSet.this.waitingAsync) {
FaweChangeSet.this.waitingAsync.notifyAll();
if (AbstractChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
synchronized (AbstractChangeSet.this.waitingAsync) {
AbstractChangeSet.this.waitingAsync.notifyAll();
}
synchronized (FaweChangeSet.this.waitingCombined) {
FaweChangeSet.this.waitingCombined.notifyAll();
synchronized (AbstractChangeSet.this.waitingCombined) {
AbstractChangeSet.this.waitingCombined.notifyAll();
}
}
}