Disenchant

  • 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 community!

    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!

Apple00220

Member
Jul 31, 2025
2
0
1
command /customenchant <enchantment> <integer>:
trigger:
set {_enchanttype} to "%arg-1%" parsed as enchantment
set {_help} to "%arg-1%"
if "%{_help}%" is "sharpness":
set {_enchant} to "%arg-1% %arg-2%" parsed as enchantment type
make console execute command "/enchant %player% %{_enchant}%"
is my code rn which is cool and all but its not what i want, i want it so before it runs the last line (enchant line) it removes the %{_enchant}% enchantment from the item bcuz with /enchant command you cant enchant an item with lets say sharpness 5 if it has sharpness 3
 
Here's what you probably intended. And you can see this example on Documentations. Although I changed it for u.

JavaScript:
command /customenchant [<enchantment>] [<integer>]:
    permission: op
    trigger:
        if arg-1 is set:
            if player's held item is not air:
                if arg-2 is set:
                    set {_type} to "%arg-1%" parsed as enchantment
                    if {_type} is set:
                        if player's held item is enchanted with {_type}:
                            disenchant {_type}
                        set {_enchant} to "%arg-1% %arg-2%" parsed as enchantment type
                        enchant player's held item with {_enchant}
                        send "&7[&8Enchant&7] &fEnchanted your held item with %arg-1% %arg-2%"
                    else:
                        send "&cInvalid enchantment"
                else:
                    set {_type} to "%arg-1%" parsed as enchantment
                    if {_type} is set:
                        if player's held item is enchanted with {_type}:
                            disenchant {_type}
                        enchant player's held item with arg-1
                        send "&7[&8Enchant&7] &fEnchanted your held item with %arg-1%"
                    else:
                        send "&cInvalid enchantment"
            else:
                send "&cYou need to be holding an item to do this command"
        else:
            send "&cSpecify the enchantment"

on tab complete of "/customenchant":
    loop all enchantments:
        add loop-value to {_enchantments::*}
    set tab completions for position 1 to {_enchantments::*}
    set tab completions for position 2 to "<any number>"
 
Here's what you probably intended. And you can see this example on Documentations. Although I changed it for u.

JavaScript:
command /customenchant [<enchantment>] [<integer>]:
    permission: op
    trigger:
        if arg-1 is set:
            if player's held item is not air:
                if arg-2 is set:
                    set {_type} to "%arg-1%" parsed as enchantment
                    if {_type} is set:
                        if player's held item is enchanted with {_type}:
                            disenchant {_type}
                        set {_enchant} to "%arg-1% %arg-2%" parsed as enchantment type
                        enchant player's held item with {_enchant}
                        send "&7[&8Enchant&7] &fEnchanted your held item with %arg-1% %arg-2%"
                    else:
                        send "&cInvalid enchantment"
                else:
                    set {_type} to "%arg-1%" parsed as enchantment
                    if {_type} is set:
                        if player's held item is enchanted with {_type}:
                            disenchant {_type}
                        enchant player's held item with arg-1
                        send "&7[&8Enchant&7] &fEnchanted your held item with %arg-1%"
                    else:
                        send "&cInvalid enchantment"
            else:
                send "&cYou need to be holding an item to do this command"
        else:
            send "&cSpecify the enchantment"

on tab complete of "/customenchant":
    loop all enchantments:
        add loop-value to {_enchantments::*}
    set tab completions for position 1 to {_enchantments::*}
    set tab completions for position 2 to "<any number>"
with this you could get sharpness 10 on any items like a dirt too