MagmaGuy / BetterStructures

Adds structures to Minecraft worlds using WorldEdit!
GNU General Public License v3.0
24 stars 11 forks source link

(Suggestion) Command sign #7

Closed AllayBreeze closed 1 year ago

AllayBreeze commented 1 year ago

It will be nice if can add a "command sign" special block type, just similar to "spawn sign", as commands can do really lots of works.

(If the sign is not enough to include a command, it can also add a "preset command" function. Preset commands are stored into YAML files and each of them has a unique identify name, and \<command> in the second line can be replaced with a preset command.)

Patterns: [command] #first line, indicates that this is a command sign.

\\;\<command> #second line, defines the executor and specific contents of the command. About the executor: if set to "console (or cs)" or left blank, the command will be executed by console; If set to "player (or p)" or "playerasop" and the trigger is set to step or stepbase, the command will be executed by the player steps on, and "playerasop (or op)" will allow the player execute the command with op permissions. Position placeholders can be used into the command like %x, %y, %z, %biome, %base (represents the material of the block sustaining the command sign), %basex, %basey, %basez, %basebiome, %player (the name of the player stepped on the sign, works with the step and stepbase trigger below)

\<trigger>;\<range> #third line, defines the way and player range to allow the command to be executed. About triggers, "generate (or g)" means that the command will be executed as the structure generates; "step (or s)" means that the command will be executed as a player arrives the command sign's position; "stepbase (or sb)" means that the command will be executed as a player steps onto the command sign's base block. About ranges, it defines the minimum distance between the player and the sign that can trigger this command, and it only works when the trigger is set to "base" or "stepbase".

\<time>;\<cooldown> #last line, defines how many times the command can be executed, and the cooldown in ticks between two times. If the \<time> is set to -1, the command can be triggered and executed for infinite times.

Examples:

[command]

cs;summon zombie %x %y %z

g;0

1;0 #this command sign will summon a zombie at its position when the structure generates, and can be triggered for one time.

[command]

cs;msg %player Welcome to this place!

s;3

-1;100 #this command sign will send the player a message when his/her distance to the sign is ≤3, and can be triggered for infinite times but has a 5s cooldown.

[command]

op;heal

sb;0

3;1200 #this command sign will allow the player heal him/herself with op permission when him/her arriving onto the sign's base block, and can be triggered for 3 times but has a 60s cooldown.

[command]

cs;a-preset-command

g;0

1;0 #this command sign will execute the preset command called "a-preset-command".

MagmaGuy commented 1 year ago

I am willing to add the ability to run a command from console when a structure spawns and, as mentioned the other ticket, I plan to add worldguard regions as well.

That being said, I will not implement systems which require long-term tracking of structures, especially not systems that might be computationally expensive as they would require scanning regions for players.

WorldGuard can be used for a number of region entering / leaving solutions, but the ability to infinitely spam preconfigured commands as a fake operator as long as you are in any of the regions is just not practical.

It is possible to rig most everything you want from WorldGuard and WorldGuardExtraFlags, including running commands on region enter and leave. I suggest you go that route, as BetterStructures aims to leave no footprint behind - this means that no functionality should be lost if you uninstall the plugin later, as no code execution is run after a new chunk is generated.