How to use essentials kits api

Discussion in 'Plugin Development' started by 4thegame3, Nov 11, 2014.

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

    4thegame3

    Check this code
    Code:java
    1. package com.elmakers.mine.bukkit.essentials;
    2.  
    3. import com.earth2me.essentials.ItemDb;
    4. import com.elmakers.mine.bukkit.api.spell.SpellCategory;
    5. import com.elmakers.mine.bukkit.magic.MagicController;
    6. import com.elmakers.mine.bukkit.wand.Wand;
    7. import net.ess3.api.IEssentials;
    8. import org.bukkit.inventory.ItemStack;
    9.  
    10. public class MagicItemDb extends ItemDb
    11. {
    12. private final MagicController controller;
    13.  
    14. public MagicItemDb(MagicController controller, Object ess)
    15. {
    16. super((IEssentials)ess);
    17. this.controller = controller;
    18. reloadConfig();
    19. }
    20.  
    21. public ItemStack get(String id)
    22. throws Exception
    23. {
    24. if (id.equals("wand")) {
    25. Wand wand = Wand.createWand(this.controller, "");
    26. if (wand != null)
    27. return wand.getItem();
    28. }
    29. else if (id.startsWith("wand:")) {
    30. String wandId = id.replace("wand:", "");
    31. Wand wand = Wand.createWand(this.controller, wandId.trim());
    32. if (wand != null) {
    33. return wand.getItem();
    34. }
    35. }
    36. else if (id.startsWith("w:")) {
    37. String wandId = id.replace("w:", "");
    38. Wand wand = Wand.createWand(this.controller, wandId.trim());
    39. if (wand != null) {
    40. return wand.getItem();
    41. }
    42. }
    43. else if (id.startsWith("book:")) {
    44. String bookCategory = id.replace("book:", "");
    45. SpellCategory category = null;
    46. if ((bookCategory.length() > 0) && (!bookCategory.equalsIgnoreCase("all"))) {
    47. category = this.controller.getCategory(bookCategory);
    48. }
    49. ItemStack bookItem = this.controller.getSpellBook(category, 1);
    50. if (bookItem != null)
    51. return bookItem;
    52. }
    53. else if (id.startsWith("spell:")) {
    54. String spellKey = id.replace("spell:", "");
    55. ItemStack itemStack = Wand.createSpellItem(spellKey, this.controller, null, true);
    56. if (itemStack != null)
    57. return itemStack;
    58. }
    59. else if (id.startsWith("s:")) {
    60. String spellKey = id.replace("s:", "");
    61. ItemStack itemStack = Wand.createSpellItem(spellKey, this.controller, null, true);
    62. if (itemStack != null)
    63. return itemStack;
    64. }
    65. else if (id.startsWith("brush:")) {
    66. String brushKey = id.replace("brush:", "");
    67. ItemStack itemStack = Wand.createBrushItem(brushKey, this.controller, null, true);
    68. if (itemStack != null)
    69. return itemStack;
    70. }
    71. else if (id.startsWith("upgrade:")) {
    72. String wandId = id.replace("upgrade:", "");
    73. Wand wand = Wand.createWand(this.controller, wandId.trim());
    74. if (wand != null) {
    75. wand.makeUpgrade();
    76. return wand.getItem();
    77. }
    78. } else if (id.startsWith("item:")) {
    79. String wandId = id.replace("item:", "");
    80. return this.controller.createItem(wandId);
    81. }
    82.  
    83. return super.get(id);
    84. }
    85. }

    its from plugin MAGIC, but i cant make it work, any help implementing it in a plugin?
     
  2. Offline

    Skionz

    So you didn't even write this?
     
Thread Status:
Not open for further replies.

Share This Page