Files
custom-kits.sk
Code
1 192
custom-kits.sk
# Custom Kits — vanilla Skript only
# Place this file in plugins/Skript/scripts/ and run:
# /sk reload custom-kits
#
# Permissions:
# kity.miecz, kity.mace, kity.spear
# kity.admin
options:
menu-title: &8&lDOSTĘPNE KITY
cooldown-miecz: 24 hours
cooldown-mace: 24 hours
cooldown-spear: 24 hours
on script load:
create-default-kits()
function create-default-kits():
if {kit::miecz::items::*} is not set:
set {_sword} to diamond sword
enchant {_sword} with sharpness 3
add {_sword} to {kit::miecz::items::*}
set {_apples} to golden apple
set amount of {_apples} to 8
add {_apples} to {kit::miecz::items::*}
add diamond helmet to {kit::miecz::items::*}
add diamond chestplate to {kit::miecz::items::*}
add diamond leggings to {kit::miecz::items::*}
add diamond boots to {kit::miecz::items::*}
if {kit::mace::items::*} is not set:
set {_mace} to mace
enchant {_mace} with density 3
add {_mace} to {kit::mace::items::*}
set {_charges} to wind charge
set amount of {_charges} to 16
add {_charges} to {kit::mace::items::*}
set {_apples} to golden apple
set amount of {_apples} to 4
add {_apples} to {kit::mace::items::*}
add netherite helmet to {kit::mace::items::*}
add netherite chestplate to {kit::mace::items::*}
add netherite leggings to {kit::mace::items::*}
add netherite boots to {kit::mace::items::*}
if {kit::spear::items::*} is not set:
set {_trident} to trident
enchant {_trident} with loyalty 3
add {_trident} to {kit::spear::items::*}
add shield to {kit::spear::items::*}
set {_potions} to potion of swiftness
set amount of {_potions} to 2
add {_potions} to {kit::spear::items::*}
add diamond helmet to {kit::spear::items::*}
add diamond chestplate to {kit::spear::items::*}
add diamond leggings to {kit::spear::items::*}
add diamond boots to {kit::spear::items::*}
function kit-status(kit: text, p: player) :: text:
if {_p} does not have permission "kity.%{_kit}%":
return "&cBrak uprawnień!"
if {kit::cooldown::%uuid of {_p}%::%{_kit}%} is set:
if now is before {kit::cooldown::%uuid of {_p}%::%{_kit}%}:
set {_remaining} to difference between {kit::cooldown::%uuid of {_p}%::%{_kit}%} and now
set {_hours} to rounded down ({_remaining} / 1 hour)
set {_minutes} to rounded down (({_remaining} - ({_hours} * 1 hour)) / 1 minute)
return "&cDostępny za: %{_hours}%h %{_minutes}%m"
return "&aDostępny do odebrania"
function get-kit-icon(kit: text, p: player) :: item:
if {_kit} is "miecz":
set {_icon} to diamond sword
set name of {_icon} to "&b&lZestaw Miecz"
else if {_kit} is "mace":
set {_icon} to mace
set name of {_icon} to "&c&lZestaw Buława"
else:
set {_icon} to trident
set name of {_icon} to "&e&lZestaw Włócznia"
set {_lore::*} to "&7Status: %{kit-status({_kit}, {_p})}%"
add "&8" to {_lore::*}
add "&eKliknij, aby odebrać zestaw." to {_lore::*}
set lore of {_icon} to {_lore::*}
return {_icon}
function open-kit-menu(p: player):
open chest inventory with 3 rows named "{@menu-title}" to {_p}
set {_pane} to gray stained glass pane named " "
loop 27 times:
set slot (loop-number - 1) of {_p}'s current inventory to {_pane}
set {_miecz} to get-kit-icon("miecz", {_p})
set {_mace} to get-kit-icon("mace", {_p})
set {_spear} to get-kit-icon("spear", {_p})
set slot 11 of {_p}'s current inventory to {_miecz}
set slot 13 of {_p}'s current inventory to {_mace}
set slot 15 of {_p}'s current inventory to {_spear}
function claim-kit(p: player, kit: text):
if {_p} does not have permission "kity.%{_kit}%":
send "&cNie masz uprawnień do odebrania tego zestawu!" to {_p}
stop
if {kit::cooldown::%uuid of {_p}%::%{_kit}%} is set:
if now is before {kit::cooldown::%uuid of {_p}%::%{_kit}%}:
send "&cTen zestaw jest jeszcze niedostępny. %{kit-status({_kit}, {_p})}%" to {_p}
stop
if {kit::%{_kit}%::items::*} is not set:
send "&cTen zestaw nie ma zapisanych przedmiotów." to {_p}
stop
loop {kit::%{_kit}%::items::*}:
give loop-value to {_p}
if {_kit} is "miecz":
set {_duration} to {@cooldown-miecz}
else if {_kit} is "mace":
set {_duration} to {@cooldown-mace}
else:
set {_duration} to {@cooldown-spear}
set {kit::cooldown::%uuid of {_p}%::%{_kit}%} to now + {_duration}
send "&aOdebrano zestaw %{_kit}%!" to {_p}
play sound "entity.player.levelup" with volume 1 and pitch 1 to {_p}
command /kit [<text>]:
aliases: kity
trigger:
if arg-1 is not set:
open-kit-menu(player)
stop
if arg-1 is "miecz":
claim-kit(player, "miecz")
else if arg-1 is "mace":
claim-kit(player, "mace")
else if arg-1 is "spear":
claim-kit(player, "spear")
else:
send "&cNieznany zestaw. Użyj: &e/kit miecz&c, &e/kit mace&c lub &e/kit spear&c." to player
command /kitedit [<text>]:
permission: kity.admin
permission message: &cNie masz uprawnień do edycji zestawów!
trigger:
if arg-1 is not set:
send "&cUżycie: &e/kitedit <miecz|mace|spear>" to player
stop
if arg-1 is not "miecz" and arg-1 is not "mace" and arg-1 is not "spear":
send "&cNieprawidłowy zestaw. Wybierz: &emiecz&c, &emace&c lub &espear&c." to player
stop
set {_kit} to arg-1
delete {kit::%{_kit}%::items::*}
loop all items in player's inventory:
if loop-value is not air:
add loop-value to {kit::%{_kit}%::items::*}
send "&aPomyślnie zapisano aktualny ekwipunek jako zestaw %{_kit}%!" to player
on inventory click:
if name of event-inventory is "{@menu-title}":
cancel event
if clicked inventory is not event-inventory:
stop
if clicked slot is 11:
close player's inventory
claim-kit(player, "miecz")
else if clicked slot is 13:
close player's inventory
claim-kit(player, "mace")
else if clicked slot is 15:
close player's inventory
claim-kit(player, "spear")