Fixed ship autosave
This commit is contained in:
parent
8980d1e53d
commit
e1058cb10d
1 changed files with 18 additions and 18 deletions
|
@ -394,6 +394,20 @@ public class JumpSequencer extends AbstractSequencer {
|
|||
private void state_borders() {
|
||||
LocalProfiler.start("Jump.borders");
|
||||
|
||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||
WarpDrive.logger.info(this + " Checking ship borders...");
|
||||
}
|
||||
|
||||
StringBuilder reason = new StringBuilder();
|
||||
|
||||
if (!ship.checkBorders(reason)) {
|
||||
String msg = reason.toString();
|
||||
disable(msg);
|
||||
ship.messageToAllPlayersOnShip(msg);
|
||||
LocalProfiler.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Generate unique file name
|
||||
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd_HH'h'mm'm'ss's'SSS");
|
||||
|
@ -401,8 +415,8 @@ public class JumpSequencer extends AbstractSequencer {
|
|||
String schematicFileName;
|
||||
do {
|
||||
Date now = new Date();
|
||||
schematicFileName = shipName + "_" + sdfDate.format(now);
|
||||
} while (new File(WarpDriveConfig.G_SCHEMALOCATION + "/auto/" + schematicFileName + ".schematic").exists());
|
||||
schematicFileName = WarpDriveConfig.G_SCHEMALOCATION + "/auto/" + shipName + "_" + sdfDate.format(now) + ".schematic";
|
||||
} while (new File(schematicFileName).exists());
|
||||
|
||||
// Save header
|
||||
NBTTagCompound schematic = new NBTTagCompound();
|
||||
|
@ -421,32 +435,18 @@ public class JumpSequencer extends AbstractSequencer {
|
|||
schematic.setTag("ship", tagCompoundShip);
|
||||
writeNBTToFile(schematicFileName, schematic);
|
||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||
// WarpDrive.logger.info(this + " Ship saved as " + schematicFileName);
|
||||
// WarpDrive.logger.info(this + " Ship saved as " + schematicFileName);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||
WarpDrive.logger.info(this + " Checking ship borders...");
|
||||
}
|
||||
|
||||
StringBuilder reason = new StringBuilder();
|
||||
|
||||
if (!ship.checkBorders(reason)) {
|
||||
String msg = reason.toString();
|
||||
disable(msg);
|
||||
ship.messageToAllPlayersOnShip(msg);
|
||||
LocalProfiler.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
msCounter = System.currentTimeMillis();
|
||||
LocalProfiler.stop();
|
||||
}
|
||||
|
||||
private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) {
|
||||
WarpDrive.logger.info(this + " writeNBTToFile " + fileName);
|
||||
WarpDrive.logger.info(this + " Saving ship state prior to jump in " + fileName);
|
||||
|
||||
try {
|
||||
File file = new File(fileName);
|
||||
|
|
Loading…
Reference in a new issue