Files
plugins
Code
1 296
plugins/Skript/scripts/HomeGUI.sk
# ββββββββββββββββββββββββββββββββββββββββββββ
# β HomeGUI - Skript System β
# β Clean GUI + Countdown Teleport System β
# ββββββββββββββββββββββββββββββββββββββββββββ
options:
prefix: &8[&bHome&8]
maxhomes: 5
countdown: 3
gui-title: &8Β» &bYour Homes &8Β«
# βββββββββββββββββββββββββββββββββββββββββββ
# FUNCTION: Open Home GUI
# βββββββββββββββββββββββββββββββββββββββββββ
function open_home_gui(p: player):
set {_uuid} to uuid of {_p}
set {_max} to {@maxhomes}
set {_inv} to chest inventory with 6 rows named "{@gui-title}"
# --- Fill border with black glass panes ---
loop integers from 0 to 53:
set slot loop-value of {_inv} to black stained glass pane named " "
# --- Header item ---
set slot 4 of {_inv} to nether star named "&b&lYour Homes" with lore "&7Manage your saved homes.|&8Total: &e%size of {homes::%{_uuid}%::*}%&8/&e%{_max}%"
# --- Home slots: row 2 (slots 10-14) and row 3 (slots 19-23) ---
set {_slot1} to 10
set {_slot2} to 11
set {_slot3} to 12
set {_slot4} to 13
set {_slot5} to 14
set {_slots::1} to 10
set {_slots::2} to 11
set {_slots::3} to 12
set {_slots::4} to 13
set {_slots::5} to 14
set {_i} to 0
loop {homes::%{_uuid}%::*}:
add 1 to {_i}
if {_i} > {_max}:
stop
set {_name} to loop-index
set {_slot} to {_slots::%{_i}%}
set {_home_item} to cyan bed named "&b%{_name}%" with lore "&7Β» Click to teleport|&8Home #%{_i}%"
set slot {_slot} of {_inv} to {_home_item}
set {_del_slot} to {_slot} + 18
set slot {_del_slot} of {_inv} to red dye named "&c&lDelete" with lore "&7Β» Click to delete|&e%{_name}%"
loop integers from ({_i} + 1) to {_max}:
set {_slot} to {_slots::%loop-value%}
set slot {_slot} of {_inv} to white bed named "&7Empty Slot" with lore "&7Β» Click to set a new home"
set {_empty_del_slot} to {_slot} + 18
set slot {_empty_del_slot} of {_inv} to gray stained glass pane named "&8No Home" with lore "&7No home set here."
# --- Close button ---
set slot 49 of {_inv} to barrier named "&c&lClose" with lore "&7Click to close this menu"
open {_inv} to {_p}
# βββββββββββββββββββββββββββββββββββββββββββ
# FUNCTION: Start Teleport Countdown
# βββββββββββββββββββββββββββββββββββββββββββ
function start_home_tp(p: player, target: location, homename: text):
set {_uuid} to uuid of {_p}
if {hometp::%{_uuid}%} is set:
send "&8[&bHome&8] &cYou already have a teleport in progress!" to {_p}
stop
set {_secs} to {@countdown}
set {hometp::%{_uuid}%} to {_secs}
set {hometp-loc::%{_uuid}%} to {_target}
set {hometp-name::%{_uuid}%} to {_homename}
set {hometp-lastloc::%{_uuid}%} to location of {_p}
send "{@prefix} &7Teleporting to &b%{_homename}% &7in &e%{_secs}% &7seconds. &8(Don't move!)" to {_p}
send action bar "&bβ³ Teleporting in &f%{_secs}%s&b..." to {_p}
loop {_secs} times:
wait 1 second
if {hometp::%{_uuid}%} is not set:
stop
subtract 1 from {hometp::%{_uuid}%}
if {hometp::%{_uuid}%} > 0:
send action bar "&bβ³ Teleporting in &f%{hometp::%{_uuid}%}%s&b..." to {_p}
else:
teleport {_p} to {hometp-loc::%{_uuid}%}
send action bar "&aβ Teleported to &b%{hometp-name::%{_uuid}%}%&a!" to {_p}
send "{@prefix} &aTeleported to home &b%{hometp-name::%{_uuid}%}%&a." to {_p}
delete {hometp::%{_uuid}%}
delete {hometp-loc::%{_uuid}%}
delete {hometp-name::%{_uuid}%}
delete {hometp-lastloc::%{_uuid}%}
stop
# βββββββββββββββββββββββββββββββββββββββββββ
# FUNCTION: Cancel Teleport
# βββββββββββββββββββββββββββββββββββββββββββ
function cancel_home_tp(p: player):
set {_uuid} to uuid of {_p}
if {hometp::%{_uuid}%} is set:
delete {hometp::%{_uuid}%}
delete {hometp-loc::%{_uuid}%}
delete {hometp-name::%{_uuid}%}
delete {hometp-lastloc::%{_uuid}%}
send action bar "&cβ Teleport cancelled! &8(You moved)" to {_p}
send "{@prefix} &cTeleport cancelled because you moved!" to {_p}
# βββββββββββββββββββββββββββββββββββββββββββ
# COMMAND: /home [name]
# βββββββββββββββββββββββββββββββββββββββββββ
command /home [<text>]:
trigger:
if arg-1 is set:
set {_uuid} to uuid of player
if {homes::%{_uuid}%::%arg-1%} is not set:
send "{@prefix} &cNo home named &e%arg-1% &cfound!"
stop
start_home_tp(player, {homes::%{_uuid}%::%arg-1%}, arg-1)
else:
open_home_gui(player)
# βββββββββββββββββββββββββββββββββββββββββββ
# COMMAND: /sethome <name>
# βββββββββββββββββββββββββββββββββββββββββββ
command /sethome <text>:
trigger:
set {_uuid} to uuid of player
set {_max} to {@maxhomes}
set {_count} to size of {homes::%{_uuid}%::*}
if {homes::%{_uuid}%::%arg-1%} is set:
send "{@prefix} &cA home named &e%arg-1% &calready exists! Use &e/delhome %arg-1% &cto remove it first."
stop
if {_count} >= {_max}:
send "{@prefix} &cYou already have the maximum of &e%{_max}% &chomes!"
stop
set {homes::%{_uuid}%::%arg-1%} to location of player
set {_new} to {_count} + 1
send "{@prefix} &aHome &b%arg-1% &ahas been set! &8(&7%{_new}%&8/&7%{_max}% &8used)"
open_home_gui(player)
# βββββββββββββββββββββββββββββββββββββββββββ
# COMMAND: /delhome <name>
# βββββββββββββββββββββββββββββββββββββββββββ
command /delhome <text>:
trigger:
set {_uuid} to uuid of player
if {homes::%{_uuid}%::%arg-1%} is not set:
send "{@prefix} &cNo home named &e%arg-1% &cfound!"
stop
delete {homes::%{_uuid}%::%arg-1%}
send "{@prefix} &aHome &b%arg-1% &ahas been deleted."
open_home_gui(player)
# βββββββββββββββββββββββββββββββββββββββββββ
# COMMAND: /homes
# βββββββββββββββββββββββββββββββββββββββββββ
command /homes:
trigger:
open_home_gui(player)
# βββββββββββββββββββββββββββββββββββββββββββ
# EVENT: Player Move - Cancel Teleport
# βββββββββββββββββββββββββββββββββββββββββββ
on player move:
set {_uuid} to uuid of player
if {hometp::%{_uuid}%} is set:
set {_old} to {hometp-lastloc::%{_uuid}%}
if {_old} is set:
if floor(x-coordinate of location of player) is not floor(x-coordinate of {_old}):
cancel_home_tp(player)
stop
if floor(y-coordinate of location of player) is not floor(y-coordinate of {_old}):
cancel_home_tp(player)
stop
if floor(z-coordinate of location of player) is not floor(z-coordinate of {_old}):
cancel_home_tp(player)
stop
# βββββββββββββββββββββββββββββββββββββββββββ
# EVENT: Player Quit - Cleanup
# βββββββββββββββββββββββββββββββββββββββββββ
on quit:
set {_uuid} to uuid of player
delete {hometp::%{_uuid}%}
delete {hometp-loc::%{_uuid}%}
delete {hometp-name::%{_uuid}%}
delete {hometp-lastloc::%{_uuid}%}
delete {home-setting::%player%}
# βββββββββββββββββββββββββββββββββββββββββββ