Mining stone executes a command

Discussion in 'Plugin Requests' started by MrBobblyBooks, Jun 17, 2022.

  1. Offline

    MrBobblyBooks

    Plugin category: not sure what this means

    Minecraft version: 1.17.1

    Suggested name: CommandExecuter

    What I want: This feels like it should be fairly easy to create, but I want a plugin so that when a player mines stone, and ores (would be great if I could change what blocks in a config.yml) it will execute a command that I can set in (config.yml) with a percentage chance that I can also set in a config.yml
    For example, a player mines 38 stone, and on the 39th block, console will give the player a crate key randomly.
    It would be great if this plugin could also have different blocks result in different commands, for example, stone will execute giving a crate key, whereas mining grass blocks could give you $10,000 which I'd want to be able to change in a config.yml

    Ideas for commands: none required

    Ideas for permissions: none required

    When I'd like it by: As soon as possible, but I'm not in a great rush. Im happy to wait a couple of weeks
     
  2. Offline

    mrsot

    There you go. If you find any bugs, just message me and I'll fix them
    The config file should be pretty straightforward, but feel free to ask anything
    Code: https://github.com/kvbc/MineCommand
     

    Attached Files:

    Last edited: Jun 18, 2022
  3. Offline

    MrBobblyBooks

    thanks! Ill check it out now
     
  4. Offline

    MrBobblyBooks

    If its not too much hassle, are you able to make it so the commands only run when the player is in survival?
     
  5. Offline

    mrsot

    Sure
     

    Attached Files:

  6. Offline

    MrBobblyBooks

    and how would I add a coloured message with the say command? I tried "&dtest message" and it didnt change anything:(
     
  7. Offline

    mrsot

    You'd need to make use of the /tellraw command
    To send a message to everyone:
    Code:
    tellraw @a {"text":"Hello everyone!","color":"red"}
    To send a message to a specific player:
    Code:
    tellraw %player% {"text":"Hi!","color":"red"}
    Be sure to try out this tool https://minecraft.tools/en/tellraw.php
     
    Last edited: Jun 18, 2022
  8. Offline

    MrBobblyBooks

    do you know why this code isnt working?
    Code:
      stone:
        -
          chance: 0.5 #50%
          commands:
            - "scrates givecrate MiningCrateTier1 %player% 1"
            - "tellraw %player% {"text":"SKY","bold":true},{"text":"ISLES ","bold":true,"color":"gold"},{"text":"» ","color":"#BDC1C6"},{"text":"You got lucky and found a ","color":"white"},{"text":"mining crate ","color":"yellow"},{"text":"(tier 1)","color":"gray"},{"text":"!","color":"white"}"
     
  9. Offline

    mrsot

    Start the commands with a single quote
    Code:
    - 'tellraw %player% {"text":"SKY","bold":true},{"text":"ISLES ","bold":true,"color":"gold"},{"text":"» ","color":"#BDC1C6"},{"text":"You got lucky and found a ","color":"white"},{"text":"mining crate ","color":"yellow"},{"text":"(tier 1)","color":"gray"},{"text":"!","color":"white"}'
    
     
  10. Offline

    MrBobblyBooks

    Code:
      [Sun 17:07:14 INFO ] SUCCESS! Given physical crate for crate: MiningCrateTier1
      [Sun 17:07:14 INFO  Server] Expected whitespace to end one argument, but found trailing data
      [Sun 17:07:14 INFO  Server] ...ld":true},{"text":"ISLES ","bold":true,"color":"gold"},{"text":"» ","color":"#BDC1C6"},{"text":"You got lucky and found a ","color":"white"},{"text":"mining crate ","color":"yellow"},{"text":"(tier 1)","color":"gray"},{"text":"!","color":"white"}<--[HERE]
    now I see no message in chat and get this in console when the command is prompted
    I have started and finished the line with a ' though, so I'm not sure why it isn't working :(
     
  11. Offline

    Stellrow

    May i suggest simply adding a separat config option for messages? Seems better in this case
     
  12. Offline

    mrsot

    You're right, i've added 2 new config options:
    • messages_player - messages send to the player who broke the block
    • messages_server - messages send to everyone

    Example:
    Code:
      tnt:
        -
          chance: 1 #100%
          commands:
            - "say be careful with that!"
            - "say test"
          messages_player:
            - "&cU mined %block%!"
          messages_server:
            - "&6%player% has mined %block%"
     

    Attached Files:

    Last edited: Jun 20, 2022
  13. Offline

    MrBobblyBooks

    thank you so much! this plugin is going to be extremely useful for me :)
     
  14. Offline

    mrsot

    I'm glad I could help
     
  15. Offline

    MrBobblyBooks

    if its not too much to ask, would you be able to add a permission too?
    for example:
    Code:
      tnt:
        -
          chance: 1 #100%
          commands:
            - "say be careful with that!"
            - "say test"
          messages_player:
            - "&cU mined %block%!"
          messages_server:
            - "&6%player% has mined %block%"
          permission:
            - minecommand.tnt
    so that only players with minecommand.tnt permission can recieve the rewards?
     

Share This Page