Skip to content

Instantly share code, notes, and snippets.

@riking
Created April 30, 2013 02:53
Show Gist options
  • Save riking/5486343 to your computer and use it in GitHub Desktop.
Save riking/5486343 to your computer and use it in GitHub Desktop.
public void checkSession() throws ExceptionWorldConflict { // CraftBukkit - throws ExceptionWorldConflict
try {
File file1 = new File(this.baseDir, "session.lock");
DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
try {
if (datainputstream.readLong() != this.sessionId) {
throw new ExceptionWorldConflict("The save is being accessed from another location, aborting");
}
} finally {
datainputstream.close();
}
} catch (IOException ioexception) {
throw new ExceptionWorldConflict("Failed to check session lock, aborting");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment