mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-13 17:27:35 +07:00
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:
@ -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!");
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user