Another error :(

Discussion in 'Plugin Development' started by CheifKeef, Aug 24, 2014.

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

    CheifKeef

    So I'm making a plugin when you right click a FIREBALL or whatever it makes you invisible I'm having a error and can't find a solution

    The event is underlined red

    Code:java
    1. package me.PokeMasterBrobee.InvisRing;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Material;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.block.Action;
    10. import org.bukkit.inventory.ItemStack;
    11. import org.bukkit.plugin.PluginDescriptionFile;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13. import org.bukkit.potion.PotionEffect;
    14. import org.bukkit.potion.PotionEffectType;
    15.  
    16. public class InvisRing extends JavaPlugin{
    17. public static Logger logger = Logger.getLogger("Minecraft");
    18. public static InvisRing plugin;
    19.  
    20. @Override
    21. public void onEnable() {
    22. PluginDescriptionFile pdfFile = this.getDescription();
    23. InvisRing.logger.info(pdfFile.getName() + pdfFile.getVersion() + "Activated");
    24. }
    25.  
    26. @Override
    27. public void onDisable() {
    28. PluginDescriptionFile pdfFile = this.getDescription();
    29. InvisRing.logger.info(pdfFile.getName() + pdfFile.getVersion() + "Deactivated");
    30. }
    31.  
    32. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    33. Player player = (Player) sender;
    34. if(cmd.getName().equalsIgnoreCase("InvisRing"));
    35. player.getInventory().addItem(new ItemStack(Material.FIREBALL));
    36. if(event.getAction()==Action.RIGHT_CLICK_AIR&&event.getPlayer().getItemInHand().getType()==Material.FIREBALL){
    37. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 500, 4));
    38. }
    39.  
    40. }
    41.  
    42. }
     
  2. Offline

    Rocoty

    You haven't defined event. Please learn Java properly before making Bukkit plugins. It is an absolute must.
     
  3. Offline

    Dragonphase

    CheifKeef

    Some very well needed tips:

    • Learn Java and how to use the Bukkit API.
    • Don't follow YouTube tutorial videos; most are outdated and don't teach you good coding practices.
    • Don't use the static keyword where it isn't necessary; The only place you should ever use the static keyword for your fields is if it's your plugin instance or if it's a final field in a Utility class.
    • Don't use Logger.getLogger("Minecraft"); Bukkit generously provides your plugin with its own logger. use getLogger();
    Please learn Java and the principles of Object Oriented Programming. Spend a decent amount of time familiarizing yourself with these. After that, learn how to use the Bukkit API.
     
Thread Status:
Not open for further replies.

Share This Page