LuckySpongeBlock - Give out pre-configured luckyblocks which execute commands when they get placed by players!

This is a discussion topic for the Ore project, LuckySpongeBlock. View the full project on Ore for downloads and more information.


LuckySpongeBlock

Build against SpongeAPI 7 to allow Server Owners to distribute different kinds of luckyblocks to their players!

What does it do?

LuckySpongeBlock allows you to create as many custom lucky blocks as you want. It uses itemstacksnapshots as serialization and therefore allows you to make highly customizable blocks. Upon placing the lucky block, it triggers the commands you entered into the config and executes them from console on the player.
This plugin also features a buy command, which players can use to buy a luckyblock at a pre-configured price.

Command/Permission

This plugin consists of only one command which is as follows:

  • /luckyspongeblock give [<player>] <luckyblockname> [amount] Permission: luckyspongeblock.give.
    Gives a the chosen luckyblock to the specified player (or yourself if you leave it out). Amount is optional and defaults to 1.

  • /luckyspongeblock buy <luckyblockname> Permission: luckyspongeblock.buy.
    Attempts to buy the chosen luckyblock. Will fail if you don’t have enough money. Command only works if you have an economy plugin installed.

  • /luckyspongeblock reload Permission: luckyspongeblock.reload.
    Attempts to reload the plugin from its configuration.

Configuration

Upon first starting your server with this plugin it will automatically generate a default configuration for you already, so you can use it straight out of the box!
The default configuration also contains plenty of comments to guide you through it, but just for coverage, I will list them here as well:

  • luckyblocks: Will contain a list of all your configured luckyblocks which can be bought and given to players ingame.

For each luckyblock you can define the following:

  • commands: The commands to be executed when the blocks get placed. All commands will be run from the console. Use %p to get the player that placed the block.

  • cost: The cost of the luckyblock. This is the amount the players have to pay to obtain the specified luckyblock

  • luckyblockitem: ItemData. Contains things like display name, lore, itemtype, unsafe data, etc. I put in a default block to show some of the possibilities, but it is easiest just to explore (or to google)!

  • name: needs to be individual will be used as reference for the command arguments

NOTE: If you make changes to existing luckyblocks, while they still exist in the world, the old ones will break. It is best to add a new luckyblock to the config instead of changing old ones, to ensure nothing breaks!

TO-DO(?)

Currently, I can’t think of additional things to add but, if you feel like something is wrong or missing, please open an issue and I’ll see what I can do!

Thank you for looking at my plugin and reading until the end of this text. :slight_smile:

A new version has been released for LuckySpongeBlock, it is available for download here.


This is the initial 1.0 release!

1 Like

Love the plugin, I was wondering how I would go about making the sponge block a player head, could you show me an example of how that would work? Like a lucky block playerhead for example.

Okay, I attached an example below:

            ItemType="minecraft:skull"
            UnsafeDamage=3
            UnsafeData {
                HideFlags=33
                SkullOwner {
                    Id=de02e45a-a7a7-44eb-a7be-f492aa15ecdd
                    Name=BlackSpirit
                    Properties {
                        textures=[
                            {
                                Value="ewogICJ0aW1lc3RhbXAiIDogMTU5MzgxNjUxMDA1NSwKICAicHJvZmlsZUlkIiA6ICJkZTAyZTQ1YWE3YTc0NGViYTdiZWY0OTJhYTE1ZWNkZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJCbGFja1NwaXJpdCIsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS80Zjg3MDVkNGIzYTMxMzg2NTYyNzViMmY0MjM4MzM4ZGNmMjFmN2FlN2IzOWQyNjhmNDNmNGU5MmJjMjIxYWZlIiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0="
                            }
                        ]
                    }
                }
                display {
                    Lore=[
                        "§aplace me down to get something!",
                        "Lore Line 2"
                    ]
                    Name="§cLucky Block!"
                }

You’ll have to look at the give command of the corresponding head you want. If it also has a long gibber-ish of letters and numbers, it needs to replace the above long gibberish of letters of numbers (together with UUID and SkullOwner (name), ofc).

This configuration needs this long combination of letters, numbers etc in order to get the head skin properly.

https://minecraft-heads.com/custom-heads/alphabet/32582-oak-wood-refresh
Example would be this, besides the owner name and UUID, it also features the “value” which you find in all commands and at the bottom of the page. You’ll need all of these 3 in order to get a playerhead from someone who hasn’t been on your server.

Hope this helps and makes sense to you!

EDIT: This is what you need to get a playerhead from someone who has been on your server:

            ItemType="minecraft:skull"
            UnsafeDamage=3
            UnsafeData {
                HideFlags=33
                SkullOwner {
                    Id=de02e45a-a7a7-44eb-a7be-f492aa15ecdd
                    Name=BlackSpirit
                }
                display {
                    Lore=[
                        "§aplace me down to get something!",
                        "Lore Line 2"
                    ]
                    Name="§cLucky Block!"
                }
                ench=[
                    {
                        id=34
                        lvl=1
                    }
                ]
            }

A new version has been released for LuckySpongeBlock, it is available for download here.


Minor Bugfix

Fixed an error being thrown in the /reload command preventing the plugin to reload completely.