I created a plugin , but it does not work as it should work .

Discussion in 'Plugin Development' started by ZioLollo_, Jul 31, 2016.

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

    ZioLollo_

    Hello.
    I just started to create plugins , today I had the idea of creating a drug plugin ( 1.8 ) to my server , as with the events I do not very well lead I decided to just make a right to test drugs , the plugin works , the only problem is that the effect of cocaine ( the first drug I wanted to do ) not only works on the item selected (sugar ) but with any item , even clicking the air.
    I shall leave the script in a file.yml .
    Please let help me it is urgent ! D :
     

    Attached Files:

  2. Online

    timtower Administrator Administrator Moderator

    Moved to plugin development.
     
  3. Offline

    Jakeeeee

    Can you save us time and put the code in
    Code:
    
    
    tags?
     
  4. Offline

    ZioLollo_

    Code:
    package zio.droghe;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class PlayerListener implements Listener{
      
       public PlayerListener(EventHandle plugin) {
         plugin.getServer().getPluginManager().registerEvents(this, plugin);
       }
      
       @EventHandler
       public void onPlayerInteract(PlayerInteractEvent e)
       {
         Player p = e.getPlayer();
         if (e.getPlayer().hasPermission("tubedrugs.cocaina"))
          if (p.getItemInHand().getType() == Material.SUGAR);
          ItemStack stack = p.getItemInHand();
      short data = stack.getDurability();
      if (p.getItemInHand().getType() == Material.SUGAR);
      if ((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)));
      
         e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 1) );
         e.getPlayer().sendMessage("§9TubeCraft> §7Effetto " + ChatColor.RED + "cocaina §6attivato§7!");
      
         ItemStack old = new ItemStack(e.getPlayer()
      .getItemInHand().getType(), e
      .getPlayer().getItemInHand()
      .getAmount() - 1, data);
      e.getPlayer().setItemInHand(old);
      
        }
    }
     
    Last edited by a moderator: Aug 1, 2016
  5. Offline

    SuperSniper

    if (p.getItemInHand().getType() == Material.SUGAR);
    if ((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)));

    replace the ; with {
     
  6. Offline

    ZioLollo_

    Done , but nothing has changed

    Please help me D:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 31, 2016
  7. Offline

    Oxyorum


    You have a lot of place in the code where you are using ; instead of curly braces. Care to fix those and update your code?
     
  8. @ZioLollo_ You don't save code in a YAML file. You need to put this in an IDE like Eclipse and compile it into a jar file.
     
  9. Offline

    ArsenArsen

    Or just use javac if you want to go old school ;)
     
Thread Status:
Not open for further replies.

Share This Page