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.
- Native Minecraft Version:
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.
/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 or cdl.admin
Shows a list of all distance limited commands
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:
(other stuff removed for brevity)
too-far-global: '&cToo far away'
world: '&cYou need a blacksmith to shoe a horse!'
god: '&cYou need a priest to make you a deity!'
I didn't put a whole lot of time into testing, so if you hit a bug just let me know.
Command Distance Limiter 1.1
Limits a command so it can only be used within a certain distance from a location