Discussion in 'BungeeCord Plugin Development' started by Known, Apr 29, 2017.

  1. @EventHandler
    public void onInteract(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    if(e.getPlayer().getItemInHand().getType() == Material.AIR){
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 4));


    not really sure whats wrong with this code, someone help please.
    • Friendly Friendly x 1
  2. Im not getting any errors, it just wont work when i right click
    • Friendly Friendly x 1
  3. have you registered the event?
  4. First, format your plugin using the BBCode code tag.
    Second, I may be wrong, but I don't think a player can be holding air.
    Third, If your method is in another class, did you register you listener?
    Fourthly, you posted this in BungeeCord development, If you are putting in your BungeeCord plugins, I don't think it will work. put it on one of your servers.
  5. What do you mean?
  6. As in
    Code (Text):
    Bukkit.getPluginManager().registerEvents(Listener, JavaPlugin)
    • Like Like x 1
  7. Code (Java):

    //in your main class
    Bukkit.getServer().getPluginManager().registerEvents(new MyListener(), this);

    //if you have the event in main
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
    • Like Like x 1
  8. the event is in the main class, do i still need to register it
  9. you have to register it too:
    Bukkit.getPluginManager().registerEvents(this, this);
  10. Implement listener in your main class, and instead of Listener use "this"
  11. thanks boys i figured it out
    • Winner Winner x 1
    • Friendly Friendly x 1
  12. No problem ;) I make this error ofter than you xD