summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/yulqen/test/KillZombies.java
blob: 2e1f9f83da84833e516a97fa1f70395ce2dbb71e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.yulqen.test;

import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Zombie;

import java.util.Collection;

import static org.bukkit.Bukkit.getServer;

public class KillZombies implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

        World world = getServer().getWorld("mad_march_hare");
        Collection<Entity> zombies = world.getEntitiesByClasses(Zombie.class);
        for (Entity z : zombies) {
            z.remove();
        }
        if (zombies.isEmpty()) {
            return false;
        }
        System.out.println("Killed all the zombies...");
        return true;
    }
}