Solved Spawn LivingEntity

Discussion in 'Plugin Development' started by MrSpyMan, Dec 22, 2014.

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

    MrSpyMan

    I just cut a part of my command plugin, I have no idea why this won't work..

    Code:
    else if(cmd.getLabel().equalsIgnoreCase("spawncashman")) {
                if(sender.isOp()) {
                Player player = Bukkit.getPlayer(sender.getName());
                LivingEntity cashman = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM);
                cashman.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 10));
                cashman.setHealth(100);
                cashman.setCustomName(ChatColor.GOLD + "Cash Man");
                cashman.setCustomNameVisible(true);
                cashman.teleport(player.getLocation());
                sender.sendMessage(ChatColor.GREEN + "You have spawned the Cash Man.");
            }
            }
     
  2. @MrSpyMan ... What doesn't work? Simply writing it doesn't work won't help many people solve your issue. Error in console? Feature not working?

    If you're spawning the Cash Man at the player's location, then why do you teleport it to the player's location?
     
  3. Offline

    _Filip

    Why even use LivingEntity?
     
Thread Status:
Not open for further replies.

Share This Page