Files
combat-limits.sk
Code
1 53
combat-limits.sk
options:
prefix: &6[Combat Limits] &r
check-interval: 10 seconds
warning-time: 60 seconds
experience-bottle-limit: 128
golden-apple-limit: 128
breeze-rod-limit: 128
cobweb-limit: 128
tnt-minecart-limit: 3
# Add another line here to limit a different item.
function checkCombatLimits(p: player):
limitCombatItem({_p}, experience bottle, {@experience-bottle-limit}, "experience bottles")
limitCombatItem({_p}, golden apple, {@golden-apple-limit}, "golden apples")
limitCombatItem({_p}, breeze rod, {@breeze-rod-limit}, "breeze rods")
limitCombatItem({_p}, cobweb, {@cobweb-limit}, "cobwebs")
limitCombatItem({_p}, minecart with tnt, {@tnt-minecart-limit}, "TNT minecarts")
function limitCombatItem(p: player, item: item type, limit: integer, name: text):
set {_amount} to 0
loop all items in {_p}'s inventory:
if type of loop-item is {_item}:
add amount of loop-item to {_amount}
if {_amount} > {_limit}:
if {combatlimits.warning::%uuid of {_p}%::%{_name}%} is not set:
set {combatlimits.warning::%uuid of {_p}%::%{_name}%} to now
send "{@prefix}&cYou have more than %{_limit}% %{_name}%. Store the excess within {@warning-time} or it will be deleted." to {_p}
else if difference between now and {combatlimits.warning::%uuid of {_p}%::%{_name}%} >= {@warning-time}:
set {_excess} to {_amount} - {_limit}
set {_remaining} to {_excess}
loop integers from 0 to 40:
if {_remaining} <= 0:
stop loop
set {_stack} to slot loop-number of {_p}'s inventory
if type of {_stack} is {_item}:
if amount of {_stack} <= {_remaining}:
subtract amount of {_stack} from {_remaining}
set slot loop-number of {_p}'s inventory to air
else:
set {_newAmount} to amount of {_stack} - {_remaining}
set slot loop-number of {_p}'s inventory to {_newAmount} of {_stack}
set {_remaining} to 0
delete {combatlimits.warning::%uuid of {_p}%::%{_name}%}
send "{@prefix}&cRemoved %{_excess}% excess %{_name}% from your inventory." to {_p}
else:
delete {combatlimits.warning::%uuid of {_p}%::%{_name}%}
every {@check-interval}:
loop all players:
checkCombatLimits(loop-player)
on quit:
delete {combatlimits.warning::%uuid of player%::*}