Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isAroundChest(loc: location) :: location:
- if block north {_loc} is chest:
- return location of block north {_loc}
- if block west {_loc} is chest:
- return location of block west {_loc}
- if block east {_loc} is chest:
- return location of block east {_loc}
- if block south {_loc} is chest:
- return location of block south {_loc}
- else:
- return null
- options:
- nameFolder: "plugins/TreasureSkript"
- nameConfig: "plugins/TreasureSkript/config.yml"
- on script load:
- if folder {@nameFolder} is not exists:
- create folder {@nameFolder}
- create file {@nameConfig}
- set "small-refresh" to "12" in {@nameConfig}
- set "large-refresh" to "24" in {@nameConfig}
- set "small-amount-items-min" to "1" in {@nameConfig}
- set "small-amount-items-max" to "3" in {@nameConfig}
- set "large-amount-items-min" to "4" in {@nameConfig}
- set "large-amount-items-max" to "5" in {@nameConfig}
- set "items.1" to "3 apple" in {@nameConfig}
- set "items.2" to "5 stone" in {@nameConfig}
- set "items.3" to "2 stick" in {@nameConfig}
- set "items.4" to "3 322:1" in {@nameConfig}
- set "items.5" to "1 diamond" in {@nameConfig}
- stop
- command /tchest [<text>]:
- trigger:
- if player has permission "treasureskript.admin":
- if arg 1 is "aktywuj":
- set {tchest.%player%} to true
- send "&7Kliknij PPM na skrzynki, by dodac je do tchest'ow"
- stop
- if arg 1 is "anuluj":
- clear {tchest.%player%}
- send "&7Juz nie dodajesz tchest'ow"
- stop
- send "&aKomendy dodawania skrzynek."
- send "&a/tchest aktywuj &7- &8aktywuje dodawanie skrzynek."
- send "&a/tchest anuluj &7- &8anuluje dodawania skrzynek."
- stop
- send "Unknown command. Type ""/help"" for help. xD"
- stop
- on rightclick on chest:
- if {tchest.%player%} is true:
- cancel event
- loop {tchest::*}:
- if location of event-block is loop-value:
- send "&cTa skrzynka jest juz dodana."
- stop
- if isAroundChest(location of event-block) is set:
- add location of event-block to {tchest::*}
- add isAroundChest(location of event-block) to {tchest::*}
- else:
- add location of event-block to {tchest::*}
- send "&cDodales skrzynke do tchest'a"
- stop
- loop {tchest::*}:
- if location of event-block is loop-value:
- cancel event
- if isAroundChest(location of event-block) is set:
- set {_rows} to 6
- open chest with 6 rows to player
- else:
- set {_rows} to 3
- open chest with 3 rows to player
- set {tchest.%player%.opened} to location of event-block
- set {tchest.%player%.rows} to {_rows}
- wait 2 tick
- if {tchest.%player%::%location of event-block%} is set:
- if now is smaller than {tchest.%player%::%location of event-block%}:
- loop {tchest.%player%::%location of event-block%::*}:
- set {_int} to loop-index-2 parsed as integer
- set player's current inventory's slot {_int} to loop-value-2
- stop
- if {_rows} is 3:
- set {_amount} to random integer between single value "small-amount-items-min" get of {@nameConfig} parsed as integer and single value "small-amount-items-max" get of {@nameConfig} parsed as integer
- else:
- set {_amount} to random integer between single value "large-amount-items-min" get of {@nameConfig} parsed as integer and single value "large-amount-items-max" get of {@nameConfig} parsed as integer
- set {_it::*} to configuration section "items" get of {@nameConfig}
- loop size of {_it::*} times:
- add single value "items.%loop-number%" get of {@nameConfig} to {_itemsConf::*}
- if {_amount} is larger than size of {_it::*}:
- set {_amount} to size of {_it::*}
- if {_amount} is smaller than or equal to 0:
- stop
- if {_amount} is not set:
- stop
- loop 10000 times:
- if size of {_slots::*} is smaller than {_amount}:
- set {_a} to random integer between 0 and 26
- loop {_slots::*}:
- if loop-value-2 is {_a}:
- set {_error} to true
- exit loop
- if {_error} is not set:
- add {_a} to {_slots::*}
- clear {_error}
- else:
- exit loop
- loop {_slots::*}:
- set {_item} to random text out of {_itemsConf::*}
- remove {_item} from {_itemsConf::*}
- set {_ilosc} to first character of {_item} parsed as integer
- set {_item} to subtext of {_item} between index 3 and length of {_item}
- set {_item} to "%random integer between 1 and {_ilosc}% %{_item}%" parsed as item type
- set {_slot} to "%loop-value-2%" parsed as integer
- set player's current inventory's slot {_slot} to {_item}
- set {_i} to 0
- if isAroundChest(location of event-block) is set:
- set {_newTime} to now
- set {_lR} to single value "large-refresh" get of {@nameConfig}
- add "%{_lR}% hour" parsed as timespan to {_newTime}
- set {tchest.%player%::%location of event-block%} to {_newTime}
- set {tchest.%player%::%isAroundChest(location of event-block)%} to {_newTime}
- loop {_rows}*9 times:
- set {tchest.%player%::%location of event-block%::%{_i}%} to player's current inventory's slot {_i}
- set {tchest.%player%::%isAroundChest(location of event-block)%::%{_i}%} to player's current inventory's slot {_i}
- add 1 to {_i}
- else:
- set {_newTime} to now
- set {_sR} to single value "small-refresh" get of {@nameConfig}
- add "%{_sR}% hour" parsed as timespan to {_newTime}
- set {tchest.%player%::%location of event-block%} to {_newTime}
- loop {_rows}*9 times:
- set {tchest.%player%::%location of event-block%::%{_i}%} to player's current inventory's slot {_i}
- add 1 to {_i}
- on inventory close:
- if {tchest.%player%.opened} is set:
- set {_i} to 0
- loop {tchest.%player%.rows} * 9 times:
- if isAroundChest({tchest.%player%.opened}) is set:
- set {_loc2} to isAroundChest({tchest.%player%.opened})
- set {tchest.%player%::%{_loc2}%::%{_i}%} to player's current inventory's slot {_i}
- set {tchest.%player%::%{tchest.%player%.opened}%::%{_i}%} to player's current inventory's slot {_i}
- add 1 to {_i}
- clear {tchest.%player%.opened}
- clear {tchest.%player%.rows}
- #{tchest::*} - dodane skrzynki
- #{tchest.%player::%lokacja%} - czas otworzenia + czas z configu
- #{tchest.%player%::%lokacja::*} - index - slot, value - item
Advertisement
Add Comment
Please, Sign In to add comment