Files
customitem.sk
customitemgive.sk
Code
2 229
customitem.sk
# -------------------------------------------------------
# Dynamic Roman numeral converter (Capped at Level 255)
# -------------------------------------------------------
function toRoman(n: integer) :: string:
set {_result} to ""
set {_val::*} to 100 and 90 and 50 and 40 and 10 and 9 and 5 and 4 and 1
set {_sym::*} to "C" and "XC" and "L" and "XL" and "X" and "IX" and "V" and "IV" and "I"
set {_num} to {_n}
loop 9 times:
set {_i} to loop-number
while {_num} >= {_val::%{_i}%}:
set {_result} to "%{_result}%%{_sym::%{_i}%}%"
subtract {_val::%{_i}%} from {_num}
return {_result}
# -------------------------------------------------------
# Main Command Execution Block
# Syntax: /customitem <item_name> <"custom_name"> <enchant:level ...> [-roman]
# -------------------------------------------------------
command /customitem <text> <text>:
permission: minecraft.command.op
permission message: "&cYou do not have permission to use this command."
trigger:
set {_rawItem} to arg-1
set {_rest} to arg-2
# ---- 1. BASE MATERIAL PARSING ----
set {_itemType} to {_rawItem} parsed as item type
if {_itemType} is not set:
send "&cInvalid material! Try: stick, leather_boots, diamond_sword" to player
stop
# FIX 1: Standard Skript item variable — "new item stack of X" is not valid syntax
set {_finalItem} to 1 of {_itemType}
# ---- 2. Dynamic Quote Stripping & Extraction ----
if {_rest} does not contain """":
send "&cPlease wrap the custom name inside quotes! Example: &f/customitem stick ""&bWand"" sharpness:5" to player
stop
set {_parts::*} to {_rest} split at """"
set {_rawDisplayName} to {_parts::2}
set {_rawExtra} to {_parts::3}
# Scan & Process the -roman Modifier Flag
set {_useRoman} to false
if {_rawExtra} contains "-roman":
set {_useRoman} to true
replace all " -roman" in {_rawExtra} with ""
replace all "-roman" in {_rawExtra} with ""
# Apply advanced formatting and HEX colors directly to the item stack
set display name of {_finalItem} to formatted {_rawDisplayName}
# ---- 3. AUTOMATICALLY STAMP ENCHANTMENTS & GENERATE LORE ----
delete {_loreLines::*}
set {_modifiers::*} to {_rawExtra} split at " "
loop {_modifiers::*}:
set {_part} to loop-value
if {_part} contains ":":
set {_split::*} to {_part} split at ":"
set {_eName} to {_split::1}
if {_eName} is set:
set {_eLevelRaw} to {_split::2}
if {_eLevelRaw} is set:
set {_eLevel} to {_eLevelRaw} parsed as integer
if {_eLevel} is set:
# Hard cap at level 255 to match the Minecraft registry limits securely
if {_eLevel} > 255:
set {_eLevel} to 255
if {_eLevel} < 1:
set {_eLevel} to 1
# Clean up name format for registry verification (e.g. fire_aspect -> fire aspect)
set {_cleanName} to {_eName}
# FIX 2: Correct argument order — replace all X in Y with Z
replace all "_" in {_cleanName} with " "
set {_enchantObj} to {_cleanName} parsed as enchantment type
if {_enchantObj} is not set:
send "&eWarning: Enchantment profile '&f%{_eName}%&e' not recognized. Skipping." to player
else:
enchant {_finalItem} with {_enchantObj} at level {_eLevel}
# --- AUTOMATED VISUAL LORE GENERATOR (only when -roman is active) ---
if {_useRoman} is true:
set {_lvlStr} to toRoman({_eLevel})
# Word Capitalization Engine (e.g. fire aspect -> Fire Aspect)
set {_words::*} to {_cleanName} split at " "
set {_capitalizedName} to ""
loop {_words::*}:
set {_word} to loop-value-2
set {_firstChar} to uppercase (first 1 characters of {_word})
set {_remainingChars} to last (length of {_word} - 1) characters of {_word}
if {_capitalizedName} is "":
set {_capitalizedName} to "%{_firstChar}%%{_remainingChars}%"
else:
set {_capitalizedName} to "%{_capitalizedName}% %{_firstChar}%%{_remainingChars}%"
add "&7%{_capitalizedName}% %{_lvlStr}%" to {_loreLines::*}
else:
send "&eWarning: Level parameter provided for &f%{_eName}%&e is non-numeric." to player
# ---- 4. RE-RENDER TOOLTIP DESIGNS ----
if {_useRoman} is true:
if size of {_loreLines::*} > 0:
set lore of {_finalItem} to {_loreLines::*}
add hide enchants to item flags of {_finalItem}
# ---- 5. DISTRIBUTE COMPLETED ITEM ----
give player {_finalItem}
send "&aSuccessfully created and given your custom item!" to player