error player interact event

Discussion in 'Plugin Development' started by pedrinofss, Sep 24, 2015.

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

    pedrinofss

    LEFT_CLICK_AIR cannot be resolved or is not a field


    package me.pedro;

    import java.awt.Desktop.Action;

    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Arrow;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.minecraft.server.v1_7_R3.ItemStack;

    public class main extends JavaPlugin implements Listener{
    public void onEnable()
    {
    getLogger().info("--------------------------------------------------");
    getLogger().info("-----------------Plugin ligado--------------------");
    getLogger().info("--------------------------------------------------");
    this.getServer().getPluginManager().registerEvents(this, this);
    }
    public void onDisable()
    {
    getLogger().info("--------------------------------------------------");
    getLogger().info("-----------------Plugin desligado-----------------");
    getLogger().info("--------------------------------------------------");
    }

    @SuppressWarnings("deprecation")
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

    Player player = (Player) sender;




    if (command.getName().equalsIgnoreCase("gm1")){
    player.sendMessage(ChatColor.DARK_RED + "Seu modo foi mudado para " + ChatColor.DARK_GREEN + "Criativo!");
    player.setGameMode(GameMode.CREATIVE);
    }
    if (command.getName().equalsIgnoreCase("gm0")){
    player.sendMessage(ChatColor.DARK_RED + "Seu modo foi mudado para " + ChatColor.DARK_GREEN + "Sobrevivencia!");
    player.setGameMode(GameMode.SURVIVAL);
    }

    return false;

    }

    @EventHandler
    public void PlayerInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    if (event.getPlayer().getItemInHand().getType().equals(Material.EGG)) {
    if (!(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) return;
    }

    }



    }
     
  2. Offline

    finalblade1234

    "import java.awt.Desktop.Action;", this version of "Action" does not have LEFT_CLICK_AIR. Use bukkit's Action
     
  3. Offline

    pedrinofss

    what??? i'm very noob in code
     
  4. Offline

    RoboticPlayer

    A) Learn Java before trying to use Bukkit, you will get into lots of bad habits otherwise
    B) Please use [ code=Java ] //your code here [ /code ] braces (without spaces), it makes code so much easier to read
    C) @finalblade1234 was saying that you imported the wrong thing for Action, instead import org.bukkit.event.block.Action
    D) Get rid of your enabling and disabling messages, Bukkit already does this
    E) onEnable and onDisable are overridden methods
    F) Check before casting sender to player
     
    mine-care likes this.
  5. Offline

    DoggyCode™

    I started Bukkit before knowing a bit of Java (2 years ago), I watched videos like the BC bros and this forum helped me a lot to improve those habits.
     
  6. Offline

    boomboompower

    @pedrinofss Hes saying

    Don't use this as your import. Use the one the Bukkit API provides.
    Code:
    import java.awt.Desktop.Action;
     
  7. Offline

    pedrinofss

    that is the error in the import: The import org.bukkit.event.block.Action collides with another import statement
     
  8. Offline

    RoboticPlayer

    Get rid of the line with the other import, then it should be fixed.
     
Thread Status:
Not open for further replies.

Share This Page