Enchantant

Discussion in 'Plugin Development' started by Faus, Dec 1, 2018.

  1. Offline

    Faus

    Can i make a sword not enchantable?
    if yes how?
     
  2. Offline

    The_Spaceman

    use the EnchantItemEvent and when an sword is enchanted cancel the event
     
  3. Offline

    Faus

    I need something that limits enchant for a sword like a kit on my server got sword sharp 5, i want a thing that no one can for example add looting on that sword, (u cant change , or lvl up, the item enchant or add one)
    @The_Spaceman could u explain me how to do that?
     
  4. Offline

    The_Spaceman

    create the event,
    get the enchantments and remove the Enchantment.LOOT_BONUS_MOBS enchantment.
    use the getEnchantsToAdd() to get the enchantments

    I don't know if this works but I'll think it works
     
  5. Offline

    Faus

    How and where, what plugin is that, whats is that? how to crate event what u mean i said i dont now how
     
  6. Offline

    The_Spaceman

    create a plugin (if you don't know how I highly suggest to look up a tutorial about it)
    create a class that extends Listener
    register the class in your onEnable using Bukkit.getPluginManager().registerEvents(yourClass, yourMainClass);
    in your Listener class create a method with the annotation '@EventHandler' and put 'EnchantItemEvent e' in the brackets.
    get the enchantments from the event and remove the Enchantment

    some parts may have a different name (I did this from my head)
    that is basically all...
     
  7. Offline

    Faus

    thats sad that 750+ peaple review this ticket and no ones now how
    do i can somehow make it so that people can't put any further enchantments on the items with books? Basically lock the enchantments somehow!




    :-:rip






    Im trying but its so difficult :-:
    There is another way pls?

    package me.skiawcraft.EnchantItemEvent.command;

    import me.skiawcraft.EnchantItemEvent.Main;
    import org.bukkit.command.CommandExecutor;

    public class Commands implements Listener {

    private Main plugin;

    public Commands(Main Plugin){
    this.plugin = plugin;

    Bukkit.getPluginManager().registerEvents(yourClass, yourMainClass);
    }

    @EventHandler


    if its correct could u continue this pls <3?Im stuck idk what to do
    (so there is no plugin or something like that to do a simple thing like this? :-:)
    because i saw a server that had items whit the lore *original*/Unenchantable, and u literaly
    cant enchant the item)
     
    Last edited: Dec 1, 2018
  8. Offline

    The_Spaceman

    this is something else than you said,

    put in your onEnable()
    Bukkit.getPluginManager().registerEvents(this, this);

    put this in your main class
    @EventHander
    public void enchEvent(EnchantItemEvent e) {
    if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore().contains("Unenchantable")) {
    e.setCancelled(true);
    }
    }
     

Share This Page