Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Version: 1.4.1 (For 1.13+ servers)
- #Skript 2.2
- #SkQuery
- #Skript-Mirror 0.9
- function Kits_getPath(t: text = "config") :: string:
- #if "%skquery version%" is "3.21.4":
- # return "../../Kits/%{_t}%.yml"
- return "plugins/Kits/%{_t}%.yml"
- function getItemByText(t: text) :: item:
- if "%{_t}%" contains "named":
- set {_item} to subtext of {_t} between index 0 to index of "named" in {_t} - 2
- set {_item} to {_item} parsed as item
- if {_item} is not item:
- return air
- if "%{_t}%" contains "with lore":
- set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to index of "with lore" in {_t} - 3
- set {_lore} to subtext of {_t} between index index of "with lore" in {_t} + 11 to length of {_t} - 1
- set {_lore::*} to split {_lore} by "||"
- return {_item} named coloured {_name} with lore coloured {_lore::*}
- else:
- set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to length of {_t} - 1
- return {_item} named coloured {_name}
- if "%{_t}%" contains "with lore":
- set {_item} to subtext of {_t} between index 0 to index of "with lore" in {_t} - 2
- set {_lore} to subtext of {_t} between index length of "%{_item}%" + 13 to index length of {_t} - 1
- set {_lore::*} to split {_lore} by "||"
- set {_item} to {_item} parsed as item
- if {_item} is item:
- return {_item} with lore coloured {_lore::*}
- return air
- set {_item} to {_t} parsed as item
- if {_item} is item:
- return {_item}
- return air
- function getIdFromItem(t: text) :: object:
- set {_kits::*} to yaml nodes "kits" from Kits_getPath()
- loop {_kits::*}:
- set {_item} to yaml value "kits.%loop-value%.displayItem" from Kits_getPath()
- if getItemByText({_item})'s name is {_t}:
- return "%loop-value%"
- return null
- function getAllItemsFromKit(ID: text) :: item types:
- set {_items::*} to yaml list "kits.%{_ID}%.items" from Kits_getPath()
- loop {_items::*}:
- add getItemByText("%loop-value%") to {_repairItems::*}
- return {_repairItems::*}
- function getTime(id: text, p: player) :: string:
- set {_sec} to 1000
- set {_min} to 60 * {_sec}
- set {_hour} to 60 * {_min}
- set {_day} to 24 * {_hour}
- set {_conf} to yaml value "kits.%{_id}%.%{_p}%" from Kits_getPath("players")
- set {_ms} to {System}.currentTimeMillis() - {_conf}
- if "%{_ms}%" contains "-":
- set {_ms} to "%{_ms}%"
- replace all "-" with "" in {_ms}
- set {_ms} to {_ms} parsed as number
- set {_res} to ""
- if {_ms} > {_day}:
- set {_res} to "%{_res}% %floor({_ms} / {_day})% dni "
- set {_ms} to {Math}.floorMod({_ms} and {_day})
- if {_ms} > {_hour}:
- set {_res} to "%{_res}%%floor({_ms} / {_hour})% godz. "
- set {_ms} to {Math}.floorMod({_ms} and {_hour})
- if {_ms} > {_min}:
- set {_res} to "%{_res}%%floor({_ms} / {_min})% min. "
- set {_ms} to {Math}.floorMod({_ms} and {_min})
- if {_ms} > {_sec}:
- set {_res} to "%{_res}%%floor({_ms} / {_sec})% sek."
- set {_ms} to {Math}.floorMod({_ms} and {_sec})
- return {_res}
- return "&aTeraz"
- function getInventory(t: text, p: player, action: text = "PPM") :: inventory:
- #Enums:
- #MAIN
- #ID
- if {_t} is "MAIN":
- set {_kits::*} to yaml nodes "kits" from Kits_getPath()
- set {_rows} to ceil("%size of {_kits::*}%" parsed as integer / 9)
- set {_x} to chest with {_rows} rows named "&eZestawy"
- loop {_kits::*}:
- set {_pex} to yaml value "kits.%loop-value%.permission" from Kits_getPath()
- if {_pex} is not "<none>":
- if {_p} has permission "%{_pex}%":
- set {_hasPermission} to "&aTAK"
- else:
- set {_hasPermission} to "&cNIE"
- else:
- set {_hasPermission} to "&aTAK"
- set {_lore::1} to " &7Posiadasz uprawnienia: %{_hasPermission}%"
- set {_lore::2} to " &7Dostepny za: %getTime(loop-value, {_p})%"
- set {_timespan} to yaml value "kits.%loop-value%.time" from Kits_getPath()
- replace all "minutes" and "minute" with "min." in {_timespan}
- replace all "seconds" and "second" with "sek." in {_timespan}
- replace all "days" and "day" with "dni." in {_timespan}
- replace all "hours" and "hour" with "godz." in {_timespan}
- replace all " and " with " " in {_timespan}
- set {_lore::3} to " &7Zestaw mozna brac raz na: &a%{_timespan}%"
- if yaml value "kits.%loop-value%.activate" from Kits_getPath() is true:
- set {_activate} to "&awlaczony"
- else:
- set {_activate} to "&cwylaczony"
- set {_lore::4} to " &7Zestaw jest w tej chwili: %{_activate}%"
- set {_guiReceive} to yaml value "kits.%loop-value%.guiReceive" from Kits_getPath()
- set {_guiReceive} to {_guiReceive} ? "&awlaczone" : "&cwylaczone"
- set {_lore::5} to " &7Branie z skrzynki: %{_guiReceive}%"
- set {_lore::6} to ""
- set {_lore} to "%{_lore::*}%"
- replace all ", " and " and " with "%newline%" in {_lore}
- set {_lore} to "%{_lore}%|| &eKliknij LPM, aby wziac zestaw.|| &eKliknij PPM, aby obejrzec zestaw."
- set {_yaml} to yaml value "kits.%loop-value%.displayItem" from Kits_getPath()
- set {_item} to getItemByText({_yaml})
- set slot loop-index parsed as integer - 1 of {_x} to {_item} named " &eZestaw: %coloured name of {_item}%" with lore {_lore::*}
- clear {_pex}, {_lore::*}, {_timespan}, {_activate}, {_lore}, {_yaml} and {_item}
- return {_x}
- if yaml value "kits.%{_t}%.displayItem" from Kits_getPath() is set:
- if {_action} is "PPM":
- set {_yaml} to yaml value "kits.%{_t}%.displayItem" from Kits_getPath()
- set {_item} to getItemByText({_yaml})
- set {_items::*} to getAllItemsFromKit({_t})
- set {_rows} to ceil("%size of {_items::*}%" parsed as integer / 9)
- set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_item}%"
- loop {_items::*}:
- set slot loop-index parsed as integer - 1 of {_x} to loop-value
- return {_x}
- if {_action} is "LPM":
- set {_yaml} to yaml value "kits.%{_t}%.displayItem" from Kits_getPath()
- set {_item} to getItemByText({_yaml})
- set {_rows} to ceil("%size of {kKits::%{_p}%::%{_id}%::*}%" parsed as integer / 9)
- set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_item}%"
- loop {kKits::%{_p}%::%{_id}%::*}:
- set slot loop-index parsed as integer - 1 of {_x} to loop-value
- return {_x}
- on script load:
- import "java.lang.Math"
- import "java.lang.Long"
- import "java.lang.System"
- import "org.bukkit.event.inventory.InventoryClickEvent"
- if yaml value "autoRefreshInGUI" from Kits_getPath() is not set:
- set yaml value "autoRefreshInGUI" from Kits_getPath() to true
- if yaml nodes "kits" from Kits_getPath() is not set:
- set yaml value "kits.test.displayItem" from Kits_getPath() to "64 steak named ""&8Moj test &r&lKit"""
- set yaml value "kits.test.permission" from Kits_getPath() to "<none>"
- set yaml value "kits.test.time" from Kits_getPath() to "5 hour"
- set yaml value "kits.test.activate" from Kits_getPath() to true
- set yaml value "kits.test.guiReceive" from Kits_getPath() to true
- add "64 steak named ""&7Start"" with lore ""&eTwoje startowe miesko||||&c&lSMACZNEGO!""" to yaml list "kits.test.items" from Kits_getPath()
- add "diamond pickaxe of efficiency 10 and unbreaking 3 named ""&6Super kox"" with lore ""&6Kopie 3x3||||&cSerdecznie polecam||&3&l&nKnugi""" to yaml list "kits.test.items" from Kits_getPath()
- set yaml value "kits.drugi.displayItem" from Kits_getPath() to "wooden sword named ""&cKit &lVIP"""
- set yaml value "kits.drugi.permission" from Kits_getPath() to "easyhc.vip"
- set yaml value "kits.drugi.time" from Kits_getPath() to "2 days and 32 minutes"
- set yaml value "kits.drugi.activate" from Kits_getPath() to false
- set yaml value "kits.test.guiReceive" from Kits_getPath() to false
- add "diamond helmet of protection 4 and unbreaking 3 named ""&6Helm VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
- add "diamond chestplate of protection 4 and unbreaking 3 named ""&6Zbroja VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
- add "diamond leggings of protection 4 and unbreaking 3 named ""&6Spodnie VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
- add "diamond boots of protection 4 and unbreaking 3 named ""&6Buty VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
- add "diamond sword of sharpness 5 and unbreaking 3 named ""&6Miecz VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
- on "org.bukkit.event.inventory.InventoryClickEvent":
- set {_name} to event.getWhoClicked().getOpenInventory().getTitle()
- if "%{_name}%" contains "&eZestaw:":
- set {_p} to event.getWhoClicked()
- set {_id} to {_name}
- replace all "&eZestaw: " in {_id} with ""
- set {_id} to getIdFromItem({_id})
- if {kKits::%{_p}%::%{_id}%} is set:
- stop
- cancel event
- if event.isRightClick() is true:
- set {_p} to event.getWhoClicked()
- close {_p}'s inventory
- wait 2 tick
- open getInventory("MAIN", {_p}) to {_p}
- stop
- if "%{_name}%" is "&eZestawy":
- cancel event
- if "%event.getCurrentItem()%" is "0 air":
- stop
- set {_p} to event.getWhoClicked()
- set {_id} to getIdFromItem(event.getCurrentItem().getItemMeta().getDisplayName().substring(11))
- if yaml value "kits.%{_id}%.displayItem" from Kits_getPath() is set:
- if event.isShiftClick() is true:
- stop
- if event.isLeftClick() is true:
- set {_lore::*} to lore of event.getCurrentItem()
- if "%{_lore::4}%" contains "wylaczony":
- stop
- if "%{_lore::5}%" contains "wlaczone":
- if "%{_lore::2}%" contains "&aTeraz":
- set {kKits::%{_p}%::%{_id}%::*} to getAllItemsFromKit({_id})
- set {_timespan} to yaml value "kits.%{_id}%.time" from Kits_getPath()
- set {_timespan} to {_timespan} parsed as timespan
- set {_time} to now
- add {_timespan} to {_time}
- set yaml value "kits.%{_id}%.%{_p}%" from Kits_getPath("players") to {_time}.getTimestamp()
- set {_broadcast} to yaml value "kits.%{_id}%.broadcast" from Kits_getPath()
- if {_broadcast} is true:
- broadcast "&c* &7Gracz %{_p}% wzial kit: %event.getCurrentItem().getItemMeta().getDisplayName().substring(11)%"
- if size of {kKits::%{_p}%::%{_id}%::*} is larger than 0:
- set {_rows} to ceil("%size of {kKits::%{_p}%::%{_id}%::*}%" parsed as integer / 9)
- set {_yaml} to yaml value "kits.%{_id}%.displayItem" from Kits_getPath()
- set {_name} to getItemByText({_yaml})
- set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_name}%"
- loop {kKits::%{_p}%::%{_id}%::*}:
- set slot loop-index parsed as integer - 1 of {_x} to loop-value
- close {_p}'s inventory
- wait 2 tick
- open {_x} to {_p}
- set {kKits::%{_p}%::%{_id}%} to true
- stop
- if "%{_lore::2}%" doesn't contain "&aTeraz":
- stop
- set {_lore::1} to 3 last characters of {_lore::1}
- if "%{_lore::1}%" is "NIE":
- stop
- set {_items::*} to getAllItemsFromKit({_id})
- if {_p} has enough space for {_items::*}:
- give {_p} {_items::*}
- else:
- send "&c* &7Nie posiadasz tyle miejsca w ekwipunku." to {_p}
- stop
- set {_timespan} to yaml value "kits.%{_id}%.time" from Kits_getPath()
- set {_broadcast} to yaml value "kits.%{_id}%.broadcast" from Kits_getPath()
- if {_broadcast} is true:
- broadcast "&c* &7Gracz %{_p}% wzial kit: %event.getCurrentItem().getItemMeta().getDisplayName().substring(11)%"
- close {_p}'s inventory
- set {_timespan} to {_timespan} parsed as timespan
- set {_time} to now
- add {_timespan} to {_time}
- set yaml value "kits.%{_id}%.%{_p}%" from Kits_getPath("players") to {_time}.getTimestamp()
- stop
- if event.isRightClick() is true:
- close {_p}'s inventory
- wait 2 tick
- open getInventory({_id}, {_p}) to {_p}
- stop
- on inventory close:
- set {_name} to (event).getPlayer().getOpenInventory().getTitle()
- if {_name} contains "&eZestaw:":
- replace all "&eZestaw: " in {_name} with ""
- set {_id} to getIdFromItem({_name})
- if yaml value "kits.%{_id}%.guiReceive" from Kits_getPath() is true:
- if {kKits::%player%::%{_id}%} is set:
- clear {kKits::%player%::%{_id}%::*}
- set {kKits::%player%::%{_id}%::*} to all items in player's current inventory
- clear {kKits::%player%::%{_id}%}
- command /kit [<text>]:
- aliases: kits
- trigger:
- open getInventory("MAIN", player) to player
- every 2 second:
- if yaml value "autoRefreshInGUI" from Kits_getPath() is true:
- loop all players:
- if (loop-player).getOpenInventory().getTitle() is "&eZestawy":
- #if inventory name of loop-player's current inventory is "&eZestawy":
- set {_items::*} to all items in loop-player's current inventory
- loop {_items::*}:
- if "%lore of loop-value-2%" doesn't contain "&7Dostepny za: &aTeraz":
- set {_lore::*} to lore of loop-value-2
- set {_name} to subtext of name of loop-value-2 between index 12 and length of name of loop-value-2
- set {_id} to getIdFromItem({_name})
- set {_oldTime} to subtext of {_lore} between index index of "Dostepny za:" in {_lore} + 13 and index index of "Zestaw mozna" in {_lore} - 6
- set {_newTime} to getTime({_id}, loop-player)
- set {_lore::2} to " &7Dostepny za: %{_newTime}%"
- set loop-player's current inventory's slot loop-index parsed as integer - 1 to loop-value-2 with lore {_lore::*}
- clear {_lore}
Advertisement
Add Comment
Please, Sign In to add comment