Files
random_fishing_loot.sk
Code
1 60
random_fishing_loot.sk
# ======================================
# RandomFishingLoot
# Compatible: Paper 1.21.4 + Skript + SkBee
# Place in: plugins/Skript/scripts/
# Reload: /sk reload random_fishing_loot
# ======================================
options:
prefix: &8[&b&lFishing&8]&r
# Blacklisted items that should never be given to players
function isBlacklisted(item: itemtype) :: boolean:
if {_item} is command block:
return true
if {_item} is repeating command block:
return true
if {_item} is chain command block:
return true
if {_item} is structure block:
return true
if {_item} is jigsaw:
return true
if {_item} is debug stick:
return true
if {_item} is barrier:
return true
if {_item} is light:
return true
return false
on fishing:
# Only trigger when the hook has caught something
if fishing state is "caught fish" or fishing state is "caught entity":
cancel event
# Build a pool of all valid items from the Minecraft registry
set {_all::*} to all minecraft items
set {_pool::*} to {}
loop {_all::*}:
if isBlacklisted(loop-value) is false:
add loop-value to {_pool::*}
# Pick a random item from the pool
set {_size} to size of {_pool::*}
if {_size} is 0:
send "{@prefix} &cNo valid items found in registry." to player
stop
set {_index} to random integer between 1 and {_size}
set {_chosen} to {_pool::%{_index}%}
# Give the item to the player
give player 1 of {_chosen}
# Format and send the message
set {_name} to name of {_chosen}
if {_name} is not set:
set {_name} to "%{_chosen}%"
send "{@prefix} &aYou got: &e%{_name}%&a!" to player