Files
genust.sk
Code
1 337
genust.sk
# =========================================================================
# GENUST - GEN RAID SERVER CORE SCRIPT
# Requires: Skript, SkBee, SkParticle
# =========================================================================
options:
GenBlock: gray stained glass
MaxGens: 5
ItemPrice: 1
StoreTag: &astore.jozmc.net
# =========================================================================
# SCOREBOARD SYSTEM (SkBee Boards)
# =========================================================================
function getMonthName(m: integer) :: text:
if {_m} = 1:
return "Jan"
if {_m} = 2:
return "Feb"
if {_m} = 3:
return "Mar"
if {_m} = 4:
return "Apr"
if {_m} = 5:
return "May"
if {_m} = 6:
return "Jun"
if {_m} = 7:
return "Jul"
if {_m} = 8:
return "Aug"
if {_m} = 9:
return "Sep"
if {_m} = 10:
return "Oct"
if {_m} = 11:
return "Nov"
return "Dec"
function updateBoard(p: player):
set {_uuid} to uuid of {_p}
set {_level} to {level::%{_uuid}%}
if {_level} is not set:
set {_level} to 1
set {_xp} to {xp::%{_uuid}%}
if {_xp} is not set:
set {_xp} to 0
set {_bal} to {balance::%{_uuid}%}
if {_bal} is not set:
set {_bal} to 0
set {_gems} to {gems::%{_uuid}%}
if {_gems} is not set:
set {_gems} to 0
set {_credits} to {credits::%{_uuid}%}
if {_credits} is not set:
set {_credits} to 0
set {_kills} to {kills::%{_uuid}%}
if {_kills} is not set:
set {_kills} to 0
set {_gens} to {placed_gens::%{_uuid}%}
if {_gens} is not set:
set {_gens} to 0
# XP percent toward next level (100 XP per level)
set {_xp_needed} to {_level} * 100
set {_xp_pct} to floor({_xp} * 100 / {_xp_needed})
# Balance formatted to 2dp — strip any locale commas
set {_bal_raw} to "%floor({_bal} * 100) / 100%"
replace all "," with "" in {_bal_raw}
# Date string
set {_month_name} to getMonthName(month of now)
set {_date} to "&8⏰ &7%{_month_name}% %day of now%, %year of now%"
# Always build a fresh board and assign — avoids null-board edge cases
set {_b} to new board with title "&6&lGENUST"
set line 15 of {_b} to {_date}
set line 14 of {_b} to " "
set line 13 of {_b} to "&7Level: &e%{_level}%&6★ &7(%{_xp_pct}%%)"
set line 12 of {_b} to " "
set line 11 of {_b} to "&7Balance: &a$%{_bal_raw}%"
set line 10 of {_b} to "&7Gems: &b✧%{_gems}%"
set line 9 of {_b} to " "
set line 8 of {_b} to "&7Credits: &6🪙%{_credits}%"
set line 7 of {_b} to " "
set line 6 of {_b} to "&7Kills: &f%{_kills}%"
set line 5 of {_b} to "&7Generators: &f%{_gens}%/{@MaxGens}"
set line 4 of {_b} to " "
set line 3 of {_b} to "{@StoreTag}"
set board of {_p} to {_b}
every 2 seconds:
loop all players:
updateBoard(loop-player)
# =========================================================================
# ON JOIN — Init all data then show board
# =========================================================================
on join:
if {balance::%player's uuid%} is not set:
set {balance::%player's uuid%} to 0
if {placed_gens::%player's uuid%} is not set:
set {placed_gens::%player's uuid%} to 0
if {kills::%player's uuid%} is not set:
set {kills::%player's uuid%} to 0
if {level::%player's uuid%} is not set:
set {level::%player's uuid%} to 1
if {xp::%player's uuid%} is not set:
set {xp::%player's uuid%} to 0
if {gems::%player's uuid%} is not set:
set {gems::%player's uuid%} to 0
if {credits::%player's uuid%} is not set:
set {credits::%player's uuid%} to 0
wait 5 ticks
updateBoard(player)
# =========================================================================
# COMMAND: /givegen
# =========================================================================
command /givegen [<player>]:
permission: admin.gens
permission message: &cYou do not have permission to execute this administrative action.
trigger:
if argument 1 is not set:
send "&cSyntax Error! Usage: /givegen <player>" to player
stop
give arg-1 1 {@GenBlock} named "&fCoal Generator Tier 1" with lore " " and "&7Generates banknotes worth" and "&a$1 &7every 10 seconds." and " " and "&7Upgrade this generator by" and "doing &eShift + Right Click"
send "&aSuccessfully gave 1x &fCoal Generator Tier 1 &ato &e%arg-1%&a." to player
send "&aYou received 1x &fCoal Generator Tier 1&a!" to arg-1
# =========================================================================
# GENERATOR PLACEMENT
# =========================================================================
on place of {@GenBlock}:
if name of player's tool is "&fCoal Generator Tier 1":
if {placed_gens::%player's uuid%} is not set:
set {placed_gens::%player's uuid%} to 0
if {placed_gens::%player's uuid%} >= {@MaxGens}:
cancel event
send "&cLimit Exceeded! You can only place a maximum of {@MaxGens} Generators." to player
stop
add 1 to {placed_gens::%player's uuid%}
set {_loc} to location of event-block
add {_loc} to {gen_locations::%player's uuid%::*}
set {_x} to "%floor(x-coordinate of {_loc}) + 0.5%"
set {_z} to "%floor(z-coordinate of {_loc}) + 0.5%"
set {_as_y} to "%floor(y-coordinate of {_loc}) - 0.45%"
set {_text_y} to "%floor(y-coordinate of {_loc}) + 1.35%"
replace all "," with "" in {_x}
replace all "," with "" in {_as_y}
replace all "," with "" in {_text_y}
replace all "," with "" in {_z}
# Invisible small armor stand with coal ore on head
execute console command "execute at %player% run summon armor_stand %{_x}% %{_as_y}% %{_z}% {Tags:[""gen_display""],Invisible:1b,Small:1b,Marker:1b,NoGravity:1b,ArmorItems:[{},{},{},{id:""minecraft:coal_ore"",count:1}]}"
# Floating $1 text display — full transformation required for 1.20.2+
execute console command "execute at %player% run summon text_display %{_x}% %{_text_y}% %{_z}% {Tags:[""gen_display""],text:'{""text"":""§a§l$1""}',background:0,billboard:""center"",transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1.2f,1.2f,1.2f]}}"
send "&aGenerator Placed! &7(%{placed_gens::%player's uuid%}%/{@MaxGens})" to player
else:
stop
# =========================================================================
# GENERATOR BREAKING
# =========================================================================
on break of {@GenBlock}:
if {gen_locations::%player's uuid%::*} contains location of event-block:
remove location of event-block from {gen_locations::%player's uuid%::*}
subtract 1 from {placed_gens::%player's uuid%}
set {_loc} to location of event-block
set {_x} to floor(x-coordinate of {_loc}) + 0.5
set {_y} to floor(y-coordinate of {_loc}) + 0.5
set {_z} to floor(z-coordinate of {_loc}) + 0.5
set {_sx} to "%{_x}%"
set {_sy} to "%{_y}%"
set {_sz} to "%{_z}%"
replace all "," with "" in {_sx}
replace all "," with "" in {_sy}
replace all "," with "" in {_sz}
execute console command "execute at %player% run kill @e[tag=gen_display,x=%{_sx}%,y=%{_sy}%,z=%{_sz}%,distance=..1.5]"
send "&cGenerator Destroyed! &7(%{placed_gens::%player's uuid%}%/{@MaxGens})" to player
cancel event
set event-block to air
drop 1 {@GenBlock} named "&fCoal Generator Tier 1" with lore " " and "&7Generates banknotes worth" and "&a$1 &7every 10 seconds." and " " and "&7Upgrade this generator by" and "doing &eShift + Right Click" at event-block