KitPlugin - Should be easy fix :P

Discussion in 'Plugin Development' started by ZONEcold, Aug 13, 2014.

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

    ZONEcold

    Hello, I am new to coding and I'm just creating a simple Kit Plugin for my RolePlay server. I'm trying to implement Listener up the top of my code. Its only showing one Error and I have no idea what is causing it the error says "The type Listener cannot be a superinterface of main; a superinterface must be a interface" I can post my code below. If someone could reply that would be great :) Just keep in mine that I am new so don't go all crazy at me because I'm probably such a idiot :p

    Code:java
    1. package me.zonecold;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Color;
    5. import org.bukkit.Effect;
    6. import org.bukkit.Material;
    7. import org.bukkit.Sound;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.inventory.ItemStack;
    12. import org.bukkit.inventory.meta.ItemMeta;
    13. import org.bukkit.inventory.meta.LeatherArmorMeta;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class main extends JavaPlugin implements Listener {
    17.  
    18. public void onDisable(){
    19.  
    20. }
    21.  
    22. public void onEnable(){
    23.  
    24. }
    25. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    26. Player player = (Player) sender;
    27. if(commandLabel.equalsIgnoreCase("zkit") && args.length == 0){
    28. player.sendMessage(ChatColor.RED + "====================");
    29. player.sendMessage(ChatColor.DARK_RED + "Commands listed for Class Kits below");
    30. player.sendMessage(ChatColor.AQUA + "/zkit Doctor" + ChatColor.GRAY + " - Get the Doctor Kit");
    31. player.sendMessage(ChatColor.AQUA + "/zkit Hitman" + ChatColor.GRAY + " - Get the Hitman Kit");
    32. }
    33. if(cmd.getName().equalsIgnoreCase("zkit") && args.length == 1 && args[0].equalsIgnoreCase("doctor")){
    34. if(player.hasPermission("zkit.doctor")){
    35. player.sendMessage(ChatColor.GREEN + "Obtained the Doctor Kit");
    36. ItemStack shears = new ItemStack(Material.SHEARS);
    37. ItemMeta meta = shears.getItemMeta();
    38. meta.setDisplayName(ChatColor.RED + "Healing Scissors");
    39. shears.setItemMeta(meta);
    40. player.getInventory().addItem(shears);
    41. player.getInventory().addItem(new ItemStack(Material.PAPER, 64));
    42. ItemStack doctorchest = new ItemStack(Material.LEATHER_CHESTPLATE);
    43. LeatherArmorMeta doctormeta = (LeatherArmorMeta) doctorchest.getItemMeta();
    44. doctormeta.setColor(Color.GREEN);
    45. doctormeta.setDisplayName(ChatColor.GREEN + "Doctors Tunic");
    46. doctorchest.setItemMeta(doctormeta);
    47. player.getInventory().setChestplate(doctorchest);
    48. player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 32));
    49. player.playSound(player.getLocation(), Sound.CAT_MEOW, 2, 2);
    50. player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.WOOL);
    51. }
    52. }
    53. if(commandLabel.equalsIgnoreCase("zkit") && args.length == 1 && args[0].equalsIgnoreCase("hitman")){
    54. if(player.hasPermission("zkit.hitman")){
    55. player.sendMessage(ChatColor.GOLD + "Obtained the Hitman Kit");
    56. ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
    57. LeatherArmorMeta meta = (LeatherArmorMeta) chest.getItemMeta();
    58. meta.setColor(Color.BLACK);
    59. meta.setDisplayName(ChatColor.GRAY + "Hitmans Tunic");
    60. chest.setItemMeta(meta);
    61. player.getInventory().setChestplate(chest);
    62. ItemStack hitmansword = new ItemStack(Material.IRON_SWORD);
    63. ItemMeta metahitman = hitmansword.getItemMeta();
    64. metahitman.setDisplayName(ChatColor.GOLD + "Hitmans Sword");
    65. hitmansword.setItemMeta(metahitman);
    66. player.getInventory().addItem(hitmansword);
    67. player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 32));
    68. player.playSound(player.getLocation(), Sound.ENDERMAN_DEATH, 2, 2);
    69. player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.ANVIL);
    70. }
    71. }
    72. return false;
    73. }
    74. }


    Thanks :)
     
  2. Offline

    tommyhoogstra

    You're going to want @Override above your onEnable and onDisable.
     
  3. Offline

    ZodiacTheories

    Skyost likes this.
  4. Offline

    tommyhoogstra

    Should still have it.
     
    Skyost likes this.
  5. Offline

    ZodiacTheories

  6. Offline

    tommyhoogstra

    Neither are conventions, yet everyone abides by them.
    Maybe you can see what is wrong with his code?
     
    Skyost likes this.
  7. Offline

    ClassyInvader69

    ZONEcold
    There is no problem at all.
    You just need to import listener.
    Put this in your import: import org.bukkit.event.Listener;
     
  8. Offline

    Zandor300

    You need @Override above your onCommand too...
     
  9. Offline

    mazentheamazin

    Zandor300 tommyhoogstra ZodiacTheories
    About the @Override issue I'm going to reference do an answer on stackoverflow

     
  10. Offline

    ZodiacTheories

  11. Offline

    fireblast709

    tommyhoogstra Zandor300 the Override annotation is 100% optional (still preferred since it will be a compile time error if not overridden properly, but not necessary)
    ZONEcold The only things I can see you do wrong in the code you posted, is that you cast sender to Player before checking if it is a Player and that you rely on the commandLabel in the first if statement. The thing that you do wrong, but is not posted in the code, is that you most likely have a Listener class in the same package. Please delete that class and add the import as ClassyInvader69 suggested.
     
  12. Offline

    Zandor300

  13. Offline

    mazentheamazin

    ZodiacTheories
    I was contributing to end this 'debate' over if its necessary and when it should be used.
     
  14. Offline

    tommyhoogstra

    I'd rename your package as well, it won't fix the issue but itl stick to conventions

    Package naming convention is as follows (I think)
    Lets say my domain name (that I own) is www.google.com
    My package name will be com.google.pluginname.category (category is optional)
     
  15. Offline

    ZodiacTheories

    tommyhoogstra

    It really doesn't matter, lets just help solve the problem
     
  16. Offline

    TheDummy

    ZONEcold
    Code:
    import org.bukkit.event.Listener;
    You're missing an import. It's possible that it's looking at some other class/interface called Listener. Also, the main plugin class isn't registered as a listener in onEnable() function.

    As for the @Override annotation, you should really be using it even if it's not required.
     
  17. Offline

    ZONEcold

Thread Status:
Not open for further replies.

Share This Page