Home›Java›Mods›Command Distance Limiter
Quick plugin I threw together for someone on the forum. This allows you to restrict the use of a command to a certain distance from a location. So if you were roleplaying and had a plugin that allows you to shoe horses for speed benefits, let's say the command is /shoe. You could restrict the command /shoe so it can only be used within like 10 blocks of the blacksmith shop in a village.

You can use it on multiple spots in a world, so if you have five blacksmith shops in your town you can mark each one for that command.

I only tested on 1.16.1, so no promises on 1.15 or older.

Commands:

/CDL SET
command distance
cdl.set or cdl.admin
Sets a restriction. So using the example above, I'd be sure to be in the world where the blacksmith is then do /cdl set shoe 10. Set distance 0 to disable. Once you run this, you will need to go click on a block. The block you click will be considered the center for distance checks.

/CDL LIST
cdl.list or cdl.admin
Shows a list of all distance limited commands

/CDL RELOAD
cdl.reload or cdl.admin
Reloads configuration from disk

Messaging is in the config, but there is one thing I need to explain. The message sent when someone is too far away, by default, is in "too-far-global". You can customize the message individual to the command or to command and world. So if you want the generic message to be "Too far away!" but for the /shoe example have it say "You need a blacksmith to shoe a horse!". Also let's say you have /god restricted to churches in villages on 5 worlds and don't want to have to set 5 duplicate messages. You can set the command itself as the value instead of making it a configuration section. See the example below:
Code (Text):
messages:
  (other stuff removed for brevity)
  too-far-global: '&cToo far away'
  too-far:
    shoe:
      world: '&cYou need a blacksmith to shoe a horse!'
    god: '&cYou need a priest to make you a deity!'
Closing
I didn't put a whole lot of time into testing, so if you hit a bug just let me know.

Commands

Plugin details

Read from the plugin's own plugin.yml.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Command Distance Limiter is a free Minecraft Java mod. Downloaded 488 times (via Spigot). Download it and open it directly in the game.

Explore more