How To Make An Enchanting Plugin?

Discussion in 'Plugin Development' started by razorkings, Apr 13, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    razorkings

    Hi, I Would Like To Know How To Make An Enchanting Plugin Since I Don't Really Know How To Make One... I Know How To Add Enchantments and Unsafe Enchantments For Plugins Like KitPvP For Example But I Would Like To Know How To Make One So I Can Just Do /Enchant <Item> <Level> Or /Enchant <Level> So If You Can Help Me I Will Be Grateful See Ya :)

    Also Please Don't Say "Just Use Essentials" But I Wont Since I Really Want To Make It Into A Custom Plugin.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. razorkings Wow, capitalising every word makes it really annoying to read.
     
    KingFaris11 likes this.
  3. Offline

    razorkings

    Sorry about that force of habit
     
  4. We're not going to feed you the code. Although, here are a few pointers:

    Code:
    Enchantment.getById(id);
    Code:
    Enchantment.getByName(name);
    Code:
    public boolean isInteger(String aString) {
        try {
            Integer.parseInt(aString);
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
    Get the args[0], if it is an integer, use Integer.parseInt(args[0]) and then get the Enchantment by the ID. If the enchantment is not null, continue, if not, use Enchantment.getByName(args[0]) and if it is not null, continue, if not, message the player saying it's an invalid enchantment.
    Then to get the level, check if args[1] is an integer, if it is, use Integer.parseInt() to set the level.
     
  5. razorkings
    To be a little bit helpful, you could make it detecting the item you're holding so you'd only need to do
    /enchant <enchantment> <level>
    You could detect the item in hand by using player.getItemInHand();
    But about how to do the enchantments, I'm not sure, if I find out anything I'll tell you.
     
Thread Status:
Not open for further replies.

Share This Page