Development Assistance Need help with disguise command

Discussion in 'Plugin Help/Development/Requests' started by zspaceminer9, Mar 23, 2015.

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

    zspaceminer9

    I'm a noob, trying to make a plugin that takes the target player's head and copies their armor. This is the best I could do, not really sure how to make it.

    Code:
        if(label.equalsIgnoreCase("be")){
                if(args.length ==0)
                    return false;
            }
            if (args.length == 1){
                    Player target = Bukkit.getServer().getPlayer(args[0]);
                    ItemStack i = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
                    SkullMeta meta = (SkullMeta) i.getItemMeta();
                    meta.setOwner(target.getName());
                    p.getInventory().setHelmet(i);
                    ItemStack chestplate = target.getInventory().getChestplate();
                    ItemStack pants = target.getInventory().getLeggings();
                    ItemStack boots = target.getInventory().getBoots();
                    p.getInventory().setChestplate(chestplate);
                    p.getInventory().setLeggings(pants);
                    p.getInventory().setBoots(boots);
                    p.sendMessage("§6You are now disguised as" + "§6§l" + target.getName());
                    p.playSound(loc, Sound.CAT_MEOW, 100, 100);
                        }
     
  2. Offline

    pie_flavor

  3. Offline

    mine-care

    @pie_flavor nope it should not work.
    firstly use command.getName() not label because it does not allow aliases, then the problem is that you close the if opened at line 1, at line 4, so it is not in the command body... To fix either remove bracket at line 4 or add one at the and of line 2. My suggestion is, go over Java basics before starting bukkit.. Hope that helps.
     
  4. Offline

    pie_flavor

    @mine-care Simple mistake. Please don't insinuate that he doesn't know Java, and if you aren't using an IDE then there's no telltale indentation error. Also your instructions are confusing.
    @zspaceminer9
    You:
    Code:
    if (args.length == 0)
        return false;
    }
    Correct:
    Code:
    if (args.length == 0) {
        return false;
    }
    He is right about one thing, though. You should use cmd.getName() instead of label.
     
  5. Offline

    mine-care

    shall I consider this a personal attack; I hope not.
    I didn't insinuate it, I sugested at least a revision.
    the dimension you provided of someone not having IDE is true but by the format of the code above, and the looks of it it is likely to come from IDE then, by bukkit plugin tutorial it is sugested to use an IDE, and even if it is not the part of the code shown 'highlights' the issue, bottom line, I didn't use an IDE to trace the issue.
    Lastly I understand they might be unclear but to that there are a lot of things playing a role like dislexia, the fact that my mother toungh is not English and so on, the reason why I post it is because from no answer it is better to have one even if it is confusing.
    Hopefully I covered you :- )
     
Thread Status:
Not open for further replies.

Share This Page