Personal Kit PVP Plugin Not Working

Discussion in 'Plugin Development' started by Lusydia, Dec 28, 2013.

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

    Lusydia

    Hi guys, im trying to make my own Kit PVP Plugin and im doing something wrong. The only lead i have is in the PVP Signs where there is a lightbulb with a cross on it (eclipse). The first lightbulb comes up under "addUnsafeEnchantment" where it tells me to rename it to "addEnchantment" only to tell me to rename it back to "addUnsafeEnchantment". The second lightbulb error comes under meta (dont know much about that one).

    Heres a copy of the code

    Code:java
    1. package me.Lusydia.UltimatePVP;
    2. import org.bukkit.Bukkit;
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.block.SignChangeEvent;
    9. import org.bukkit.inventory.ItemStack;
    10. import org.bukkit.inventory.meta.ItemMeta;
    11. import org.bukkit.potion.PotionEffectType;
    12. import org.bukkit.enchantments.Enchantment;
    13.  
    14.  
    15. public class Bowman implements Listener{
    16.  
    17. public static Bukkit plugin;
    18.  
    19. public void BukkitListener(Bukkit instance) {
    20. plugin = instance;}
    21.  
    22. @EventHandler
    23. public void onSignCreate(SignChangeEvent sign){
    24. Player p = sign.getPlayer();
    25. if(sign.getLine(0).equalsIgnoreCase("[PVP]"))
    26. if(sign.getLine(1).equalsIgnoreCase("Bowman"))
    27. p.sendMessage(ChatColor.GOLD + "You have chosen the kit Bowman!");
    28.  
    29. p.getInventory().clear();
    30.  
    31. ItemStack STONE_SWORD = new ItemStack(Material.STONE_SWORD);
    32. ItemMeta meta = STONE_SWORD.getItemMeta();
    33. meta.setDisplayName("Safety Sword");
    34. meta.addUnsafeEnchantment(Enchantment.DAMAGE_ALL,1);
    35. STONE_SWORD.setItemMeta(meta);
    36. p.getInventory().addItem(STONE_SWORD);
    37. ItemStack BOW = new ItemStack(Material.BOW);
    38.  
    39. ItemMeta meta = BOW.getItemMeta();
    40. meta.setDisplayName("Trusty Bow");
    41. meta.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE,3,Enchantment.ARROW_KNOCKBACK,2);
    42. BOW.setItemMeta(meta);
    43. p.getInventory().addItem(BOW);
    44.  
    45. p.getInventory().addItem(new ItemStack(Material.ARROW,64));
    46.  
    47. p.getInventory().addItem(new ItemStack(Material.ARROW,64));
    48.  
    49. p.getInventory().addItem(new ItemStack(Material.COOKED_BEEF,4));
    50.  
    51. ItemStack CHAINMAIL_HELMET = new ItemStack(Material.CHAINMAIL_HELMET);
    52.  
    53. ItemMeta meta = CHAINMAIL_HELMET.getItemMeta();
    54. meta.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,3);
    55. CHAINMAIL_HELMET.setItemMeta(meta);
    56. p.getInventory().addItem(CHAINMAIL_HELMET);
    57. ItemStack CHAINMAIL_CHESTPLATE = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
    58.  
    59. ItemMeta meta = CHAINMAIL_CHESTPLATE.getItemMeta();
    60. meta.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,3);
    61. CHAINMAIL_CHESTPLATE.setItemMeta(meta);
    62. p.getInventory().addItem(CHAINMAIL_CHESTPLATE);
    63. ItemStack CHAINMAIL_LEGGINGS = new ItemStack(Material.CHAINMAIL_LEGGINGS);
    64.  
    65. ItemMeta meta = CHAINMAIL_LEGGINGS.getItemMeta();
    66. meta.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,3);
    67. CHAINMAIL_LEGGINGS.setItemMeta(meta);
    68. p.getInventory().addItem(CHAINMAIL_LEGGINGS);
    69. ItemStack CHAINMAIL_BOOTS = new ItemStack(Material.CHAINMAIL_BOOTS);
    70.  
    71. ItemMeta meta = CHAINMAIL_BOOTS.getItemMeta();
    72. meta).addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,3);
    73. meta.addUnsafeEnchantment(Enchantment.PROTECTION_FALL,3);
    74. CHAINMAIL_BOOTS.setItemMeta(meta);
    75. p.getInventory().addItem(CHAINMAIL_BOOTS);
    76.  
    77. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED));
    78.  
    79.  
    80.  
    81. }
    82. }


    I can paste the rest of my other classes if its needed

    Thankyou Lusydia!
     
  2. Offline

    xTigerRebornx

    Lusydia Why are you passing Bukkit itself into your class?......wut..........Is your plugin named Bukkit? You get a problem with meta because you are using more then one variable with the same name, causing problems
     
  3. Offline

    Lusydia

    The reason im passing Bukkit into the class is that it was randomly causing errors into the class without it but iv just deleted it so its fine now. And for the meta... Im smart

    But that still doesnt explain why im getting errors for the enchantments

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    Gater12

    Lusydia Uhh.....
    Should it be
    Code:java
    1. STONE_SWORD.addUnsafeEnchantment(Enchantment, int);
     
  5. Offline

    xTigerRebornx

  6. Offline

    HyrulesLegend

  7. Offline

    Lusydia

    Should i not use Unsafe?
     
  8. Offline

    xTigerRebornx

  9. Offline

    HyrulesLegend

  10. Offline

    xTigerRebornx

    Max_The_Link_Fan Idk why, but the OP is adding the enchants VIA the ItemMeta, so I gave him the solution for ItemMeta
     
  11. Offline

    Lusydia

    GUYS Gater12 already worked this out... but there is one thing thats come up how would i apply the potion effect speed (i tried this but more errors)
    Code:java
    1. p.addPotionEffect(new PotionEffect ((PotionEffectType.SPEED);


    And because this is a kit pvp server

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  12. Offline

    doubleboss00

  13. Offline

    CeramicTitan

    You probably should be using unsafe. It will avoid errors
     
  14. Offline

    HyrulesLegend

    Lusydia
    Code:java
    1. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, int, int);
     
  15. Offline

    Lusydia

    All of that is underlined red
     
  16. Offline

    CeramicTitan

    Import
     
  17. Offline

    Lusydia

    import what? The code? how?
     
  18. Offline

    CeramicTitan

    Scroll over the red lines and click import {object} from org.bukkit
     
  19. Offline

    HyrulesLegend

    Replace the "int" with numbers.
     
  20. Offline

    Lusydia

    Ok actually thanks guys i fixed it. I flunked it and hadnt changed the int thanks!

    oh by the way my servers going public on the first of feburary ill give you guys a rank

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  21. Offline

    xTigerRebornx

    Lusydia No need, we are here to help (and code) (and run Bukkit servers)
     
  22. Offline

    Lusydia

    TheRestoneEmeraldGames

    ok fine thanks anyway!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page