Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.
#Made by eult
#version 0.1
options:
#this is the permission that is required to to allow
#the user to use the command
permission: ArmorTrim.admin
#If you use the stop option on a non-trimmed
#item you will have this pattern
#! MAKE SURE IT'S LOWER CASE!
stop-option-pattern: sentry
#If you use the stop option on a non-trimmed
#item you will have this material
#! MAKE SURE IT'S LOWER CASE!
stop-option-material: emerald
on load:
set {-ArmorTrim::material::*} to "Emerald", "Redstone", "Lapis", "Amethyst", "Iron", "Diamond", "Gold", "Copper", "Stop" and "Netherite"
set {-ArmorTrim::pattern::*} to "Sentry", "Dune", "Coast", "Wild", "Tide", "Ward", "Vex", "Rib", "Snout", "Eye", "Spire", "Silence", "Wayfinder", "Shaper", "Host", "Stop" and "Raiser"
#! COMMAND
command /ArmorTrim [<string>] [<string>] [<string>]:
aliases: at
permission: {@permission}
trigger:
if arg-1 is "info":
send "&8» &6ArmorTrim info:"
send "&a Pattern &8[&c%eultGetPattern(Player's tool) ? "Has no Pattern"%&8]"
send "&a Material &8[&c%eultGetMaterial(Player's tool) ? "Has no Material"%&8]"
stop
if arg-1 or arg-2 or arg-3 is not set:
send "&8»&6 Main Command:"
send "&a/at &8[&aSlot number &8|| &aTool&8] &8[&aMaterial&8] &8[&aPattern&8]"
send "&a/at &8[&aTrim info about Player's tool]"
send "&8»&6 To change the pattern material:"
send "&8» &a/at &8[&aSlot number &8|| &aTool&8] &8[&aMaterial&8] &4STOP"
send "&8»&6 To change the pattern:"
send "&8» &a/at &8[&aSlot number &8|| &aTool&8] &4STOP &8[&aPattern&8]"
send ""
send "&eUse the STOP if you don't want to change a argument &c(can not be the first argument)"
send "&eif Armor is not Trimmed you can not use the stop option"
stop
if arg-1 is not "Tool", "t" or "Player-tool":
if arg-1 partially matches "[A-Za-z]":
send "&8» &eIt is not valid to enter &a/at &c%arg-1% &a%arg-2% %arg-3%&e."
stop
if {-ArmorTrim::material::*} does not contain arg-2:
send "&8» &eIt is not valid to enter &a/at &a%arg-1% &c%arg-2%&a %arg-3%&e."
stop
if {-ArmorTrim::pattern::*} does not contain arg-3:
send "&8» &eIt is not valid to enter &a/at &a%arg-1% %arg-2% &c%arg-3%&e."
stop
if arg-1 is "Tool", "t" or "Player-tool":
set {_item} to player's tool
if {_item} is not any armor:
send "&8» &4%{_item}% is not an armor"
stop
set {_item} to eultSetTrim({_item}, arg-2, arg-3)
set player's tool to {_item}
play sound "block.note_block.pling" with volume 1 and pitch 2 to player
else:
set {_slot} to arg-1 parsed as number
set {_item} to slot {_slot} of player's inventory
if {_item} is not any armor:
send "&8» &4%{_item}% is not an armor"
stop
set {_item} to eultSetTrim({_item}, arg-2, arg-3)
set slot {_slot} of player's inventory to {_item}
play sound "block.note_block.pling" with volume 1 and pitch 2 to player
#! tab completion to make it easier to work with the command
on tab complete of "/ArmorTrim" or "/at":
add "Tool", "Player-tool" and "Info" to {_firstTab::*}
loop 41 times:
add "%loop-value%" to {_firstTab::*}
set tab completions for position 1 to {_firstTab::*}
#Materials
set tab completions for position 2 to {-ArmorTrim::material::*}
#Pattern
set tab completions for position 3 to {-ArmorTrim::pattern::*}
#! useful functions feel free to change if you know what you're doing
function eultSetTrim(item: item, material: string, pattern: string) :: object:
if eultGetMaterial({_item}) is not set: #this is to check if the item has any Trim
replace "stop" with "{@stop-option-pattern}" in {_pattern}
replace "stop" with "{@stop-option-material}" in {_material}
set {_material} to lowercase {_material}
set {_pattern} to lowercase {_pattern}
set {_item} to eultBuildTrim({_item}, {_material}, {_pattern})
return {_item}
stop
set {_item} to eultSetPattern({_item}, {_pattern}) if {_pattern} is not "stop"
set {_item} to eultSetMaterial({_item}, {_material}) if {_material} is not "stop"
return {_item}
#this function build the trim if the item didn't have a trim
#it's bad but there is no better way to do it otherwise
function eultBuildTrim(item: item, material: string, pattern: string) :: object:
set {_nbt} to (nbt compound of {_item})
set {_a} to nbt compound of "{Trim:{material:""minecraft:%{_material}%"",pattern:""minecraft:%{_pattern}%""}}"
add {_a} to {_nbt}
return {_item}
function eultGetMaterial(item: item) :: object:
set {_nbt} to (nbt compound of {_item})
set {_trim} to (tag "Trim" of {_nbt})
set {_material} to (tag "material" of {_trim})
replace "minecraft:" with "" in {_material}
return {_material}
function eultGetPattern(item: item) :: object:
set {_nbt} to (nbt compound of {_item})
set {_trim} to (tag "Trim" of {_nbt})
set {_pattern} to (tag "pattern" of {_trim})
replace "minecraft:" with "" in {_pattern}
return {_pattern}
function eultSetPattern(item: item, pattern: string) :: object:
set {_pattern} to lower case {_pattern}
set {_nbt} to (nbt compound of {_item})
set {_trim} to (tag "Trim" of {_nbt})
set (tag "pattern" of {_trim}) to "minecraft:%{_pattern}%"
return {_item}
function eultSetMaterial(item: item, material: string) :: object:
set {_material} to lower case {_material}
set {_nbt} to (nbt compound of {_item})
set {_trim} to (tag "Trim" of {_nbt})
set (tag "material" of {_trim}) to "minecraft:%{_material}%"
return {_item}