Custom Enchants Request & Help

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Tewahh

Member
Aug 18, 2023
14
1
3
23
Code:
command /ce:
    aliases: /customenchants, /customenchant, /enchants
    trigger:
        set {_item} to gray stained glass pane
        set {_enchantmentsList} to book named "&eList Of All The Enchants"
        set line 1 of lore of {_enchantmentsList} to ""
        set {_commonEnchant} to book named "&7&lCommon Enchant"
        set {_uncommonEnchant} to book named "&a&lUncommon Enchant"
        set {_rareEnchant} to book named "&1&lRare Enchant"
        set {_uniqueEnchant} to book named "&e&lUnique Enchant"
        set {_legendaryEnchant} to book named "&6&lLegendary Enchant"
        set {_mythicalEnchant} to book named "&d&lMythical Enchant"
        # set {_executiveEnchant} to book named "&b&lExecutive Enchant"
        set {_gui} to a new chest inventory with 6 rows with name "&b&lCustom Enchants"
        set slot (integers between 0 and 53) of {_gui} to {_item}
        set slot 10 of {_gui} to {_commonEnchant}
        set slot 13 of {_gui} to {_uncommonEnchant}
        set slot 16 of {_gui} to {_rareEnchant}
        set slot 37 of {_gui} to {_uniqueEnchant}
        set slot 40 of {_gui} to {_legendaryEnchant}
        set slot 43 of {_gui} to {_mythicalEnchant}
        set slot 53 of {_gui} to {_enchantmentsList}
        open {_gui} to player

on inventory click:
    if name of event-inventory is "&b&lCustom Enchants":
        if index of event-slot = 10:
            cancel event
            if player's level > 1:
                remove 1 from player's level
                give player book named "&7&lCommon Enchant"
                send "You received a &7&lCommon Enchant Book"
        else if index of event-slot = 13:
            cancel event
            if player's level > 2:
                remove 1 from player's level
                give player book named "&a&lUncommon Enchant"
                send "You received a &a&lUncommon Enchant Book"
        else if index of event-slot = 16:
            cancel event
            if player's level > 3:
                remove 3 from player's level
                give player book named "&1&lRare Enchant"
                send "You received a &1&lRare Enchant Book"
        else if index of event-slot = 37:
            cancel event
            if player's level > 4:
                remove 4 from player's level
                give player book named "&e&lUnique Enchant"
                send "You received a &e&lUnique Enchant Book"
        else if index of event-slot = 40:
            cancel event
            if player's level > 5:
                remove 5 from player's level
                give player book named "&6&lLegendary Enchant"
                send "You received a &6&lLegendary Enchant Book"
        else if index of event-slot = 43:
            cancel event
            if player's level > 6:
                remove 6 from player's level
                give player book named "&d&lMythical Enchant"
                send "You received a &d&lMythical Enchant Book"

on right click:
    if event-item is book named "&7&lCommon Enchant":
        set {custom.enchant} to random integer between 1 and 2
        if {custom.enchant} is 1:
            set {_book} to enchanted book named "&7&lSmelter"
            set line 1 of lore of {_book} to "&7Smelts the ores that you mine."
            set line 2 of lore of {_book} to "&eTool Encahntment"
            give player {_book}
            send "&7Received the &eSmelter&7 Enchantment" to player
        else if {custom.enchant} is 2:
            set {_book} to enchanted book named "&7Confusion"
            set line 1 of lore of {_book} to "&7Chance to apply &eBlindness &7and &eNausea effects"
            set line 2 of lore of {_book} to "&7to the enemy!"
            set line 3 of lore of {_book} to "&eSword Enchantment"
            give player {_book}
            send "&7Received the &eConfusion&7 Enchantment" to player
    
    
    if event-item is book named "&6&lLegendary Enchant":
        chance of 100%:
            set {custom.enchant} to random integer between 1 and 1
            if {custom.enchant} is 1:
                set {_book} to enchanted book named "&6&lOverload"
                set line 1 of lore of {_book} to "&7Gives the player increased maxed health"
                set line 2 of lore of {_book} to "&7Stacks up to 45 hearts"
                set line 3 of lore of {_book} to ""
                set line 4 of lore of {_book} to "Armor"
                give player {_book}
    
    
    if event-item is book named "&d&lMythical Enchant":
        chance of 100%:
            set {custom.enchant} to random integer between 1 and 5
            if {custom.enchant} is 1:
                set {_book} to enchanted book named "&d&lGodly Overload"
                set line 1 of lore of {_book} to "&d&lDescription:"
                set line 2 of lore of {_book} to "&7Gives the player incrased maxed health"
                set line 3 of lore of {_book} to "&7Stacks up to 50 hearts"
                set line 4 of lore of {_book} to ""
                set line 5 of lore of {_book} to "&d&lApplicable To:"
                set line 6 of lore of {_book} to "&7Armor"
                set line 7 of lore of {_book} to ""
                set line 8 of lore of {_book} to "&d&lRequirements:"
                set line 9 of lore of {_book} to "&7Must have Overload 3 on each piece"
                give player {_book}
            else if {custom.enchant} is 2:
                set {_book} to enchanted book named "&d&lHallucination"
                set line 1 of lore of {_book} to "&d&lDescription:"
                set line 2 of lore of {_book} to "&7Puts victim in webs and bedrock. VISUALLY"
                set line 3 of lore of {_book} to "&7You can't hit the enemy, but you can be hit."
                set line 4 of lore of {_book} to ""
                set line 5 of lore of {_book} to "&d&lApplicable To:"
                set line 6 of lore of {_book} to "&7Swords/Axes"
                set line 7 of lore of {_book} to ""
                set line 8 of lore of {_book} to "&d&lVISUAL ENCHANT"
                set line 9 of lore of {_book} to "&7Visual Enchants mean that the effects that happen"
                set line 10 of lore of {_book} to "&7Will only show for the victim/attacker."
                give player {_book}
            else if {custom.enchant} is 3:
                set {_book} to enchanted book named "&d&lMama's Mad"
                # maybe add a blank line of lore to each new line. Description "", effects: "" applicable to ""
                set line 1 of lore of {_book} to "&d&lDescription:"
                set line 2 of lore of {_book} to "&7Mama found the grades"
                set line 3 of lore of {_book} to "&7Better start running."
                set line 4 of lore of {_book} to ""
                set line 5 of lore of {_book} to "&d&lEffects:"
                set line 6 of lore of {_book} to "&7Gives the player Strength 2.5"
                set line 7 of lore of {_book} to ""
                set line 8 of lore of {_book} to "&d&lApplicable To:"
                set line 9 of lore of {_book} to "&7Swords/Axes"
                set line 10 of lore of {_book} to ""
                set line 11 of lore of {_book} to "&d&lRequirements:"
                set line 12 of lore of {_book} to "&7Must have Rage 3 on the item."
                set line 13 of lore of {_book} to ""
                set line 14 of lore of {_book} to "&d&lJOKE ENCHANT"
                set line 15 of lore of {_book} to "&7While this is a joke enchant, it still gives effects."
                give player {_book}
            else if {custom.enchant} is 4:
                set {_book} to enchanted book named "&d&lLightning"
                set line 1 of lore of {_book} to ""
                set line 2 of lore of {_book} to ""
                set line 3 of lore of {_book} to ""
                give player {_book}
            else if {custom.enchant} is 5:
                set {_book} to enchanted book named "&d&lFatty"
                set line 1 of lore of {_book} to ""
                set line 2 of lore of {_book} to ""
                set line 3 of lore of {_book} to ""
                give player {_book}


on inventory click:
    if cursor slot of player is book named "&7Confusion", "&f&lEfficiency" or "&a&lFortune":
        set {_nm} to name of cursor slot of player
        if event-item is any sword:
            if event-item's lore doesn't contain "%{_nm}%":
                set {_a} to event-item
                cancel event
                set lore of {_a} to "%lore of {_a}%" and "%{_nm}%"
                wait 2 ticks
                set cursor slot of player to air
                set event-slot to {_a}
            else:
                cancel event
                send "&7You already have that enchantment!"






command /enchanter [<offline player>]:
    trigger:
        set {_gui} to a new chest inventory with 6 rows with name "&b&lEnchanter"
        set {_item} to black stained glass pane named "&c&lHello"
        set {_itemB} to barrier named "&4&lFiller" # or change the barrier to red stained glass
        set {_itemC} to air
        set {_itemA} to anvil named "&f&lClick Me!" with lore "&7&lPut an item on the left side,", "&7&lPut an enchant book on the right side" and "Then click me and it will put the enchant on the item"
        set slot (integers between 0 and 53) of {_gui} to {_item}
        set slot 31 of {_gui} to {_itemA}
        set slot (integers between 11 and 15) of {_gui} to {_itemB}
        set slot 20 and 24 of {_gui} to {_itemB}
        set slot 29 and 33 of {_gui} to {_itemC}
    # its gonna look like
    # barrier, barrier, barrier, barrier, barrier
    # barrier,            barrier,          barrier,
    # barrier,            barrier,          barrier,
    #             ITEM,                BOOK,
    # barrier,            barrier,          barrier,
    # barrier,            barrier,          barrier,
    # barrier,            barrier,          barrier,

        
        open {_gui} to player
on inventory click:
    if name of event-inventory is "&b&lEnchanter":
        if index of event-slot = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 or 53:
            cancel event
on inventory click:
    if name of event-inventory is "&b&lEnchanter":
        if index of event-slot = 31:
            cancel event
        if slot 29 of player's current inventory is any sword:
            make console execute "/tell Tewahh Hi!"
        if slot 33 of player's current inventory is any book:
            make console execute "/tell Tewahh Hello!"

So, this is a bit of a request as well as help, I wanna make this code shorter and more optimized, but I dont know how to use functions/loops very well, so i wanna learn how to do this better, but I need someone to put my into the right direction.
 
To optimize it first you can reduce the lines needed to make the initial /ce gui:

code_language.skript:
command /ce:
    aliases: /customenchants, /customenchant, /enchants
    trigger:
        set {_gui} to a new chest inventory with 6 rows with name "&b&lCustom Enchants"
        set slot (integers between 0 and 53) of {_gui} to gray stained glass pane
        set slot 10 of {_gui} to book named "&7&lCommon Enchant"
        set slot 13 of {_gui} to book named "&a&lUncommon Enchant"
        set slot 16 of {_gui} to book named "&1&lRare Enchant"
        set slot 37 of {_gui} to book named "&e&lUnique Enchant"
        set slot 40 of {_gui} to book named "&6&lLegendary Enchant"
        set slot 43 of {_gui} to book named "&d&lMythical Enchant"
        set slot 53 of {_gui} to book named "&eList Of All The Enchants" with lore ""
        open {_gui} to player

This can also be done for the rest of the GUIs and items in the script.
 
To optimize it first you can reduce the lines needed to make the initial /ce gui:

code_language.skript:
command /ce:
    aliases: /customenchants, /customenchant, /enchants
    trigger:
        set {_gui} to a new chest inventory with 6 rows with name "&b&lCustom Enchants"
        set slot (integers between 0 and 53) of {_gui} to gray stained glass pane
        set slot 10 of {_gui} to book named "&7&lCommon Enchant"
        set slot 13 of {_gui} to book named "&a&lUncommon Enchant"
        set slot 16 of {_gui} to book named "&1&lRare Enchant"
        set slot 37 of {_gui} to book named "&e&lUnique Enchant"
        set slot 40 of {_gui} to book named "&6&lLegendary Enchant"
        set slot 43 of {_gui} to book named "&d&lMythical Enchant"
        set slot 53 of {_gui} to book named "&eList Of All The Enchants" with lore ""
        open {_gui} to player

This can also be done for the rest of the GUIs and items in the script.
so, what about the long lines of code near the middle ish. where the actual enchants are obtained using the right click method?
 
For that you should change the lore to work like this:
(Using "and" instead of setting the lore by line)

code_language.skript:
give player enchanted book named "&7&lSmelter" with lore "&7Smelts the ores that you mine." and "&eTool Enchantment"
 
For that you should change the lore to work like this:
(Using "and" instead of setting the lore by line)

code_language.skript:
give player enchanted book named "&7&lSmelter" with lore "&7Smelts the ores that you mine." and "&eTool Enchantment"
oh yeah, completely forgot that we could do that. thank you!
 
For that you should change the lore to work like this:
(Using "and" instead of setting the lore by line)

code_language.skript:
give player enchanted book named "&7&lSmelter" with lore "&7Smelts the ores that you mine." and "&eTool Enchantment"
Code:
# TO-DO LIST

# make commands that will disable enchants/messages
# finish the actual enchanter gui
# figure out how to shorten and optimzie the code so that it looks cleaner
command /ce:
    aliases: /customenchants, /customenchant, /enchants
    trigger:
        set {_item} to gray stained glass pane
        set {_enchantmentsList} to book named "&eList Of All The Enchants"
        set line 1 of lore of {_enchantmentsList} to ""
        set {_commonEnchant} to book named "&7&lCommon Enchant"
        set {_uncommonEnchant} to book named "&a&lUncommon Enchant"
        set {_rareEnchant} to book named "&1&lRare Enchant"
        set {_uniqueEnchant} to book named "&e&lUnique Enchant"
        set {_legendaryEnchant} to book named "&6&lLegendary Enchant"
        set {_mythicalEnchant} to book named "&d&lMythical Enchant"
        # set {_executiveEnchant} to book named "&b&lExecutive Enchant"
        set {_gui} to a new chest inventory with 6 rows with name "&b&lCustom Enchants"
        set slot (integers between 0 and 53) of {_gui} to {_item}
        set slot 10 of {_gui} to {_commonEnchant}
        set slot 13 of {_gui} to {_uncommonEnchant}
        set slot 16 of {_gui} to {_rareEnchant}
        set slot 37 of {_gui} to {_uniqueEnchant}
        set slot 40 of {_gui} to {_legendaryEnchant}
        set slot 43 of {_gui} to {_mythicalEnchant}
        set slot 53 of {_gui} to {_enchantmentsList}
        open {_gui} to player
on inventory click:
    if name of event-inventory is "&b&lCustom Enchants":
        if index of event-slot = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 or 53:
            cancel event
            if index of event-slot = 10:
                if player's level > 1:
                    remove 1 from player's level
                    give player book named "&7&lCommon Enchant"
                    send "You received a &7&lCommon Enchant Book"
            else if index of event-slot = 13:
                if player's level > 2:
                    remove 2 from player's level
                    give player book named "&a&lUncommon Enchant"
                    send "You received a &a&lUncommon Enchant Book"
            else if index of event-slot = 16:
                if player's level > 3:
                    remove 3 from player's level
                    give player book named "&1&lRare Enchant"
                    send "You received a &1&lRare Enchant Book"
            else if index of event-slot = 37:
                if player's level > 4:
                    remove 4 from player's level
                    give player book named "&e&lUnique Enchant"
                    send "You received a &e&lUnique Enchant Book"
            else if index of event-slot = 40:
                if player's level > 5:
                    remove 5 from player's level
                    give player book named "&6&lLegendary Enchant"
                    send "You received a &6&lLegendary Enchant Book"
            else if index of event-slot = 43:
                if player's level > 6:
                    remove 6 from player's level
                    give player book named "&d&lMythical Enchant"
                    send "You received a &d&lMythical Enchant Book"

on right click:
    if event-item is book named "&7&lCommon Enchant":
        set {custom.enchant} to random integer between 1 and 2
        if {custom.enchant} is 1:
            give player enchanted book named "&7&lSmelter" with lore "&7Smelts the ores that you mine." and "&eTools Enchantment"
            send "&7Received the &eSmelter&7 Enchantment" to player
        else if {custom.enchant} is 2:
            give player enchanted book named "&7Confusion" with lore "&7Chance to apply &eBlindness &7and &eNausea effects", "&7to the enemy!" and "&eSword Enchantment"
            send "&7Received the &eConfusion&7 Enchantment" to player
    if event-item is book named "&6&lLegendary Enchant":
        set {custom.enchant} to a random integer between 1 and 1
        if {custom.enchant} is 1:
            set {custom.enchant.level} to a random integer between 1 and 3
            give player enchanted book named "&6&lOverload {custom.enchant.level}" with lore "&7Gives the player increased maxed health.", "&7Stacks up to 45 hearts", "" and "Armor"   
    if event-item is book named "&d&lMythical Enchant":
        set {custom.enchant} to random integer between 1 and 5
        if {custom.enchant} is 1:
            give player enchanted book named "&d&lGodly Overload" with lore "&d&lDescription:", "&7Gives the player incrased maxed health", "&7Stacks up to 50 hearts", "", "&d&lApplicable To:", "&7Armor" , "", "&d&lRequirements:" and "&7Must have Overload 3 on each piece"           
        else if {custom.enchant} is 2:
            give player enchanted book named "&d&lHallucination" with lore "&d&lDescription:", "&7Puts victim in webs and bedrock. VISUALLY", "&7You can't hit the enemy, but you can be hit.", "", "&d&lApplicable To:", "&7Swords/Axes" , "", "&d&lVISUAL ENCHANT", "&7Visual Enchants mean that the effects that happen" and "&7Will only show for the victim/attacker."
        else if {custom.enchant} is 3:
            give player enchanted book named "&d&lMama's Mad" with lore "&d&lDescription:", "&7Mama found the grades", "&7Better start running.", "", "&d&lEffects:", "&7Gives the player Strength 2.5", "", "&d&lApplicable To:", "&7Swords/Axes", "", "&d&lRequirements:" and "&7Must have Rage 3 on the item."
        else if {custom.enchant} is 4:
            give player enchanted book named "&d&lLightning" with lore "", "" and ""
        else if {custom.enchant} is 5:
            give player enchanted book named "&d&lFatty" with lore "", "" and ""

on inventory click:
    if cursor slot of player is enchanted book:
        if name of cursor slot of player is "&7&lSmelter":
            if event-item is any pickaxe:
                if lore of event-item doesn't contain "&7&lSmelter":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7&lSmelter" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &e&lSmelter&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Speed":
            if event-item is any boots:
                if lore of event-item doesn't contain "&7Speed":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Speed" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eSpeed&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Shockwave":
            if event-item is any chestplate:
                if lore of event-item doesn't contain "&7Shockwave":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Shockwave" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eShockwave&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Escapist":
            if event-item is any helmet:
                if lore of event-item doesn't contain "&7Escapist":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Escapist" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eEscapist&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Bounce":
            if event-item is any leggings:
                if lore of event-item doesn't contain "&7Bounce":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Bounce" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eBounce&7 successfully applied!" to the player
                    set cursor slot of player to air
                                        

on inventory click:
    if cursor slot of player is book named "&7Confusion", "&f&lEfficiency" or "&a&lFortune":
        set {_nm} to name of cursor slot of player
        if event-item is any sword:
            if event-item's lore doesn't contain "%{_nm}%":
                set {_a} to event-item
                cancel event
                set lore of {_a} to "%lore of {_a}%" and "%{_nm}%"
                wait 2 ticks
                set cursor slot of player to air
                set event-slot to {_a}
            else:
                cancel event
                send "&7You already have that enchantment!"






command /enchanter [<offline player>]:
    trigger:
        set {_gui} to a new chest inventory with 6 rows with name "&b&lEnchanter"
        set slot (integers between 0 and 53) of {_gui} to black stained glass pane named "&c&lHello"
        set slot 31 of {_gui} to anvil named "&f&lClick Me!" with lore "&7&lPut an item on the left side,", "&7&lPut an enchant book on the right side" and "Then click me and it will put the enchant on the item"
        set slot (integers between 11 and 15) of {_gui} to barrier named "&4&lFiller"
        set slot 20 and 24 of {_gui} to barrier named "&4&lFiller"
        set slot 29 and 33 of {_gui} to air
        open {_gui} to player
on inventory click:
    if name of event-inventory is "&b&lEnchanter":
        if index of event-slot = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 or 53:
            cancel event

# on inventory click:
#     if name of event-inventory is "&b&lEnchanter":
#         if index of event-slot = 31:
#             # cancel event
#             if slot 29 of player's current inventory contains any sword:
#                 # make console execute "/tell Tewahh Hi!"
#                 if slot 33 of player's current inventory contains any book:
#                     broadcast "Hey, %player%, you have a sword in slot 29, and a book in slot 33."
#                     make console execute "/tell Tewahh Hello!"
on inventory click:
    if name of event-inventory is "&b&lEnchanter":
        if index of event-slot = 31:
            if slot 29 of player's current inventory is any sword:
                if slot 33 of player's current inventory is any book:
                    cancel event
                    make console execute "/tell Tewahh Hi!"

on mine:
    if event-block is gold ore, iron ore, ancient debris, sand or cobblestone:
        if lore of player's tool contains "&7&lSmelter":
            send "hey!" to player
            

# on damage:
#     if lore of attacker's weapon contains "&d&lLightning":
#         if difference between now and {%attacker's uuid%.lightningEnchant.lastUsed} is less than 15 seconds:
#         else:
#             apply slowness 5 to the victim for 5 seconds
#             loop 3 times:
#                 strike lightning effect at the victim
#                 wait 1 second
#             send "&8&lThe &d&lLightning &8&leffect has activated"
#             set {%attacker's uuid%.lightningEnchant.lastUsed} to now

# on damage:
#     if lore of attacker's weapon contains "&7Crippling":
#         chance of 10%:
#             apply blindness 1 to victim for 3 seconds
#             apply slowness 2 to victim for 3 seconds

# on damage:
#     if lore of victim's chestplate contains "&7Shockwave":
#         chance of 12%:
#             apply nausea 2 to attacker for 2 seconds
#             strike lightning effect at the attacker
#             damage attacker by 1 heart
                        
# on damage:
#     if victim's health <= 3:
#         if lore of victim's helmet contains "&7Escapist":
#             apply swiftness 2 to victim for 5 seconds
#             apply invisibility to victim for 5 seconds
#             wait 5 seconds
#             remove swiftness from victim
                
# every 2 seconds:
#     loop all players:
#         if lore of loop-player's boots contains "&7Speed I":
#             apply swiftness 1 to loop-player for 2.01 seconds
#         else if lore of loop-player's boots contains "&7Speed II":
#             apply swiftness 2 to loop-player for 2.01 seconds

# every 2 seconds:
#     loop all players:
#         if lore of loop-player's leggings contains "&7Bounce":
#             apply jump boost 2 to loop-player for 2.01 seconds


thats my new skript, is there anything else i can do to make it better/more efficient/optimized? if so, what and how?
 
Code:
# TO-DO LIST

# make commands that will disable enchants/messages
# finish the actual enchanter gui
# figure out how to shorten and optimzie the code so that it looks cleaner
command /ce:
    aliases: /customenchants, /customenchant, /enchants
    trigger:
        set {_item} to gray stained glass pane
        set {_enchantmentsList} to book named "&eList Of All The Enchants"
        set line 1 of lore of {_enchantmentsList} to ""
        set {_commonEnchant} to book named "&7&lCommon Enchant"
        set {_uncommonEnchant} to book named "&a&lUncommon Enchant"
        set {_rareEnchant} to book named "&1&lRare Enchant"
        set {_uniqueEnchant} to book named "&e&lUnique Enchant"
        set {_legendaryEnchant} to book named "&6&lLegendary Enchant"
        set {_mythicalEnchant} to book named "&d&lMythical Enchant"
        # set {_executiveEnchant} to book named "&b&lExecutive Enchant"
        set {_gui} to a new chest inventory with 6 rows with name "&b&lCustom Enchants"
        set slot (integers between 0 and 53) of {_gui} to {_item}
        set slot 10 of {_gui} to {_commonEnchant}
        set slot 13 of {_gui} to {_uncommonEnchant}
        set slot 16 of {_gui} to {_rareEnchant}
        set slot 37 of {_gui} to {_uniqueEnchant}
        set slot 40 of {_gui} to {_legendaryEnchant}
        set slot 43 of {_gui} to {_mythicalEnchant}
        set slot 53 of {_gui} to {_enchantmentsList}
        open {_gui} to player
on inventory click:
    if name of event-inventory is "&b&lCustom Enchants":
        if index of event-slot = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 or 53:
            cancel event
            if index of event-slot = 10:
                if player's level > 1:
                    remove 1 from player's level
                    give player book named "&7&lCommon Enchant"
                    send "You received a &7&lCommon Enchant Book"
            else if index of event-slot = 13:
                if player's level > 2:
                    remove 2 from player's level
                    give player book named "&a&lUncommon Enchant"
                    send "You received a &a&lUncommon Enchant Book"
            else if index of event-slot = 16:
                if player's level > 3:
                    remove 3 from player's level
                    give player book named "&1&lRare Enchant"
                    send "You received a &1&lRare Enchant Book"
            else if index of event-slot = 37:
                if player's level > 4:
                    remove 4 from player's level
                    give player book named "&e&lUnique Enchant"
                    send "You received a &e&lUnique Enchant Book"
            else if index of event-slot = 40:
                if player's level > 5:
                    remove 5 from player's level
                    give player book named "&6&lLegendary Enchant"
                    send "You received a &6&lLegendary Enchant Book"
            else if index of event-slot = 43:
                if player's level > 6:
                    remove 6 from player's level
                    give player book named "&d&lMythical Enchant"
                    send "You received a &d&lMythical Enchant Book"

on right click:
    if event-item is book named "&7&lCommon Enchant":
        set {custom.enchant} to random integer between 1 and 2
        if {custom.enchant} is 1:
            give player enchanted book named "&7&lSmelter" with lore "&7Smelts the ores that you mine." and "&eTools Enchantment"
            send "&7Received the &eSmelter&7 Enchantment" to player
        else if {custom.enchant} is 2:
            give player enchanted book named "&7Confusion" with lore "&7Chance to apply &eBlindness &7and &eNausea effects", "&7to the enemy!" and "&eSword Enchantment"
            send "&7Received the &eConfusion&7 Enchantment" to player
    if event-item is book named "&6&lLegendary Enchant":
        set {custom.enchant} to a random integer between 1 and 1
        if {custom.enchant} is 1:
            set {custom.enchant.level} to a random integer between 1 and 3
            give player enchanted book named "&6&lOverload {custom.enchant.level}" with lore "&7Gives the player increased maxed health.", "&7Stacks up to 45 hearts", "" and "Armor"  
    if event-item is book named "&d&lMythical Enchant":
        set {custom.enchant} to random integer between 1 and 5
        if {custom.enchant} is 1:
            give player enchanted book named "&d&lGodly Overload" with lore "&d&lDescription:", "&7Gives the player incrased maxed health", "&7Stacks up to 50 hearts", "", "&d&lApplicable To:", "&7Armor" , "", "&d&lRequirements:" and "&7Must have Overload 3 on each piece"          
        else if {custom.enchant} is 2:
            give player enchanted book named "&d&lHallucination" with lore "&d&lDescription:", "&7Puts victim in webs and bedrock. VISUALLY", "&7You can't hit the enemy, but you can be hit.", "", "&d&lApplicable To:", "&7Swords/Axes" , "", "&d&lVISUAL ENCHANT", "&7Visual Enchants mean that the effects that happen" and "&7Will only show for the victim/attacker."
        else if {custom.enchant} is 3:
            give player enchanted book named "&d&lMama's Mad" with lore "&d&lDescription:", "&7Mama found the grades", "&7Better start running.", "", "&d&lEffects:", "&7Gives the player Strength 2.5", "", "&d&lApplicable To:", "&7Swords/Axes", "", "&d&lRequirements:" and "&7Must have Rage 3 on the item."
        else if {custom.enchant} is 4:
            give player enchanted book named "&d&lLightning" with lore "", "" and ""
        else if {custom.enchant} is 5:
            give player enchanted book named "&d&lFatty" with lore "", "" and ""

on inventory click:
    if cursor slot of player is enchanted book:
        if name of cursor slot of player is "&7&lSmelter":
            if event-item is any pickaxe:
                if lore of event-item doesn't contain "&7&lSmelter":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7&lSmelter" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &e&lSmelter&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Speed":
            if event-item is any boots:
                if lore of event-item doesn't contain "&7Speed":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Speed" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eSpeed&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Shockwave":
            if event-item is any chestplate:
                if lore of event-item doesn't contain "&7Shockwave":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Shockwave" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eShockwave&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Escapist":
            if event-item is any helmet:
                if lore of event-item doesn't contain "&7Escapist":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Escapist" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eEscapist&7 successfully applied!" to the player
                    set cursor slot of player to air
        else if name of cursor slot of player is "&7Bounce":
            if event-item is any leggings:
                if lore of event-item doesn't contain "&7Bounce":
                    cancel the event
                    set {_item} to event-item
                    remove {_item} from player
                    add "&7Bounce" to lore of {_item}
                    give player {_item}
                    send "&7[&e&lENCHANTER&7] &eBounce&7 successfully applied!" to the player
                    set cursor slot of player to air
                                       

on inventory click:
    if cursor slot of player is book named "&7Confusion", "&f&lEfficiency" or "&a&lFortune":
        set {_nm} to name of cursor slot of player
        if event-item is any sword:
            if event-item's lore doesn't contain "%{_nm}%":
                set {_a} to event-item
                cancel event
                set lore of {_a} to "%lore of {_a}%" and "%{_nm}%"
                wait 2 ticks
                set cursor slot of player to air
                set event-slot to {_a}
            else:
                cancel event
                send "&7You already have that enchantment!"






command /enchanter [<offline player>]:
    trigger:
        set {_gui} to a new chest inventory with 6 rows with name "&b&lEnchanter"
        set slot (integers between 0 and 53) of {_gui} to black stained glass pane named "&c&lHello"
        set slot 31 of {_gui} to anvil named "&f&lClick Me!" with lore "&7&lPut an item on the left side,", "&7&lPut an enchant book on the right side" and "Then click me and it will put the enchant on the item"
        set slot (integers between 11 and 15) of {_gui} to barrier named "&4&lFiller"
        set slot 20 and 24 of {_gui} to barrier named "&4&lFiller"
        set slot 29 and 33 of {_gui} to air
        open {_gui} to player
on inventory click:
    if name of event-inventory is "&b&lEnchanter":
        if index of event-slot = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 or 53:
            cancel event

# on inventory click:
#     if name of event-inventory is "&b&lEnchanter":
#         if index of event-slot = 31:
#             # cancel event
#             if slot 29 of player's current inventory contains any sword:
#                 # make console execute "/tell Tewahh Hi!"
#                 if slot 33 of player's current inventory contains any book:
#                     broadcast "Hey, %player%, you have a sword in slot 29, and a book in slot 33."
#                     make console execute "/tell Tewahh Hello!"
on inventory click:
    if name of event-inventory is "&b&lEnchanter":
        if index of event-slot = 31:
            if slot 29 of player's current inventory is any sword:
                if slot 33 of player's current inventory is any book:
                    cancel event
                    make console execute "/tell Tewahh Hi!"

on mine:
    if event-block is gold ore, iron ore, ancient debris, sand or cobblestone:
        if lore of player's tool contains "&7&lSmelter":
            send "hey!" to player
           

# on damage:
#     if lore of attacker's weapon contains "&d&lLightning":
#         if difference between now and {%attacker's uuid%.lightningEnchant.lastUsed} is less than 15 seconds:
#         else:
#             apply slowness 5 to the victim for 5 seconds
#             loop 3 times:
#                 strike lightning effect at the victim
#                 wait 1 second
#             send "&8&lThe &d&lLightning &8&leffect has activated"
#             set {%attacker's uuid%.lightningEnchant.lastUsed} to now

# on damage:
#     if lore of attacker's weapon contains "&7Crippling":
#         chance of 10%:
#             apply blindness 1 to victim for 3 seconds
#             apply slowness 2 to victim for 3 seconds

# on damage:
#     if lore of victim's chestplate contains "&7Shockwave":
#         chance of 12%:
#             apply nausea 2 to attacker for 2 seconds
#             strike lightning effect at the attacker
#             damage attacker by 1 heart
                       
# on damage:
#     if victim's health <= 3:
#         if lore of victim's helmet contains "&7Escapist":
#             apply swiftness 2 to victim for 5 seconds
#             apply invisibility to victim for 5 seconds
#             wait 5 seconds
#             remove swiftness from victim
               
# every 2 seconds:
#     loop all players:
#         if lore of loop-player's boots contains "&7Speed I":
#             apply swiftness 1 to loop-player for 2.01 seconds
#         else if lore of loop-player's boots contains "&7Speed II":
#             apply swiftness 2 to loop-player for 2.01 seconds

# every 2 seconds:
#     loop all players:
#         if lore of loop-player's leggings contains "&7Bounce":
#             apply jump boost 2 to loop-player for 2.01 seconds


thats my new skript, is there anything else i can do to make it better/more efficient/optimized? if so, what and how?
At the end, I see you have two loops that loop all players.This can be very inefficient and usually cuts down server performance
Make sure to put as few loops as you can

code_language.skript:
every 2 seconds:
    loop all players:
        if lore of loop-player's boots contains "&7Speed I":
            apply swiftness 1 to loop-player for 2.01 seconds
        else if lore of loop-player's boots contains "&7Speed II":
            apply swiftness 2 to loop-player for 2.01 seconds
            
        # Leggings
        
        if lore of loop-player's leggings contains "&7Bounce":
            apply jump boost 2 to loop-player for 2.01 seconds
 
At the end, I see you have two loops that loop all players.This can be very inefficient and usually cuts down server performance
Make sure to put as few loops as you can

code_language.skript:
every 2 seconds:
    loop all players:
        if lore of loop-player's boots contains "&7Speed I":
            apply swiftness 1 to loop-player for 2.01 seconds
        else if lore of loop-player's boots contains "&7Speed II":
            apply swiftness 2 to loop-player for 2.01 seconds
           
        # Leggings
       
        if lore of loop-player's leggings contains "&7Bounce":
            apply jump boost 2 to loop-player for 2.01 seconds
Alright, I'll have to add that, i know about using Functions to make code shorter and cleaner, but im not good at making them. I really dont know how to make it all work in functions. I just want my code to be as organized/neat/optimized as possible.