Command Distance Limiter
1.1Limits a command so it can only be used within a certain distance from a location
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:
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.
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta