mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
PurgeWorlds class, purges a given world of the given entities.
This commit is contained in:
parent
f579b36d65
commit
37b2ad7e1d
52
src/com/onarandombox/utils/PurgeWorlds.java
Normal file
52
src/com/onarandombox/utils/PurgeWorlds.java
Normal file
@ -0,0 +1,52 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
||||
import com.onarandombox.MultiVerseCore.MultiVerseCore;
|
||||
|
||||
public class PurgeWorlds {
|
||||
|
||||
MultiVerseCore plugin;
|
||||
|
||||
public PurgeWorlds(MultiVerseCore plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void purge(CommandSender sender, World w, List<String> creatures){
|
||||
|
||||
List<Entity> entities = w.getEntities();
|
||||
int count = 0;
|
||||
|
||||
for(Entity e: entities){
|
||||
if ((((e instanceof Creeper)) && (creatures.contains("CREEPER"))) || (((e instanceof Skeleton)) && (creatures.contains("SKELETON"))) ||
|
||||
(((e instanceof Spider)) && (creatures.contains("SPIDER"))) || (((e instanceof Zombie)) && (creatures.contains("ZOMBIE"))) ||
|
||||
(((e instanceof Ghast)) && (creatures.contains("GHAST"))) || (((e instanceof PigZombie)) && (creatures.contains("PIGZOMBIE"))) ||
|
||||
(((e instanceof Giant)) && (creatures.contains("GIANT"))) || (((e instanceof Slime)) && (creatures.contains("SLIME"))) ||
|
||||
(((e instanceof Chicken)) && (creatures.contains("CHICKEN"))) || (((e instanceof Cow)) && (creatures.contains("COW"))) ||
|
||||
(((e instanceof Sheep)) && (creatures.contains("SHEEP"))) || (((e instanceof Pig)) && (creatures.contains("PIG"))) || (
|
||||
((e instanceof Squid)) && (creatures.contains("SQUID"))) || creatures.contains("*")) {
|
||||
e.remove();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(count + " Entities Purged from " + w.getName());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user