Added rollback into the admin menu, fixed a bug where players would crash upon trying to view their own logs on relog.

This commit is contained in:
Commodore64x
2018-05-19 13:37:44 +10:00
parent 380a955e7a
commit 68af32bc9f
12 changed files with 149 additions and 58 deletions

View File

@ -743,49 +743,7 @@ public class ServerControl extends Module {
return;
}
for(IntMap.Entry<Array<EditLog>> editLog : editLogs.entries()) {
int coords = editLog.key;
Array<EditLog> logs = editLog.value;
for(int i = 0; i < rollbackTimes; i++) {
EditLog log = logs.get(logs.size - 1);
int x = coords % world.width();
int y = coords / world.width();
Block result = log.block;
int rotation = log.rotation;
if(log.action == EditLog.EditAction.PLACE) {
Placement.breakBlock(x, y, false, false);
Packets.BreakPacket packet = new Packets.BreakPacket();
packet.x = (short) x;
packet.y = (short) y;
packet.playerid = 0;
Net.send(packet, Net.SendMode.tcp);
}
else if(log.action == EditLog.EditAction.BREAK) {
Placement.placeBlock(x, y, result, rotation, false, false);
Packets.PlacePacket packet = new Packets.PlacePacket();
packet.x = (short) x;
packet.y = (short) y;
packet.rotation = (byte) rotation;
packet.playerid = 0;
packet.block = result.id;
Net.send(packet, Net.SendMode.tcp);
}
logs.removeIndex(logs.size - 1);
if(logs.size == 0) {
editLogs.remove(coords);
break;
}
}
}
netServer.admins.rollbackWorld(rollbackTimes);
info("Rollback done!");
});
}