Reading MongoDB documents

How a world is saved

In a vanilla world the four factors below are the only differences per Runescape world. This means the entire difference can be summarized by the "Players" collection and the "Grand Exchange" collection. Here is the outline:

  • Players: This collection is a translated/serialized Player class from the Java source from the class Player to a JSON format inputted into a Player document.
  • Grand Exchange: This collection holds a list of items in the Grand Exchange as a JSON document.
  • High scores: This collection automatically process/indexes the players files into a high scores by their experience/levels.
  • Logs: This collection holds all player trades and server errors ever generated.

The Mongo Database & these 4 collections auto-populate upon server start. If they already exist the server reads the database and these four factors, initializes all the Grand Exchange offers and when a player logs in, loads all the player data from it.

How Is The Player Class Saved?

If you take a look at the player class you will see certain variables stored inside it, particularly observe the word transient:

public class Player extends Entity {
  private String username;
	private Inventory inventory;
	private Equipment equipment;
	private Skills skills;
  private transient Conversation conversation;
	private transient InterfaceManager interfaceManager;
  private transient Trade trade;
  private transient boolean running;
	private transient boolean resting;
  //etc..
}

When the Player class is being translated/serialized into JSON everything that is either a function or transient is not stored in the JSON document. For this reason you will not see "running: true," in MongoDB documents but you will see inventory, skills and equipment.