Plugin: LocationSnapshot

Here’s an example of using a DataAccess (in this case, AllPlayerLocations) in a new plugin, LocationSnapshot. For this plugin, we’ll provide two new commands:

  • /savelocations

  • /loadlocations

You might want to use this kind of feature as part of a competition, where you can return all players back to their starting points at the end.

The savelocations command, as you’d expect, saves the current locations of all online players to disk. loadlocations reads them back in and teleports everyone back to those saved locations. We’ll use Canary’s Database functions with our AllPlayerLocations DataAccess object to save and load a hash of Players and Locations.

There are two main pieces to this plugin: saveLocations and ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.