Mystery Bags [1.15] 3.10

Customizable surprise mystery bags that can drop from mobs and contain random items!

  1. Explodncheez
    Tested Minecraft Versions:
    • 1.15

    Description
    Coded from scratch as a 1.9+ replacement for and improvement on the inactive SurpriseBags plugin, MysteryBags adds special customizable items into your world that can drop from mobs and animals. After a player obtains one, he/she can hold the item and right click to open the bag, causing the bag to disappear, and leaving the player with a random item!

    Bags can be created with a simple in-game command. Afterwards, you can edit it to your heart's content in the plugin's folder!


    Features
    • Highly customizable messages!
    • Bags can drop from any mob!
    • Bag drops can be limited by world, WorldGuard region, mob type, name, and even metadata!
    • Bags can be any item - even custom player heads!
    • Bags can hold commands that are run from console!
    • Bag rewards can have random amounts!
    • Bag contents are easily editable with an in-game GUI!
    • Rare items can be set to announce to the entire server when gotten!

    Commands
    <Required field> [Optional field]
    • /mbag list - Lists the ids of all loaded Mystery Bags.
    • /mbag addbag <id> [material]:[data] - Adds a new Mystery Bag. Unless you know what you're doing, always use this command to create a new bag file!
    • /mbag removebag <id> - Unloads a loaded Mystery Bag, but does not delete the file. Use this command before deleting the file.
    • /mbag spawn <id> [amount] [player] - Exactly what the command implies: spawns Mystery Bags.
    • /mbag edit <id> - Open the Content Editor GUI for the specified Mystery Bag.
    • /mbag save <id> - Saves changes from the Content Editor GUI to the bag's config file.
    • /mbag reload - Reloads config options and bags from disc.
    • /mbag stack <#> - Sets the literal amount of held item as used in item weights.
    • /mbag amount <#> - Sets the amount of that item that can be obtained from a MysteryBag without affecting chance. Allows <#-#> to specify a range of values (inclusive).
    • /mbag command <cmd> - Spawns a Written Book with data holding the command. If received from a MysteryBag, the player will not get the book, but will have the commands run from console. Using this command while holding an existing Command Book will add more commands to it.
      Allowed parameters in commands (case sensitive):
      %P% - player's name
      %W% / %X% / %Y% / %Z% - player's world and coords
    • /mbag setname <name> - Sets the custom name of held item.
    • /mbag setlore <lore> - Sets the custom lore of held item. Use '/' for multiple lines.
    • /mbag addlore <lore> - Appends lines of lore to held item. Use '/' to add multiple lines.
    • /mbag removelore [#lines] - Removes lines of lore from an item, starting at the bottom, ex. '/mbag removelore 2' removes the bottom-most 2 lines of lore from held item.
    • /mbag unbreakable - Toggles the Unbreakable status of held item. Requires that the server be running Spigot.
    • /mbag skulldata <file> - Displays the internal skulldata of held head. Use this in the 'material: THIS' section of a data file to have a custom head as a bag! Specifying a filename will write the output to a file.
    Permissions
    • mysterybags.open - allows opening of Mystery Bags. Default: Everyone
    • mysterybags.admin - allows the usage of MysteryBag commands. Default: Operators

    Notable Differences from SurpriseBags
    This plugin is designed to be as closely compatible with existing SurpriseBags configs as possible; however, there are obviously still changes that need to be made before porting over old bags and configs!
    • Included checks to prevent players from Crafting, Smelting, or Brewing with Mystery Bags!
    • Region and World limits on bag drops are based on where the mob is killed (as opposed to where it spawned).
    • Bags can be opened both in the Main and Off hand slots. Having a bag in each hand opens both of them at the same time!
    • Removed "global" drop chance for bags. The only RNG roll for bag drops is now specified in each individual bag.
    • Drop chances can be further varied by mob type, ex. skeletons may have a higher chance to drop a certain bag than any other mobs.
    • Player bag-open counts and "rare" rewards can be tracked and are logged to output.yml.
    • Ability to specify "rare" rewards and announce to the server whenever a lucky player receives one, with optional firework and sound effect. The broadcasted message is fully customizable.
    • The bag ID is no longer visible in the item's lore.
    • Tons of other additional config options!
    To update SurpriseBag configs into MysteryBag configs, simply copy/paste the following lines into the respective files (and edit them as needed):
    # Does a player have to kill a mob to have a chance at a bag?
    require-player-kill: yeah

    ### OPTIONAL
    # Can mobs from spawners drop Mystery Bags?
    # This value will override the global value.
    allow-spawner-drop: no

    ### OPTIONAL
    # Can baby animals drop Mystery Bags?
    # Does not apply to zombies.
    # This value will override the global value.
    allow-baby-drop: no

    #
    # Looting Chance Increase
    # Only effective if looting-sensitive is true - the drop rate will
    # be boosted by this amount for every level of looting.
    looting-effectiveness: 0.05

    #
    # Looting-Increases-Amount
    # If true, then Looting will have a chance to increase the amount of
    # bags dropped when a player gets one.
    looting-increases-amount: no

    #
    # Message to tell players what they got
    # %ITEMNAME% - name of item, or item material if unnamed
    # %ITEM% - item material
    open-message: 'The bag contained %ITEMNAME%!'

    #
    # Announce Rare Loot
    # If true, the announce-rare-loot-message will broadcast every time
    # a player gets a reward from the rare-items list.
    announce-rare-loot: indubitably

    #
    # Rare Loot Firework
    # If true, a firework will launch at the player's location upon
    # getting rare loot.
    rare-loot-firework: k

    #
    # Rare Loot Sound
    # If true, the "wither spawn" sound will play for everyone
    # if a player gets rare loot.
    rare-loot-sound: true

    #
    # %PLAYER% - name of Player
    # %ITEMNAME% - name of item, or item material if unnamed
    # %ITEM% - item material
    announce-rare-loot-message: '%PLAYER% got lucky and received %ITEMNAME% from a Mystery Bag!'

    #
    # Whether or not to keep track of how many of each bag each player
    # has opened. Data will be written to output.yml
    log-bags: no

    #
    # Whether or not to keep track of rare loot players get.
    # Data will be written to output.yml
    log-rare-loot: no

    #
    # Items listed here are considered rare loot. These only affect the rare loot message.
    # Format:
    # ITEM:
    # - 'If this list isn't empty,'
    # - 'the item is only rare if item name'
    # - 'is contained within this list.'
    # - 'Use & for color codes.'
    ## This item is always rare no matter the name:
    # OTHER_ITEM: []
    rare-loot:
    DIAMOND: []
    #
    # IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!
    # Change 'openmsg' to LIST format!
    # For instance:
    #
    # openmsg:
    # - "&2Hold item and right click to open!"
    #

    #
    # Whether this bag will trigger the drop check
    #
    enabled: false

    #
    # Same as drop-chance, except defined per mob.
    # Values here override the drop-chance above.
    drop-chance-mobs:
    - ZOMBIE: 0.2


    Default Configuration Files
    #
    # CheezBags config file
    #

    #
    # General settings:
    #

    # DONT CHANGE THIS!!!!
    version: 1

    # Will a random bag drop from mobs, set to yes/no
    # Not just limited to hostiles
    drop-from-mobs: yes

    # Should MysteryBags drop separately from the mob's normal?
    # Set this option to TRUE if you suspect a plugin conflict
    # is preventing bags from dropping!
    override-drops: no

    # Does a player have to kill a mob to have a chance at a bag?
    require-player-kill: yeah

    # Can mobs from spawners drop Mystery Bags?
    # This is the default value and can be overridden in
    # in individual bag configs.
    default-allow-spawner-drop: no

    # Can baby animals drop Mystery Bags?
    # Does not apply to zombies.
    # This is the default value and can be overridden in
    # in individual bag configs.
    default-allow-baby-drop: no

    #
    # Looting Sensitive
    # If true, then the drop chance for each bag will increase for
    # every level of the looting enchantment. That is, if players are
    # using a looting sword, they have higher chances of getting bags.
    #
    looting-sensitive: no

    #
    # Looting Chance Increase
    # Only effective if looting-sensitive is true - the drop rate will
    # be boosted by this amount for every level of looting.
    looting-effectiveness: 0.05

    #
    # Looting-Increases-Amount
    # If true, then Looting will have a chance to increase the amount of
    # bags dropped when a player gets one.
    looting-increases-amount: no

    # A list of WorldGuard regions to limit the drops.
    # This is useful if you want bags to drop only in spawn, for example.
    # You must have WorldGuard installed for this to work (duh).
    # Bags will attempt to drop everywhere if this is empty ('[]').
    drop-limit-to-area: []

    #
    # Limit drops to particular worlds.
    # If this is not empty ('[]'), bags will only drop on those worlds.
    # Otherwise bags will attempt to drop in all worlds.
    drop-limit-to-world: []

    #
    # Message to tell players what they got
    # %ITEMNAME% - name of item, or item material if unnamed
    # %ITEM% - item material
    # %BAG% - display name of the bag item, or the bag id if the item doesn't have a name
    open-message: 'The bag contained %ITEMNAME%!'

    #
    # Opening Spy Message
    # If true, server ops will get a message whenever a user opens a bag.
    openingspymessage: sure

    #
    # Announce Rare Loot
    # If true, the announce-rare-loot-message will broadcast every time
    # a player gets a reward from the rare-items list.
    announce-rare-loot: indubitably

    #
    # Rare Loot Firework
    # If true, a firework will launch at the player's location upon
    # getting rare loot.
    rare-loot-firework: k

    #
    # Rare Loot Sound
    # If true, the "wither spawn" sound will play for everyone
    # if a player gets rare loot.
    rare-loot-sound: true

    #
    # %PLAYER% - name of Player
    # %ITEMNAME% - name of item, or item material if unnamed
    # %ITEM% - item material
    # %BAG% - display name of the bag item, or the bag id if the item doesn't have a name
    announce-rare-loot-message: '%PLAYER% got lucky and received %ITEMNAME% from a &e%BAG%&6!'

    #
    # Whether or not to keep track of how many of each bag each player
    # has opened. Data will be written to output.yml
    log-bags: no

    #
    # Whether or not to keep track of rare loot players get.
    # Data will be written to output.yml
    log-rare-loot: no

    #
    # Items listed here are considered rare loot. These only affect the rare loot message.
    # Format:
    # ITEM:
    # - 'If this list isn't empty,'
    # - 'the item is only rare if item name'
    # - 'is contained within this list.'
    # - 'Use & for color codes.'
    ## This item is always rare no matter the name:
    # OTHER_ITEM: []
    rare-loot:
    DIAMOND: []
    #
    # Whether this bag will trigger the drop check
    #
    enabled: false

    #
    # The material of the bag item. This is "CHEST" by default.
    # When using a data value, make sure the entire line has ''s around it!
    material: 'CHEST:0'

    #
    # The item's display name.
    # You may use color codes with the '&' character.
    #
    displayname: "&3Mysterious Treasure"

    #
    # A friendly message on the item lore description.
    # You may use color codes with the '&' character.
    # May be a single line or multiple lines.
    #
    openmsg:
    - "&2Hold item and right click to open!"

    #
    # Whether to always announce drops from this bag
    # as a "rare" item - sounds and fireworks included
    #
    always-rare: false

    # Will opening the bag give all items inside it?
    give-all-items: no

    # Can mobs from spawners drop Mystery Bags?
    # This value will override the global value.
    allow-spawner-drop: no

    # Can baby animals drop Mystery Bags?
    # Does not apply to zombies.
    # This value will override the global value.
    allow-baby-drop: no

    #
    # Can only drop from these mobs.
    # Leave empty to drop from all mobs.
    limit-mob:
    - ZOMBIE

    #
    # Can only drop in these worlds.
    # IS OVERRIDDEN BY the global world limits.
    limit-world: []

    #
    # Chance that the bag fails and player gets Nausea
    failure-chance: 0.0

    #
    # message to send player when it fails
    failure-lines:
    - '&2That didn''t feel very good.'
    - '&2It was a trap!'

    #
    # Global Mob drop-chance.
    #
    # On top of the global drop-chance, this states the
    # chance of this particular bag dropping by a mob.
    #
    # 0.05 is %5, 0.10 is 10%, 0.5 is 50% and so on.
    #
    drop-chance: 0.05

    #
    # Same as drop-chance, except defined per mob.
    # Values here override the drop-chance above.
    drop-chance-mobs:
    ZOMBIE: 0.2

    #
    # The items in the bag.
    #
    # This bag has 1 enchanted book, 1 ghast tear, 2 diamond blocks and other items.
    #
    # When players open the bag, they get exactly 1 item from the bag (e.g. 1 Dblock).
    # This means that players are more likely to get a diamond block than a ghast tear.
    #
    items:
    - ==: org.bukkit.inventory.ItemStack
    type: ENCHANTED_BOOK
    amount: 1
    meta:
    ==: ItemMeta
    meta-type: ENCHANTED
    stored-enchants:
    DAMAGE_ALL: 4

    - ==: org.bukkit.inventory.ItemStack
    type: GHAST_TEAR
    amount: 1

    - ==: org.bukkit.inventory.ItemStack
    type: NETHER_STAR
    amount: 1

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_BLOCK
    amount: 2

    - ==: org.bukkit.inventory.ItemStack
    type: ENDER_PEARL
    amount: 2

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_BOOTS
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    PROTECTION_FALL: 3

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_CHESTPLATE
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    PROTECTION_EXPLOSIONS: 3

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_LEGGINGS
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    PROTECTION_ENVIRONMENTAL: 3

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_HELMET
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    OXYGEN: 3
    #
    # Whether this bag will trigger the drop check
    #
    enabled: false

    #
    # The material of the bag item. This is "CHEST" by default.
    # When using a data value, make sure the entire line has ''s around it!
    material: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDJhYzFjNTE4MDdlMjYxYzEyYzRmMmFkYmFkMzZiOGIyYzQ5N2MyNzdmNzIyM2VjMjQ0Y2I0NjA4YzU5YyJ9fX0='

    #
    # The item's display name.
    # You may use color codes with the '&' character.
    #
    displayname: "&cFancy Gift"

    #
    # A friendly message on the item lore description.
    # You may use color codes with the '&' character.
    # May be a single line or multiple lines.
    #
    openmsg:
    - "&2Hold item and right click to open!"

    #
    # Whether to always announce drops from this bag
    # as a "rare" item - sounds and fireworks included
    #
    always-rare: false

    # Will opening the bag give all items inside it?
    give-all-items: no

    # Can mobs from spawners drop Mystery Bags?
    # This value will override the global value.
    allow-spawner-drop: no

    # Can baby animals drop Mystery Bags?
    # Does not apply to zombies.
    # This value will override the global value.
    allow-baby-drop: no

    #
    # Can only drop from these mobs.
    # Leave empty to drop from all mobs.
    limit-mob:
    - ZOMBIE;Bob

    #
    # Can only drop in these worlds.
    # IS OVERRIDDEN BY the global world limits.
    limit-world: []

    #
    # Chance that the bag fails and player gets Nausea
    failure-chance: 0.0

    #
    # message to send player when it fails
    failure-lines:
    - '&2That didn''t feel very good.'
    - '&2It was a trap!'

    #
    # Global Mob drop-chance.
    #
    # On top of the global drop-chance, this states the
    # chance of this particular bag dropping by a mob.
    #
    # 0.05 is %5, 0.10 is 10%, 0.5 is 50% and so on.
    #
    drop-chance: 0.05

    #
    # Same as drop-chance, except defined per mob.
    # Values here override the drop-chance above.
    drop-chance-mobs:
    ZOMBIE: 0.2

    #
    # The items in the bag.
    #
    # This bag has 1 enchanted book, 1 ghast tear, 2 diamond blocks and other items.
    #
    # When players open the bag, they get exactly 1 item from the bag (e.g. 1 Dblock).
    # This means that players are more likely to get a diamond block than a ghast tear.
    #
    items:
    - ==: org.bukkit.inventory.ItemStack
    type: ENCHANTED_BOOK
    amount: 1
    meta:
    ==: ItemMeta
    meta-type: ENCHANTED
    stored-enchants:
    DAMAGE_ALL: 4

    - ==: org.bukkit.inventory.ItemStack
    type: GHAST_TEAR
    amount: 1

    - ==: org.bukkit.inventory.ItemStack
    type: NETHER_STAR
    amount: 1

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_BLOCK
    amount: 2

    - ==: org.bukkit.inventory.ItemStack
    type: ENDER_PEARL
    amount: 2

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_BOOTS
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    PROTECTION_FALL: 3

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_CHESTPLATE
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    PROTECTION_EXPLOSIONS: 3

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_LEGGINGS
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    PROTECTION_ENVIRONMENTAL: 3

    - ==: org.bukkit.inventory.ItemStack
    type: DIAMOND_HELMET
    meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    enchants:
    OXYGEN: 3


    ----------------------------------------------------------------------------------------------------


    Found a bug? Got a feature request or suggestion?
    Please leave a comment or shoot me a PM! :D


    ----------------------------------------------------------------------------------------------------

    View the Source Code on GitHub.

    ----------------------------------------------------------------------------------------------------

    FishySammich likes this.

Recent Reviews

  1. GenericEntity
    GenericEntity
    5/5,
    Version: 3.10
    This is an amazing plugin with tons of uses! I would love to see it updated to 1.16.
  2. NevendyND
    NevendyND
    5/5,
    Version: 3.10
    I loved sbag but jea its sad thats its only for <1.12.2 and down..
    But now i found this and I'm happy with it :3
  3. manojl
    manojl
    4/5,
    Version: 3.10
    Place to edit or PREFIX when winning a rare item ...
    Nice plugin, love it!!!
    i'm used in 1.15.2 work
  4. Kubson_19
    Kubson_19
    5/5,
    Version: 1.40
    Fantastic plugin, very easy tu use the Gui menu. It was easier than I expected, perfect for RPG servers or any style. Great Job!
  5. p82183645
    p82183645
    5/5,
    Version: 1.21
    I have a very serious question that can reply to me?
    In the discussion area .
  6. FishySammich
    FishySammich
    5/5,
    Version: 1.1
    Works fantastic, really easy to use GUI menu. Some things are a bit tricky but all around a great plugin with a rather friendly Author.
    1. Explodncheez
      Author's Response
      Thank you for the review! Please do not hesitate to let me know if you run into problems or have suggestions for how some features can be more user-friendly!
  7. JustRandomGuy
    JustRandomGuy
    3/5,
    Version: 1.01
    1.8 bro please you're plugin is awesome :( sorry for the 3 stars when the 1.8 is down you'll get 5 waiting ....
    1. Explodncheez
      Author's Response
      In the future, please do not use the review section to suggest features. I will not be releasing a version of MysteryBags for 1.8, as I believe SurpriseBags still works for that version.