Store Game Data in a Database

That’s great for configuration data, but not so useful for game data—data that changes as the game plays on, like player scores and status, inventory, health, and things like that. We need to access data a little differently, and be able to write game data from the plugin as well as read it.

There is one important limitation to storage approaches, however. You can only save and load simple types: strings, integers, floating point, and boolean values. You can’t save Minecraft-specific objects—things like Location or Player. You can save a player’s name as a String, and save a Location as a set of double x-, y-, and z-coordinates, but you can’t save the Minecraft objects directly.

That turns out to be a reasonable ...

Get Learn to Program with Minecraft Plugins, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.