forked from LogBlock/LogBlock
Fixed rollback
This commit is contained in:
@@ -192,7 +192,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
minutes = parseTimeSpec(args[3], args[4]);
|
minutes = parseTimeSpec(args[3], args[4]);
|
||||||
if (isInt(args[2])) {
|
if (isInt(args[2])) {
|
||||||
player.sendMessage(ChatColor.GREEN + "Rolling back area within " + args[2] + " blocks of you by " + minutes + " minutes.");
|
player.sendMessage(ChatColor.GREEN + "Rolling back area within " + args[2] + " blocks of you by " + minutes + " minutes.");
|
||||||
new Thread(new Rollback(player, conn, Integer.parseInt(args[2]), minutes, table)).start();
|
getServer().getScheduler().scheduleSyncDelayedTask(this, new Rollback(player, conn, Integer.parseInt(args[2]), minutes, table));
|
||||||
} else
|
} else
|
||||||
player.sendMessage(ChatColor.RED + "Can't parse to an int: " + args[2]);
|
player.sendMessage(ChatColor.RED + "Can't parse to an int: " + args[2]);
|
||||||
} else
|
} else
|
||||||
@@ -203,7 +203,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
minutes = parseTimeSpec(args[4], args[5]);
|
minutes = parseTimeSpec(args[4], args[5]);
|
||||||
if (isInt(args[3])) {
|
if (isInt(args[3])) {
|
||||||
player.sendMessage(ChatColor.GREEN + "Rolling back " + args[2] + " within " + args[3] + " blocks by " + minutes + " minutes.");
|
player.sendMessage(ChatColor.GREEN + "Rolling back " + args[2] + " within " + args[3] + " blocks by " + minutes + " minutes.");
|
||||||
new Thread(new Rollback(player, conn, args[2], Integer.parseInt(args[3]), minutes, table)).start();
|
getServer().getScheduler().scheduleSyncDelayedTask(this, new Rollback(player, conn, args[2], Integer.parseInt(args[3]), minutes, table));
|
||||||
} else
|
} else
|
||||||
player.sendMessage(ChatColor.RED + "Can't parse to an int: " + args[3]);
|
player.sendMessage(ChatColor.RED + "Can't parse to an int: " + args[3]);
|
||||||
} else
|
} else
|
||||||
@@ -216,9 +216,10 @@ public class LogBlock extends JavaPlugin
|
|||||||
if (we != null) {
|
if (we != null) {
|
||||||
Selection sel = ((WorldEditPlugin)we).getSelection(player);
|
Selection sel = ((WorldEditPlugin)we).getSelection(player);
|
||||||
if (sel != null) {
|
if (sel != null) {
|
||||||
if (sel instanceof CuboidSelection)
|
if (sel instanceof CuboidSelection) {
|
||||||
new Thread(new Rollback(player, conn, sel.getMinimumPoint(), sel.getMaximumPoint(), minutes, table)).start();
|
player.sendMessage(ChatColor.GREEN + "Rolling back selection by " + minutes + " minutes.");
|
||||||
else
|
getServer().getScheduler().scheduleSyncDelayedTask(this, new Rollback(player, conn, sel.getMinimumPoint(), sel.getMaximumPoint(), minutes, table));
|
||||||
|
} else
|
||||||
player.sendMessage(ChatColor.RED + "You have to define a cuboid selection");
|
player.sendMessage(ChatColor.RED + "You have to define a cuboid selection");
|
||||||
} else
|
} else
|
||||||
player.sendMessage(ChatColor.RED + "No selection defined");
|
player.sendMessage(ChatColor.RED + "No selection defined");
|
||||||
|
@@ -123,24 +123,12 @@ public class Rollback implements Runnable
|
|||||||
int changes = edits.size();
|
int changes = edits.size();
|
||||||
int rolledBack = 0;
|
int rolledBack = 0;
|
||||||
player.sendMessage(ChatColor.GREEN + "" + changes + " Changes found.");
|
player.sendMessage(ChatColor.GREEN + "" + changes + " Changes found.");
|
||||||
player.sendMessage(ChatColor.GOLD + "This may take " + (int)Math.ceil(changes/1000) + " seconds.");
|
|
||||||
int counter = 0;
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Edit e = edits.poll();
|
Edit e = edits.poll();
|
||||||
while (e != null)
|
while (e != null)
|
||||||
{
|
{
|
||||||
if (e.perform())
|
if (e.perform())
|
||||||
rolledBack++;
|
rolledBack++;
|
||||||
counter++;
|
|
||||||
if (counter > 100) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
LogBlock.log.log(Level.SEVERE, this.getClass().getName() + " SQL exception", ex);
|
|
||||||
player.sendMessage(ChatColor.RED + "Error, check server logs.");
|
|
||||||
}
|
|
||||||
counter = 0;
|
|
||||||
}
|
|
||||||
e = edits.poll();
|
e = edits.poll();
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + "Rollback finished successfully");
|
player.sendMessage(ChatColor.GREEN + "Rollback finished successfully");
|
||||||
|
Reference in New Issue
Block a user