Lootcrates - Powerful and Highly Customizable Rewards icon

Lootcrates - Powerful and Highly Customizable Rewards -----

Reward your players with lootcrates



Join the Discord for prereleases and help
[​IMG]
https://discord.gg/K9xDtEKyXT

Quick Start Guide


Fixes for package name changes in 1.21 have been implemented.

The changes to NBT in 1.20.5+ have been implemented. The plugin is expected to function, given you install the newest version of CRUtils (see below). Reach out if any issues occur.
  • Installation:
  • Give yourself a crate with /crates crate peasant
  • Edit plugin via /crates editor
  • Play around with gradient color formatting using /crates colors
  • Full support for QualityArmory, MMOItems, Skript, and more upon request...
  • Optionally choose a server-specific locale via /crates lang <country-code>
    • /crates lang en
    • If you want to contribute any languages, reach out to me on my Discord above.
Crates:
[​IMG]

Editing loot:
[​IMG]
I am aware the gifs look buggy. For some reason, Spigot likes very-tiny 5MB gifs even though they are hosted on Imgur.

If Skript is installed, you have the option to add a LootSkriptEvent to any given LootSet. Following the videos below to normally add a new loot, do this for the LootSkriptEvent, and input the tag of the on loot event you want to trigger.
Example Skript:
Code (Text):
on loot "troll":
    send "Haha you got trolololed" to player
You can also give a crate to a player:
Code (Text):
command /cratesk <string>:
    trigger:
        give crate arg-1 to the player
And list all loaded crates:
Code (Text):

command /crateslist:
    trigger:
        loop crates: # note*: 'crates' is a string list
            send "Crate %loop-value%" to player
 
Code (Text):

# Spawn crates in area
# made by crazicrafter1

# /dropcrateregion -370 337 -350 357 world
command /dropcrateregion <number> <number> <number> <number> <string>:
    permission: loot.drop
    usage: /dropcrateregion <x1> <z1> <x2> <z2> <world>
    trigger:
        set {dropcrate.x1} to arg-1
        set {dropcrate.z1} to arg-2
        set {dropcrate.x2} to arg-3
        set {dropcrate.z2} to arg-4
 
        set {dropcrate.world} to arg-5
 
        message "&6Set lootdrop region between %arg 1% %arg 2% and %arg 3% %arg 4% in %arg 5%"



# /dropcratechance peasant 20
command /dropcratechance <string> <number>:
    permission: loot.drop
    usage: /dropcratechance <crate> <chance>
    trigger:
        set {dropcrate.chances::%arg 1%} to arg-2
        set {dropcrate.last} to {dropcrate.now}
        set {dropcrate.sum} to 0
 
        loop {dropcrate.chances::*}:
            add loop-value to {dropcrate.sum}
 
        message "&6Set %arg 1% crate weight to %arg 2%"
        #message "sums: %{dropcrate.sum}%"



# /dropcrateinterval 20
command /dropcrateinterval <number>:
    permission: loot.drop
    usage: /dropcrateinterval <seconds>
    trigger:
        set {dropcrate.interval} to arg-1
 
        message "&6Set lootdrop interval to %arg 1%s"



# /dropcratelist
command /dropcratelist:
    permission: loot.drop
    trigger:
        message "&2World: &a%{dropcrate.world}%"
        loop {dropcrate.chances::*}:
            message " - &8%loop-index% %loop-value%"



# 10 second accuracy, which isnt too laggy
every 10 seconds: # in "%{dropcrate.world}%":
    add 10 to {dropcrate.now}
 
    if {dropcrate.chances::*} is set:
        if {dropcrate.interval} is set:
 
 
 
            if {dropcrate.last} <= {dropcrate.now} - {dropcrate.interval}:
 
                set {_random} to a random integer between 0 and {dropcrate.sum} - 1
 
                # https://stackoverflow.com/questions/1761626/weighted-random-numbers
                loop {dropcrate.chances::*}:
                    if {_random} < loop-value:
 
                        # forcibly find a valid region
                        while {_location} is not set:
                            # https://www.spigotmc.org/threads/random-location-in-a-specific-region.351639/
                            set {_location} to location(random integer from {dropcrate.x1} to {dropcrate.x2}, 255, random integer from {dropcrate.z1} to {dropcrate.z2}, world({dropcrate.world}))
 
                            # https://www.reddit.com/r/UHCHosts/comments/6qxtof/skript_place_a_chest_at_random_coordinates/
                            while block below {_location} is not solid:
                                set {_location} to block below {_location}
                                if {_location}'s y-coordinate <= 1:
                                    delete {_location}
                                    exit 1 loop
 
                        # temp selected block
                        set {_chest} to block at {_location}
 
                        # now set a chest block
                        set block at {_location} to chest
 
                        # https://forums.skunity.com/threads/adding-items-to-a-chest.8080/#post-35136
                        set slot 13 of {_chest}'s inventory to crate loop-index
 
                        # effect thingy
                        shoot ("firework rocket" parsed as entity type) from {_location}
 
                        broadcast "&6Lootdrop of %loop-index% at %{_location}'s x-coordinate%, %{_location}'s z-coordinate% in %{_location}'s world%"
 
                        set {dropcrate.last} to {dropcrate.now}
 
                        exit 1 loop
 
                    remove loop-value from {_random}
 
                if {_chest} is not set:
                    broadcast "unexpected"
 
Code (Text):

# World generated crates
# made by crazicrafter1

options:
    prefix: &8[&cLCE&8] &7



on skript load:
    #set {leasterr} to 10000
 
    loop {lce.weights::*}:
        # if crate does not exist
        if crate loop-index is not set:
            # delete it
            clear {lce.weights::%loop-index%}
            send "{@prefix}%loop-index% crate no longer exists, removing..." to console
 
    set {lce.weightsum} to 0
 
    # reweigh
    loop {lce.weights::*}:
        add loop-value to {lce.weightsum}
 
 

# delete a spawned crate
# /lcedel king
command /lcedel <string>:
    permission: lce.admin
    usage: /lceweights <crate>
    trigger:
        clear {lce.weights::%arg-1%}
 
        message "{@prefix}%arg-1% crate will no longer spawn"



# specified crate spawn weights
# /lceweights king 10
# /lceweights peasant 10
command /lceweights <string> <number>:
    permission: lce.admin
    usage: /lceweights <crate> <weight>
    trigger:
        # set crate chance
        if crate arg-1 is not set:
            send "{@prefix}That crate does not exist"
            stop
 
        set {lce.weights::%arg-1%} to arg-2
 
        add arg-2 to {lce.weightsum}
 
        message "{@prefix}Set %arg-1% crate spawn weight to %arg-2%"
 


# what world to spawn crates in
# /lce world world
command /lceworld <string>:
    permission: lce.admin
    usage: /lceworld <world>
    trigger:
        if (arg-1 parsed as world) is set:
            set {lce.world} to arg-1
            message "{@prefix}Set crate spawn world to %arg-1%"
        else:
            message "{@prefix}That world does not exist"



# crate chunk spawn chance
# /lce chance .1
command /lcechance <number>:
    permission: lce.admin
    usage: /lcechance <decimal>
    trigger:
        if arg-1 > 0:
            if arg-1 < 1:
                set {lce.chance} to arg-1
                message "{@prefix}Set new chunk crate spawn chance to %arg-1%"
                stop
 
        message "{@prefix}Number must lie within (0, 1)"



# information about the skript
# /lce
command /lce:
    permission: lce.admin
    trigger:
        if {lce.enable}:
            message "{@prefix}LCE is enabled"
        else:
            message "{@prefix}LCE is disabled"
 
        if {lce.weights::*} is not set:
            message "&7Crate spawn weights are not set"
        else:
            message "&7Crate spawn weights:"
            loop {lce.weights::*}:
                message "&7 - %loop-index% %loop-value%"
 
        if {lce.chance} is not set:
            message "&7New chunk spawn chance is not set"
        else:
            message "&7New chunk spawn chance is set to %{lce.chance}%"
 
        if {lce.world} is not set:
            message "&7Crate spawn world is not set"
        else:
            message "&7Crate spawn world is set to %{lce.world}%"
 


command /lcereset:
    permission: lce.admin
    trigger:
        clear {lce.weights::*}
        clear {lce.world}
        clear {lce.chance}
        clear {lce.weightsum}
        message "{@prefix}Reset all crate spawn data"
 
 

command /lceenable:
    permission: lce.admin
    trigger:
        set {lce.enable} to true
        message "{@prefix}LCE is now enabled"

command /lcedisable:
    permission: lce.admin
    trigger:
        set {lce.enable} to false
        message "{@prefix}LCE is now disabled"



# https://skripthub.net/docs/
on chunk generate:
    if not {lce.enable}:
        stop
 
    if {lce.weights::*} is not set:
        stop
    if {lce.world} is not set:
        stop
    if {lce.chance} is not set:
        stop
 
    if world of event-chunk is not {lce.world}:
        stop
 
    # https://skripthub.net/docs/?id=3915
    set {_block} to block at 0, 0, 0 in chunk event-chunk
 
    set {_block} to highest solid block at {_block}
 
    set {_rchance} to a random number between 0 and 1
    if {_rchance} > {lce.chance}:
        stop
 
    set {_random} to a random integer between 0 and {lce.weightsum} - 1
 
    #broadcast "rand: %{_random}%"
 
    # https://stackoverflow.com/questions/1761626/weighted-random-numbers
    loop {lce.weights::*}:
        if {_random} < loop-value:
 
            #broadcast "&8Spawned crate in %{_block}%"
 
            # temp selected block
            set {_chest} to block at {_block}

            # now set a chest block
            set block at {_block} to chest

            # https://forums.skunity.com/threads/adding-items-to-a-chest.8080/#post-35136
            set slot 13 of {_chest}'s inventory to crate loop-index

            set {dropcrate.last} to {dropcrate.now}

            #exit 1 loop
            stop

        remove loop-value from {_random}

    #if {_chest} is not set:
    #    if {_rweight} < {leasterr}:
    #        set {leasterr} to {_rweight}
    #
    #    broadcast "{@prefix}&cunexpected outcome (%{leasterr}%"
Code (Text):

# Keycrates
# made by crazicrafter1
# requires SkBee

options:
    prefix: &8[&2LCE-KC&8] &7

# https://github.com/ShaneBeee/SkBee/wiki/NBTCompound#set-1
command /kc:
    permission: lootcrates.admin
    trigger:
        message "{@prefix}Key crate claim location is at %{lce.keycrate}%"

command /kcmake <string>:
    permission: lootcrates.admin
    trigger:
        add "{CrateKey:""%arg-1%""}" to nbt of player's held item
        message "{@prefix}Created a %arg-1% crate key from item"

command /kcput:
    permission: lootcrates.admin
    trigger:
        if target block is not solid:
            message "{@prefix}Invalid block position"
        else:
            set {lce.keycrate} to location of target block
            message "{@prefix}Set key crate location to %{lce.keycrate}%"

command /kcdel:
    permission: lootcrates.admin
    trigger:
        if {lce.keycrate} is not none:
            clear {lce.keycrate}
            message "{@prefix}Removed keycrate location"
        else:
            message "{@prefix}No crate key location is set"

# https://forums.skunity.com/threads/how-to-use-nbt-tags-on-items.7541/#post-32433
on rightclick:
    set {_key} to tag "tag;CrateKey" of nbt compound of player's held item
    if {lce.keycrate} is location of clicked block:
        cancel event
        if {_key} is set:
            opencrate {_key} to player
            message "{@prefix}Using %{_key}% crate key"
        else:
            message "{@prefix}Must use a crate key to open"
    else:
        if {_key} is set:
            message "{@prefix}Can only open at a key claim"
 
on leftclick:
    set {_key} to tag "tag;CrateKey" of nbt compound of player's held item
    if {_key} is set:
        cancel event
        if {lce.keycrate} is location of clicked block:
            # preview crate
            previewcrate {_key} to player
            message "{@prefix}Previewing %{_key}% crate"
        else:
            message "{@prefix}Can only preview at a key claim"

on block break:
    if {lce.keycrate} is location of block:
        cancel event
 

Code (Text):

# Fake crate (trollcrate)
# made by crazicrafter1/PeriodicSeizures/crzi
# requires SkBee

command /trollcrate <string>:
    permission: tc.admin
    trigger:
        set {_item} to crate arg-1
        set {_nbt} to nbt compound of {_item}
        delete tag "tag;Crate" of {_nbt}
        set {_item} to item from nbt {_nbt}
 
        #message "%{_nbt}%"
 
        give {_item} to the player
 
        message "Received 1 troll %arg-1% crate"
 

IMPORTANT
- Try to stick with the latest versions of Minecraft.
- Do not give 1-star ratings prior to contacting me. It's petty and somewhat rude.
- Although this plugin should be fully compatible with fairly recent Minecraft versions (1.16.5+), this might not be the case for versions prior to this, especially 1.8-1.12. The most used legacy version is 1.12, which constitutes only 2.1% of servers (according to bStats). About 3% of servers are in 1.16.5, and all others are 1.18.1 and/or above. If you want legacy support for your server, you are better sticking with a legacy build of Lootcrates. I haven't tested out a version such as 1.8 in a while, so there's no telling how this plugin performs on that version. What I am trying to say is that I do not like legacy versions. It is like keeping a foot in the past, and not being able to move forward unless I stop supporting them. I don't know.
Resource Information
Author:
----------
Total Downloads: 16,926
First Release: Jun 18, 2019
Last Update: Nov 7, 2024
Category: ---------------
All-Time Rating:
22 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings