Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options:
- #Title that is displayed in chat and guis
- loottitle: &eLootchest &8|
- #Main color:
- lootc1: &e
- #Chest refill timer
- chestref: 3 seconds
- on break:
- if {lootchests::%event-location%} is set:
- player has permission "lootchest.break":
- delete {lootchests::%event-location%::*}
- delete {lootchests::%event-location%}
- send "{@loottitle} &7Lootchest destroyed!"
- else:
- cancel event
- command /lootchest [<text>] [<text>] [<text>]:
- aliases: lc
- trigger:
- player has permission "lootchest.use":
- if arg 1 is "set":
- target block is chest or trapped chest:
- set {lootchests::%location of target block%} to location of target block
- send "{@loottitle} &7Your target chest is now a lootchest!"
- else if arg 1 is "delete":
- if arg 2 is set:
- delete {lootchests::%arg 2%::*}
- delete {lootchests::%arg 2%}
- send "{@loottitle} &7Lootchest deleted!"
- else:
- target block is chest or trapped chest:
- if {lootchests::%location of target block%} is set:
- delete {lootchests::%location of target block%::*}
- delete {lootchests::%location of target block%}
- send "{@loottitle} &7Lootchest deleted!"
- else:
- send "{@loottitle} &7Seems like your target chest is not a lootchest!"
- else if arg 1 is "add":
- target block is chest or trapped chest:
- if {lootchests::%location of target block%} is set:
- player's tool is not air:
- if arg 2 is set:
- if arg 2 contains "-":
- set {_x::*} to arg 2 split at "-"
- if {_x::1} matches "\d+":
- if {_x::2} matches "\d+":
- add "%1 of player's tool%|%arg 2%" to {lootchests::%location of target block%::items::*}
- send "{@loottitle} &7You added {@lootc1}%player's tool% &7with a varying amount of {@lootc1}%{_x::1}% &7to {@lootc1}%{_x::2}% &7items to the lootbox!"
- else:
- send "{@loottitle} &7Seems like there's an error with the upper end of your amount! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
- else:
- send "{@loottitle} &7Seems like there's an error with the lower end of your amount! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
- else:
- send "{@loottitle} &7Seems like there's an error with your amount! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
- else:
- send "{@loottitle} &7Please write the amount for {@lootc1}%player's tool%&7! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
- else:
- send "{@loottitle} &7Please hold an item you want to add to the lootchest!"
- else:
- send "{@loottitle} &7Seems like your target chest is not a lootchest!"
- else if arg 1 is "remove":
- if arg 2 is set:
- if {lootchests::%arg 2%} is set:
- if arg 3 is set:
- loop {lootchests::%arg 2%::items::*}:
- if loop-value contains arg 3:
- remove loop-value from {lootchests::%arg 2%::items::*}
- exit loop
- send "{@loottitle} {@lootc1}%arg 3% &7has been removed from {@lootc1}%arg 2%&7!"
- else:
- send "{@loottitle} &7Please write the item you want to remove from {@lootc1}%arg 2%&7!"
- else:
- send "{@loottitle} &7Seems like {@lootc1}%arg 2% is not a lootchest!"
- else:
- send "{@loottitle} &7Please write the lootchest you want to remove an item from!"
- else if arg 1 is "info":
- if arg 2 is set:
- if {lootchests::%arg 2%} is set:
- set {_lootchest} to arg 2
- else:
- send "{@loottitle} &7Seems like {@lootc1}%arg 2% is not a lootchest!"
- else:
- target block is chest or trapped chest:
- set {_lootchest} to {lootchests::%location of target block%}
- if {lootchests::%{_lootchest}%} is set:
- if size of {lootchests::%{_lootchest}%::items::*} > 0:
- send "{@loottitle} &7List of items in the target lootchest:"
- send " "
- loop {lootchests::%{_lootchest}%::items::*}:
- set {_item::*} to loop-value split at "|"
- replace "-" in {_item::2} with " &7to {@lootc1}"
- send formatted "&7○ {@lootc1}%{_item::1}% &8| &7Amount: {@lootc1}%{_item::2}% &8| <ttp:&7Click to remove.><cmd:/lootchest remove %{_lootchest}% %{_item::1}%>&c[X]<reset>"
- else:
- send "{@loottitle} &7Seems like this lootchest doesn't contain any items yet!"
- else:
- send "{@loottitle} &7Seems like your target chest is not a lootchest!"
- else if arg 1 is "list":
- if size of {lootchests::*} > 0:
- send "{@loottitle} &7List of all current lootchests:"
- send " "
- loop {lootchests::*}:
- set {_x::*} to loop-index split at ":"
- set {_world} to {_x::1}
- set {_x::*} to {_x::2} split at ","
- send formatted "&7○ {@lootc1}Lootchest <ttp:{@lootc1}X: &7%{_x::1}% {@lootc1}Y: &7%{_x::2}% {@lootc1}Z: &7%{_x::3}% &7in world {@lootc1}%{_world}%>&7[Loc]<reset> &8| <ttp:&7Click to teleport><cmd:/lootchest tp %loop-index%>&5[TP]<reset> &8| <ttp:&7Click to receive info><cmd:/lootchest info %loop-index%><##4dffa6>[Info]<reset> &8| <ttp:&7Click to delete><cmd:/lootchest delete %loop-index%>&c[Del]<reset>"
- else:
- send "{@loottitle} &7Seems like no lootchests are set up yet!"
- else if arg 1 is "tp":
- if arg 2 is set:
- teleport player to {lootchests::%arg 2%}
- else:
- send "{@loottitle} &7Please decide to which lootchest you want to get teleported to!"
- else if arg 1 is "preset":
- if {lootchests::%location of target block%} is set:
- set {_x} to "%{lootchests::%location of target block%}%"
- replace "x: ", "y: ", "z: " and " " in {_x} with ""
- set {_x} to "%world of target block%:%{_x}%"
- give chest named "{@lootc1}Lootchest &7Preset" with lore "" and "&7Preset of: {@lootc1}%{_x}%" to player
- send "{@loottitle} &7You received a preset of the lootchest {@lootc1}%{_x}%&7!"
- else:
- send "{@loottitle} &7Seems like your target chest is not a lootchest!"
- else:
- send "{@loottitle} &7Please write what you want to do:"
- send " "
- send formatted "&7○ {@lootc1}/lootchest set &8| <ttp:&7Converts the target chest to a lootchest>&7[i]<reset>"
- send formatted "&7○ {@lootc1}/lootchest delete &8| <ttp:&7Converts the target chest back to a normal chest>&7[i]<reset>"
- send formatted "&7○ {@lootc1}/lootchest add <min-max>&8| <ttp:&7Adds your tool to the target lootchest>&7[i]<reset> &8| &7Example: /lootchest add 7-18"
- send formatted "&7○ {@lootc1}/lootchest remove &8| <ttp:&7Removes items from the target lootchest>&7[i]<reset>"
- send formatted "&7○ {@lootc1}/lootchest info &8| <ttp:&7Gives you info about your target lootchest>&7[i]<reset>"
- send formatted "&7○ {@lootc1}/lootchest list &8| <ttp:&7Gives you a list of all lootchests>&7[i]<reset>"
- send formatted "&7○ {@lootc1}/lootchest preset &8| <ttp:&7Gives you a preset of your target lootchest>&7[i]<reset>"
- else:
- send "{@loottitle} &cYou don't have the required permission to use this command!"
- on place:
- if name of player's tool contains "{@lootc1}Lootchest &7Preset":
- set {_x::*} to uncolored line 2 of lore of player's tool split at "of: "
- add "{CustomName:""text""}" to nbt of block at event-location
- if {lootchests::%{_x::2}%} is set:
- set {lootchests::%event-location%} to event-location
- set {lootchests::%event-location%::items::*} to {lootchests::%{_x::2}%::items::*}
- send "{@loottitle} &7Placed lootchest with the following preset:"
- send "{@loottitle} {@lootc1}%{_x::2}%"
- else:
- send "{@loottitle} &7Seems like that preset doesn't exist anymore!"
- every {@chestref}:
- if size of {lootchests::*} > 0:
- loop {lootchests::*}:
- if size of {lootchests::%loop-index%::items::*} > 0:
- clear inventory of block at {lootchests::%loop-index%}
- loop {lootchests::%loop-index%::items::*}:
- set {_x::*} to loop-value-2 split at "|"
- set {_item} to {_x::1} parsed as item type
- set {_x::*} to {_x::2} split at "-"
- set {_amount} to a random integer between {_x::1} parsed as integer and {_x::2} parsed as integer
- set {_z} to a random integer between 0 and 26
- set {_inv} to inventory of block at {lootchests::%loop-index-1%}
- set slot {_z} of {_inv} to {_amount} of {_item}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement