I need help with this me.anton.infected;

Discussion in 'Plugin Development' started by TonySet, Dec 30, 2017.

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

    TonySet

    The title pretty much explains what I need help with but anyways I'm trying to make a zombie spawning plugin and I needed to add an infected this for some moar code and it was working before and now it just is destroying me trying to figure this out if you could help me out it would be greatly apricated.
    Thanks, ~Anton
    Code:
    package net.anton.infected;
    
    
    import java.util.logging.Logger;
    import me.anton.infected.Infected;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Zombie;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class Main extends JavaPlugin implements Listener
    {
    
    public final Logger log = Logger.getLogger("Minecraft");
    
    public void onEnable()
    {
    log.info("Bosses Enabled");
    getServer().getPluginManager().registerEvents(this, this);
    }
    
    public void onDisable()
    {
    log.info("Bosses Disabled");
    }
    
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
    if (cmd.getName().equalsIgnoreCase("ZombieHere"))
    {
    if(sender instanceof Player)
    {
    Player p = (Player) sender;
    spawnZombie(p);
    }else{
    sender.sendMessage("You must be a player to execute this command!");
    }
    return true;
    }
    return false;
    }
    
    public void spawnZombie(Player p)
    {
    
    PotionEffect slow = new PotionEffect(PotionEffectType.SLOW, 6000000, 20);
    PotionEffect nojump = new PotionEffect(PotionEffectType.JUMP, 6000000, -1);
    Zombie z = p.getLocation().getWorld().spawn(p.getLocation(), Zombie.class);
    z.setCustomName(ChatColor.GREEN + "" + ChatColor.BOLD + "LEFT CLICK FOR INFECTED");
    z.setBaby(false);
    z.setVillager(false);
    z.addPotionEffect(slow);
    z.addPotionEffect(nojump);
    z.setCustomNameVisible(true);
    
    }
    
    @EventHandler
    public void onEntityDamageEvent(EntityDamageByEntityEvent e)
    {
    
    if(e.getDamager() instanceof Player)
    {
    if(e.getEntityType().equals(EntityType.ZOMBIE))
    {
    e.setCancelled(true);
    Player p = (Player) e.getDamager();
    Infected.addPlayerInLobby(p);
    }
    }
    if(e.getDamager() instanceof Zombie)
    {
    if(e.getEntityType().equals(EntityType.PLAYER))
    {
    e.setCancelled(true);
    }
    }
    
    }
    
    
    }
     
  2. Offline

    Caedus

    What exactly is the problem?
     
    KingOfTheEast01 likes this.
  3. Offline

    TonySet

    im trying to import me.anton.infected.Infected;
     
  4. Offline

    timtower Administrator Administrator Moderator

    @TonySet Remove the import, just use the class somewhere and hit the auto import button.
    Remove your logger, nothing should use the minecraft logger.
    Don't log your own plugins, Bukkit does that for you.
    Enums are compared with ==, not with equals.
     
    KingOfTheEast01 likes this.
  5. Offline

    CeramicTitan

    Also furthering this, Please fix your indentation. It's super important in programming.
     
    timtower and KingOfTheEast01 like this.
Thread Status:
Not open for further replies.

Share This Page