Skips line of code & rerunning code

Discussion in 'Plugin Development' started by Corymbus, Aug 31, 2015.

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

    Corymbus

    1) My plugin seems to skip a line of code. It runs the spawn zombie, but not the player.sendMessage? The section of code is:
    Code:
        else if (args.length == 2)
           {
             if (args[1].equalsIgnoreCase("baby"))
               player.sendMessage(ChatColor.AQUA + "Swarm" + ChatColor.GRAY + " |" + ChatColor.RED + " Spawning a baby swarm of " + args[1]);
              Zombie z = (Zombie)player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
              z.setBaby(true);
              z.setCustomName(ChatColor.AQUA + "BabySwarm" + ChatColor.GRAY + " | " + args[1]);
              ItemStack skull = new ItemStack(Material.SKULL_ITEM);
              skull.setDurability((short)3);
              SkullMeta sm = (SkullMeta)skull.getItemMeta();
              sm.setOwner(args[1]);
              skull.setItemMeta(sm);
              z.getEquipment().setHelmet(new ItemStack(skull));
              z.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 1));
              z.setCustomNameVisible(true);
              z.setCustomName(ChatColor.AQUA + "BabySwarm" + ChatColor.GRAY + " | " + args[1]);
    2) Is there a way to repeat the zombie spawning method above without copying and pasting it? I tried public void but that created issues with the + args[1] (Is there is a way can I set playername to equal args[1] so I can use public void and replace with args[1] with playername in the public void?)
     
  2. Offline

    xMrPoi

    You forgot your opening and closing brackets for your baby if statement and your closing brackets for your argument length if statement.

    What do you mean by making a public void?

    You can use a for loop to spawn multiple zombies.
     
  3. Offline

    RainoBoy97

    Unless args[1] is equal to "baby" it wont send the message.
     
Thread Status:
Not open for further replies.

Share This Page