Right Click Air not working

Discussion in 'Spigot Plugin Help' started by NicksPvpsonMC, Jun 15, 2018 at 1:08 AM.

  1. So I am making a drug plugin cause all the other ones are not customizable and I basically don't but have this one problem with one of them.

    Code (Java):
                  if ((this.plugin.getConfig().getBoolean("Drugs.Toggle.werther")) &&
                              (p.hasPermission("bp.drugs.werther")) &&
                              ((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) &&
                              (p.getInventory().getItemInHand().getType() == Material.BAKED_POTATO))
                            {
                              p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 240, 1), true);
                              p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 240, 4), true);
                              p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 240, 3), true);
                              p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 240, 0), true);
                              p.setFoodLevel(20);;
                             
                              p.sendMessage(this.prefix + ChatColor.YELLOW + "You used a Werther.");
                              if (this.plugin.getConfig().getBoolean("Drugs.Console.logs")) {
                                this.logger.info(p.getName() + " used Werther");
                              }
                              if (amount > 1)
                              {
                                itemStack.setAmount(amount - 1);
                                p.getInventory().setItemInHand(itemStack);
                              }
                              if (amount == 1) {
                                p.getInventory().setItemInHand(null);
                                  }
                                }  
    All the code for the plugin is mostly the same besides this one because it has a different permission node but that shouldn't affect anything. When you right-click it in game it works but when you get to 1 in the stack it stops going away unless you right click a block and with any other drugs it works fine I have compared the code on each one and there the same so can someone please help me. Thanks
     
  2. This > 1 will check ints which are larger than 1 like = 2 ,3 , 100 , etc.

    Use this instead => 1

    Also next time use https://www.spigotmc.org/forums/spigot-plugin-development.52/
     
    #2 ZNetwork, Jun 15, 2018 at 3:20 AM
    Last edited: Jun 15, 2018 at 3:27 AM
  3. where exactly are you talking about
     

Share This Page