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.
#Item Break and Repair 1.00
#July 12, 2018
#By Parrothead (https://forums.skunity.com/members/parrothead.488/)
#Need help? post on the thread or PM me on Discord (Parrothead#8885)
#
#Features
#
#Turn items (specifically ones with low or no durability) into a block that needs to be repaired to use again
#Repair those items with another function, making them work exactly as before
#Protection options to stop custom items with powers from working in destroyed form
#Lightweight!
#REQUIRES
#SKStuff
#Most versions of Skript should work, if not then let me know
#Maybe more? Let me know if I missed anything
options:
BROKENITEMMODEL: nether star #What do broken items look like? Set this to a cool head model
LOCATIONOFCHEST: {itembreakandrepair.chestlocation} #The item is first created in a chest because of Skript bugginess otherwise. Set to a chest that is protected from player interaction (Lockette, LWC, WG) and a location that is always loaded into RAM (i.e. spawn).
BREAKTEXT: &6&7&6 #This is inserted in the middle of broken item names to break any abilities that you have coded to work off of item names. If that doesn't apply to your server, leave this blank. (Example: 'Explosion Sword' becomes 'Exp&6&7&6losion Sword'. This is reverted on fix.
BROKENLORE: &c&l✖ BROKEN ✖||&cMust Repair Before Using||&c&m-------------- #This is inserted to the top of the item's lore to show the player it's broken.
TOTALLORELINES: 3 #How many lore lines above do you have? Put that number here!
function breakItem(item: item, player: player):
{_item} is not player head
#---
#Looking for empty chest slot
loop integers from 0 to 26:
if slot loop-integer of {@LOCATIONOFCHEST} is air:
set {_position} to loop-integer
exit loop
#---
#Create the item
set slot {_position} of {@LOCATIONOFCHEST} to {_item}
set {_item.type} to type of slot {_position} of {@LOCATIONOFCHEST}
#---
set {_nbt} to nbt of {_item}
set slot {_position} of {@LOCATIONOFCHEST} to {@BROKENITEMMODEL}
add "%{_nbt}%" to nbt of slot {_position} of {@LOCATIONOFCHEST}
#---
#Add broken notifier to the item's lore
set {_break.lore} to lore of slot {_position} of {@LOCATIONOFCHEST}
set {_break.lore} to "{@BROKENLORE}||%{_break.lore}%"
#---
#Add NBT to tell what the item actually is when repaired
set {_item.type} to "%{_item.type}%" parsed as a string
replace all " " in {_item.type} with "_"
add "{ItemType: %{_item.type}%}" to nbt of slot {_position} of {@LOCATIONOFCHEST}
#---
#Jumble the item's name to stop abilities from working that trigger off of the name (unjumbles later with other function)
#Can turn this off / delete if needed
set {_break.name} to name of slot {_position} of {@LOCATIONOFCHEST}
#---Names starting with lowercase fuck up
#replace all "a" in {_break.name} with "a&r&6"
#replace all "e" in {_break.name} with "e&r&6"
#replace all "i" in {_break.name} with "i&r&6"
#replace all "o" in {_break.name} with "o&r&6"
#replace all "u" in {_break.name} with "u&r&6"
#replace all "y" in {_break.name} with "y&r&6"
set {_first3} to the first 3 characters of {_break.name}
set {_lastall} to subtext of {_break.name} from characters 4 to (the length of {_break.name})
#---
set name of slot {_position} of {@LOCATIONOFCHEST} to "%{_first3}%{@BREAKTEXT}%{_lastall}%"
#---
#Give the player the finished item and remove old one
set {_item.finished} to slot {_position} of {@LOCATIONOFCHEST}
set lore of {_item.finished} to {_break.lore}
loop items in {_player}'s inventory:
if loop-item is {_item}:
delete loop-item
exit loop
give {_player} {_item.finished}
#---
#Cleanup
set slot {_position} of {@LOCATIONOFCHEST} to air #Deleting created broken item
#---
#Flair
message "&4&lWARNING » &6&lYour %name of {_item}%&6&l has broke!!" to {_player}
function fixItem(item: item, player: player):
#---
#Looking for empty chest slot
loop integers from 0 to 26:
if slot loop-integer of {@LOCATIONOFCHEST} is air:
set {_position} to loop-integer
exit loop
#---
#Grabbing item type
set {_item.type} to tag "ItemType" of nbt of {_item}
replace all "_" in {_item.type} with " "
set {_item.type} to {_item.type} parsed as an item type
#---
#Creating the item
set slot {_position} of {@LOCATIONOFCHEST} to {_item.type}
#---
#Add NBT
set {_nbt} to nbt of {_item}
add "%{_nbt}%" to nbt of slot {_position} of {@LOCATIONOFCHEST}
#---
#Remove Broken Lore
loop {@TOTALLORELINES} times:
delete line 1 of lore of slot {_position} of {@LOCATIONOFCHEST}
#---
#Fix Broken Name
set {_break.name} to name of slot {_position} of {@LOCATIONOFCHEST}
#--- Names starting with lowercase fuck up
replace all "&7&6&7" in {_break.name} with ""
#---
set name of slot {_position} of {@LOCATIONOFCHEST} to {_break.name}
#---
#Give the player the finished item and remove old one
set {_item.finished} to slot {_position} of {@LOCATIONOFCHEST}
loop items in {_player}'s inventory:
if loop-item is {_item}:
delete loop-item
exit loop
give {_player} {_item.finished}
#---
#Cleanup
set slot {_position} of {@LOCATIONOFCHEST} to air #Deleting created broken item
#---
#Flair
message "&aYou have repaired your %name of {_item}%&a!" to {_player}