getting name

Discussion in 'Plugin Development' started by xguysprison, Mar 6, 2015.

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

    xguysprison

    hallo again so i am working on a plugin and i made it so that if they rightclick with a diamond pickaxe then it takes your pickaxe and replaceses it
    Code:
        @EventHandler
        public void onPlayerUse(PlayerInteractEvent e) {   
            Player p = e.getPlayer();
            if(plugin.toggle) {
                if (p.isSneaking()) {
                    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                        if(p.hasPermission("infusion.toggle")) {
                            if(e.hasItem()) {
                                ItemStack item = e.getItem();
                                if(plugin.helper.canEnchant(item.getType())) {
                                    if(plugin.helper.hasInfusion(item.getEnchantments())) {
                                        plugin.helper.remove(item);
                                    }else {
                                        plugin.helper.add(item);
                                    }
                                    p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1F, 1F);
                                    return;
    but i cant figure out how to do so when they rightclick nothing will happend unless its names Infusion Pickaxe.

    heres all my code
    http://pastie.org/private/yefpot0lyicgru8wxmzv9w

    please help me so i cant figure it out i tryed but cant get it to work
     
  2. Offline

    mine-care

    check for the name/lore of the item. Also you dont need a boolean in your oncommand method to define if it is a player, instead if it is not a player return true :p
     
  3. Offline

    xguysprison

    example please ?
    @mine-care
     
  4. Offline

    mine-care

  5. Offline

    xguysprison

  6. Offline

    mine-care

    @xguysprison well I think you are looking for spoon feeding, it won't help you and it will probably lead to a mistake, the li k above shows a google search where it is exactly what you need. Just read the docs and you will find what you Need =)
     
Thread Status:
Not open for further replies.

Share This Page