O'Reilly logo

Learn to Program with Minecraft Plugins, 2nd Edition by Andy Hunt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required