Files
config.sk
discord.sk
optimization.sk
spawn.sk
Code
4 158
optimization.sk
# ===================================================
# ServerOptimizerPro - Optimization Module
# Periodic cleanup + mob cap limiter + admin controls
# ===================================================
function doCleanup():
set {_items} to 0
set {_arrows} to 0
set {_orbs} to 0
loop all entities in all worlds:
if loop-entity is a dropped item:
add 1 to {_items}
delete loop-entity
else if loop-entity is an arrow:
add 1 to {_arrows}
delete loop-entity
else if loop-entity is an experience orb:
add 1 to {_orbs}
delete loop-entity
if {optimizer::enabled} is true:
broadcast "{@optimizer-prefix} &7ᴄʟᴇᴀɴᴜᴘ ᴄᴏᴍᴘʟᴇᴛᴇ &8» &fɪᴛᴇᴍꜱ: &a%{_items}% &8| &fᴀʀʀᴏᴡꜱ: &a%{_arrows}% &8| &fᴏʀʙꜱ: &a%{_orbs}%"
every {@cleanup-interval-minutes} minutes:
doCleanup()
every {@mobcap-check-minutes} minutes:
loop all worlds:
set {_world} to loop-world
set {_count} to 0
set {_removed} to 0
loop all entities in {_world}:
if loop-entity is a living entity:
if loop-entity is not a player:
add 1 to {_count}
if {_count} > {@max-living-entities-per-world}:
set {_excess} to {_count} - {@max-living-entities-per-world}
loop all entities in {_world}:
if {_removed} >= {_excess}:
stop loop
if loop-entity is a living entity:
if loop-entity is not a player:
if loop-entity is not tamed:
if name of loop-entity is not set:
delete loop-entity
add 1 to {_removed}
if {optimizer::enabled} is true:
broadcast "{@optimizer-prefix} &7ᴍᴏʙ ᴄᴀᴘ ʀᴇᴀᴄʜᴇᴅ ɪɴ &a%{_world}% &8» &cʀᴇᴍᴏᴠᴇᴅ %{_removed}% ᴇɴᴛɪᴛɪᴇꜱ"
command /forceclean:
permission: optimizer.forceclean
permission message: {@prefix} &cɴᴏ ᴘᴇʀᴍɪꜱꜱɪᴏɴ.
trigger:
doCleanup()
send "{@optimizer-prefix} &aᴍᴀɴᴜᴀʟ ᴄʟᴇᴀɴᴜᴘ ᴇxᴇᴄᴜᴛᴇᴅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ." to player
command /togglecleanup:
permission: optimizer.toggle
permission message: {@prefix} &cɴᴏ ᴘᴇʀᴍɪꜱꜱɪᴏɴ.
trigger:
if {optimizer::enabled} is true:
set {optimizer::enabled} to false
send "{@optimizer-prefix} &cᴄʟᴇᴀɴᴜᴘ ʙʀᴏᴀᴅᴄᴀꜱᴛꜱ ᴅɪꜱᴀʙʟᴇᴅ." to player
else:
set {optimizer::enabled} to true
send "{@optimizer-prefix} &aᴄʟᴇᴀɴᴜᴘ ʙʀᴏᴀᴅᴄᴀꜱᴛꜱ ᴇɴᴀʙʟᴇᴅ." to player
on join:
wait 1 second
send "{@optimizer-prefix} &7ᴛʜɪꜱ ꜱᴇʀᴠᴇʀ ɪꜱ ʀᴜɴɴɪɴɢ &6ꜱᴍᴏᴏᴛʜ ᴏᴘᴛɪᴍɪᴢᴀᴛɪᴏɴ &7ᴛᴏᴏʟꜱ ꜰᴏʀ ᴀ &aʟᴀɢ-ꜰʀᴇᴇ ᴇxᴘᴇʀɪᴇɴᴄᴇ." to player