Code:
if (playerCommand.startsWith("c") && playerCommand.length() > 2) {
try {
BufferedWriter coord = new BufferedWriter(new FileWriter("./Data/Coords.txt", true));
String location = playerCommand.substring(2);
try {
coord.write("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel+" L: "+location);
c.sendMessage("You have successfully logged a location.");
coord.newLine();
} finally {
coord.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Basically I use this for if I find an area I like and don't feel like opening up notepad or whatever to save the coordinates I can just type ::c (location) and it will automatically save the X coord, Y coord, and my height, as well with what area it is in a file in the server, that makes it cleaner and easier to save locations as well as find them later on.. Here is what it will look like when it saves into the file..
X: 3232 Y: 3231 H: 0 L: Lumbridge
X: 3210 Y: 3424 H: 0 L: Varrock
X: 2964 Y: 3378 H: 0 L: Falador
X: 3102 Y: 3489 H: 0 L: Edgeville
Usage:
In game go to whatever location you want, say lumbridge, then do..
And It will save the coordinates along with the name you provided in coords.txt in your data folder.