Custom Home Coordinate System on the Minecraft Server - using CommandHelper & MethodScript

Our community-supported Minecraft server has several custom commands in the game.

For example, our very own 'home' system that has zero teleportation involved, and is focused around sharing coordinates with others.

How the Home coordinates system works in-game


You can:

/sethome

This will record your current X and Z coordinates (height is ignored), as your home location.

Later, other players can use this to find where you live:

/home <player>

Or, if you happen to forget where your own home is, you could use:

/home

and it would remind you of the coordinates. You'd still need to walk there, because where's the fun in teleporting all over the place. It makes things too easy :)

Although, of course, you'd have to remember the command. If you forget that as well, you're in trouble :P

But there is a help command as well, so as long as you remember that one it can remind you of the other commands that are available:

/help

It is worth noting also, that if you want to stop sharing your home location with other players, you can delete it:

/delhome

This just removes your home location from the database, and you can always add it back again later.

Sound interesting? Why not join us on the Minecraft server :D

Technical implementation for the Home coordinates system


To do this, we're using a Minecraft server plugin called CommandHelper.

If you run a Minecraft server, you can download CommandHelper here.

CommandHelper is a scripting plugin, that allows you to create in-game commands, aliases and event listeners without creating an entire Java-based server plugin. All you need to do is have a basic working knowledge of the scripting language, MethodScript.

If you haven't heard of MethodScript, that's perfectly reasonable. It was created for CommandHelper, and so you likely would not have used it elsewhere. It is currently in the process of outgrowing the Minecraft plugin and is useful as a scripting tool on Windows and Linux, but that is beyond the scope of this article.

The home coordinates system on the community Minecraft server is made up of several parts. I'll demonstrate the 'sethome' command today, and if there is interest I may write another article in the future with more information on the other commands.

MethodScript, which is what you write to make use of CommandHelper, has several useful functions. There is a comprehensive list of all MethodScript functions on the website.

To create a 'sethome' command, you could add something like this into your aliases.msa file, within the plugin configuration directory:

*:/sethome = >>>
    // Get location
    @location = ploc();

    // Confirm we are in overworld
    if (@location['world'] == 'world') {
        // Store player location
        store_value("[email protected]", integer(round(@location['x'])));
        store_value("[email protected]", integer(round(@location['z'])));

        // Tell the player
        msg(color("GREEN") . "You are now sharing your home coordinates.");
    } else {
        msg(color("RED") . "Currently, you can only set a home in the overworld.");
    }
<<<

This is not actually the exact code that I'm running, as I've added additional error checking and a few other features to mine. But it should be enough to get you started with using CommandHelper to create a home coordinates system.

Note:
  • The implementation above only supports the overworld. If you wish to support other dimensions, simply save the dimension along with the coordinates.
  • Since we are defining this in the aliases.msa file, it will not auto-complete in the game chat. Look at register_command() instead if you want more control, including the ability to tab-complete the function names and any parameters.
  • This is just one small part of the system. You will also want to write a '/home' command (or alias) to retrieve and display the values that you stored.
  • If a players name changes, their home coordinates are still linked to the old name. A more resilient system would make use of the player's UUID instead when storing (and retrieving) the values.

Have some questions, you're stuck, or would just like some help with understanding how this works? Pop into our community Discord and say hello :) We currently have a dedicated tutorial-help channel where you can ask any questions.