Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- #
- #
- #
- #
- #
- #
- #
- #
- import:
- org.bukkit.block.Chest
- function loot_config(p: sender):
- set {_ms} to ms
- clear {-lootconfig::*}
- load yaml "plugins/Skript/loot/loots.yml" as "loot"
- loop yaml node keys "loots" from "loot":
- set {-lootconfig::name::%loop-value%} to (yaml value "loots.%loop-value%.name" from "loot") ? "Nameless"
- set {-lootconfig::cooldown::%loop-value%} to (yaml value "loots.%loop-value%.cooldown" from "loot" to seconds) ? 0
- loop yaml list "loots.%loop-value%.loot" from "loot":
- set {_match} to matcher "(.+) ([0-9]+)%% (.+)" of "%loop-value-2%"
- add 1 to {_i}
- set {_amount} to 1st element of groups 1 of {_match}
- set {_i::*} to (split {_amount} at "-") ? {_amount}
- if {_i::2} is not set:
- set {-lootconfig::loot::%loop-value-1%::%{_i}%::min} to {_i::1} parsed as number
- set {-lootconfig::loot::%loop-value-1%::%{_i}%::max} to {-lootconfig::loot::%loop-value-1%::%{_i}%::min}
- else:
- set {-lootconfig::loot::%loop-value-1%::%{_i}%::min} to {_i::1} parsed as number
- set {-lootconfig::loot::%loop-value-1%::%{_i}%::max} to {_i::2} parsed as number
- set {_chance} to 1st element of groups 2 of {_match}
- set {-lootconfig::loot::%loop-value-1%::%{_i}%::chance} to ({_chance} parsed as number) / 100
- set {_item} to 1st element of groups 3 of {_match}
- set {-lootconfig::loot::%loop-value-1%::%{_i}%} to {_item} parsed as item
- if {-lootconfig::loot::%loop-value-1%::%{_i}%} is not set:
- clear {-lootconfig::loot::%loop-value-1%::%{_i}%::*}
- send "&3[Loots] &7Failed to load the item &c%loop-value-2%&7." to {_p}
- unload yaml "loot"
- send "&3[Loots] &fConfig loaded in &a%ms - {_ms}%ms &fwith a total of &a%{_i} ? 0% &fitems." to {_p}
- on load:
- loot_config(console)
- command /loot [<text>] [<text>] [<text>]:
- trigger:
- if player doesn't have permission "loot.admin":
- send "&3[Loots] &cYou do not have the required permission."
- else if arg 1 = "reload":
- loot_config(sender)
- function loot_getfromname(name: text) :: text:
- loop {-lootconfig::name::*}:
- {_name} = loop-value
- return loop-index
- on inventory open:
- event-inventory.getHolder() is instance of Chest
- set {_b} to event-inventory.getHolder().getBlock()
- set {_l} to location of {_b}
- if {loot::cooldown::%{_l}%} > unix timestamp of now:
- set {_format} to regex replace "00[a-zA-Z]+" with "" in (format ({loot::cooldown::%{_l}%} - unix timestamp of now) into "yy'y'MM'mo'dd'd'HH'h'mm'm'ss's'")
- send "&3[Loots] &7This chest will refill in &c%{_format}%&7."
- else:
- set {_name} to loot_getfromname({_b}.getState().getCustomName())
- {_name} is set
- send "&3[Loots] &7You opened a &a%{_b}.getState().getCustomName()% &7chest."
- set {loot::cooldown::%{_l}%} to unix timestamp of now + {-lootconfig::cooldown::%{_name}%}
- loop {-lootconfig::loot::%{_name}%::*}:
- chance of {-lootconfig::loot::%{_name}%::%loop-index%::chance}:
- set {_i} to random integer between {-lootconfig::loot::%{_name}%::%loop-index%::min} and {-lootconfig::loot::%{_name}%::%loop-index%::max} of loop-value
- set slot (random integer between 0 and 26) of {_b} to {_i}
- on break:
- event-block = chest
- event is not cancelled
- {loot::cooldown::%event-location%} is set
- clear {loot::cooldown::%event-location%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement