use of org.bukkit.World in project EliteMobs by MagmaGuy.
the class MobScanner method scanMobs.
public void scanMobs(int passiveStackAmount) {
for (World world : worldList) {
Iterator<LivingEntity> iterator = world.getLivingEntities().iterator();
while (iterator.hasNext()) {
Entity entity = iterator.next();
if (ValidAgressiveMobFilter.ValidAgressiveMobFilter(entity)) {
//scan for naturally/command/plugin spawned EliteMobs
if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() != 1 && ((Damageable) entity).getMaxHealth() == DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity)) {
HealthHandler.naturalAgressiveHealthHandler(entity, entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt());
customAggressiveName(entity);
PowerHandler.powerHandler(entity);
ArmorHandler.ArmorHandler(entity);
}
//scan for stacked EliteMobs
if (ConfigValues.defaultConfig.getBoolean("Allow aggressive EliteMobs") && ConfigValues.defaultConfig.getBoolean("Aggressive mob stacking") && !entity.hasMetadata(MetadataHandler.FORBIDDEN_MD)) {
if (!(entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() >= ConfigValues.defaultConfig.getInt("Aggressive mob stacking cap")) && !entity.hasMetadata(MetadataHandler.FORBIDDEN_MD)) {
scanValidAggressiveLivingEntity(entity);
}
if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
PowerHandler.powerHandler(entity);
ArmorHandler.ArmorHandler(entity);
}
}
}
//scan for passive mobs
if (ConfigValues.defaultConfig.getBoolean("Allow Passive EliteMobs")) {
//scan for passive mobs that might have lost their metadata
if (ValidPassiveMobFilter.ValidPassiveMobFilter(entity) && ((LivingEntity) entity).getMaxHealth() != DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity) && ((LivingEntity) entity).getMaxHealth() == DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity) * ConfigValues.defaultConfig.getInt("Passive EliteMob stack amount")) {
customPassiveName(entity, plugin);
}
//scan for new passive supermobs
if (ValidPassiveMobFilter.ValidPassiveMobFilter(entity) && !entity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD)) {
scanValidPassiveLivingEntity(entity);
}
//spawn chicken eggs, really wish there were an event for this
ChickenHandler.superEggs(entity, passiveStackAmount);
}
//scan for iron golems with missing metadata
if (!entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity instanceof IronGolem && ((IronGolem) entity).getMaxHealth() != DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity)) {
entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, ScalingFormula.reversePowerFormula(((IronGolem) entity).getMaxHealth(), DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity))));
customAggressiveName(entity);
}
}
}
}
use of org.bukkit.World in project EliteMobs by MagmaGuy.
the class StatsCommandHandler method statsHandler.
public void statsHandler(CommandSender commandSender) {
int mobLevelSavingsCount = 0;
int totalMobCount = 0;
int aggressiveCount = 0;
int passiveCount = 0;
int blazeCount = 0;
int caveSpiderCount = 0;
int creeperCount = 0;
int endermanCount = 0;
int endermiteCount = 0;
int huskCount = 0;
int ironGolemCount = 0;
int pigZombieCount = 0;
int polarBearCount = 0;
int silverfishCount = 0;
int skeletonCount = 0;
int spiderCount = 0;
int strayCount = 0;
int witchCount = 0;
int witherSkeletonCount = 0;
int zombieCount = 0;
int zombieVillagerCount = 0;
int chickenCount = 0;
int cowCount = 0;
int mushroomCowCount = 0;
int pigCount = 0;
int sheepCount = 0;
for (World world : worldList) {
for (LivingEntity livingEntity : world.getLivingEntities()) {
if (livingEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD) || livingEntity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD)) {
totalMobCount++;
if (livingEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
mobLevelSavingsCount += livingEntity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt();
aggressiveCount++;
switch(livingEntity.getType()) {
case ZOMBIE:
zombieCount++;
break;
case HUSK:
huskCount++;
break;
case ZOMBIE_VILLAGER:
zombieVillagerCount++;
break;
case SKELETON:
skeletonCount++;
break;
case WITHER_SKELETON:
witherSkeletonCount++;
break;
case STRAY:
strayCount++;
break;
case PIG_ZOMBIE:
pigZombieCount++;
break;
case CREEPER:
creeperCount++;
break;
case SPIDER:
spiderCount++;
break;
case ENDERMAN:
endermanCount++;
break;
case CAVE_SPIDER:
caveSpiderCount++;
break;
case SILVERFISH:
silverfishCount++;
break;
case BLAZE:
blazeCount++;
break;
case WITCH:
witchCount++;
break;
case ENDERMITE:
endermiteCount++;
break;
case POLAR_BEAR:
polarBearCount++;
break;
case IRON_GOLEM:
ironGolemCount++;
break;
default:
getLogger().info("Error: Couldn't assign custom mob name due to unexpected aggressive boss mob (talk to the dev!)");
getLogger().info("Missing mob type: " + livingEntity.getType());
break;
}
} else if (livingEntity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD)) {
//passive EliteMobs only stack at 50 right now
//TODO: redo this count at some other stage of this plugin's development
mobLevelSavingsCount += ConfigValues.defaultConfig.getInt("Passive EliteMob stack amount");
passiveCount++;
switch(livingEntity.getType()) {
case CHICKEN:
chickenCount++;
break;
case COW:
cowCount++;
break;
case MUSHROOM_COW:
mushroomCowCount++;
break;
case PIG:
pigCount++;
break;
case SHEEP:
sheepCount++;
break;
default:
getLogger().info("Error: Couldn't assign custom mob name due to unexpected passive boss mob (talk to the dev!)");
getLogger().info("Missing mob type: " + livingEntity.getType());
break;
}
}
}
}
}
if (commandSender instanceof Player) {
Player player = (Player) commandSender;
player.sendMessage("§5§m-----------------------------------------------------");
player.sendMessage("§a§lEliteMobs stats:");
player.sendMessage("There are currently §l§6" + totalMobCount + " §f§rEliteMobs replacing §l§e" + mobLevelSavingsCount + " §f§rregular mobs.");
if (aggressiveCount > 0) {
String aggressiveCountMessage = "§c" + aggressiveCount + " §4Aggressive EliteMobs: §f";
HashMap unsortedMobCount = new HashMap();
unsortedMobCountFilter(unsortedMobCount, blazeCount, "blazes");
unsortedMobCountFilter(unsortedMobCount, caveSpiderCount, "cave spiders");
unsortedMobCountFilter(unsortedMobCount, creeperCount, "creepers");
unsortedMobCountFilter(unsortedMobCount, endermanCount, "endermen");
unsortedMobCountFilter(unsortedMobCount, endermiteCount, "endermites");
unsortedMobCountFilter(unsortedMobCount, huskCount, "husks");
unsortedMobCountFilter(unsortedMobCount, pigZombieCount, "zombiepigmen");
unsortedMobCountFilter(unsortedMobCount, polarBearCount, "polar bears");
unsortedMobCountFilter(unsortedMobCount, silverfishCount, "silverfish");
unsortedMobCountFilter(unsortedMobCount, skeletonCount, "skeletons");
unsortedMobCountFilter(unsortedMobCount, spiderCount, "spiders");
unsortedMobCountFilter(unsortedMobCount, strayCount, "strays");
unsortedMobCountFilter(unsortedMobCount, witchCount, "witches");
unsortedMobCountFilter(unsortedMobCount, witherSkeletonCount, "wither skeletons");
unsortedMobCountFilter(unsortedMobCount, zombieCount, "zombie");
unsortedMobCountFilter(unsortedMobCount, zombieVillagerCount, "zombie villagers");
player.sendMessage(messageStringAppender(aggressiveCountMessage, unsortedMobCount));
}
if (passiveCount > 0) {
String passiveCountMessage = "§b" + passiveCount + " §3Passive EliteMobs: §f";
HashMap unsortedMobCount = new HashMap();
unsortedMobCountFilter(unsortedMobCount, chickenCount, "chickens");
unsortedMobCountFilter(unsortedMobCount, cowCount, "cows");
unsortedMobCountFilter(unsortedMobCount, ironGolemCount, "iron golems");
unsortedMobCountFilter(unsortedMobCount, mushroomCowCount, "mushroom cows");
unsortedMobCountFilter(unsortedMobCount, pigCount, "pigs");
unsortedMobCountFilter(unsortedMobCount, sheepCount, "sheep");
player.sendMessage(messageStringAppender(passiveCountMessage, unsortedMobCount));
}
player.sendMessage("§5§m-----------------------------------------------------");
} else if (commandSender instanceof ConsoleCommandSender) {
getServer().getConsoleSender().sendMessage("§5§m-------------------------------------------------------------");
getServer().getConsoleSender().sendMessage("§a§lEliteMobs stats:");
getServer().getConsoleSender().sendMessage("There are currently §l§6" + totalMobCount + " §f§rEliteMobs replacing §l§e" + mobLevelSavingsCount + " §f§rregular mobs.");
if (aggressiveCount > 0) {
String aggressiveCountMessage = "§c" + aggressiveCount + " §4Aggressive EliteMobs: §f";
HashMap unsortedMobCount = new HashMap();
unsortedMobCountFilter(unsortedMobCount, blazeCount, "blazes");
unsortedMobCountFilter(unsortedMobCount, caveSpiderCount, "cave spiders");
unsortedMobCountFilter(unsortedMobCount, creeperCount, "creepers");
unsortedMobCountFilter(unsortedMobCount, endermanCount, "endermen");
unsortedMobCountFilter(unsortedMobCount, endermiteCount, "endermites");
unsortedMobCountFilter(unsortedMobCount, huskCount, "husks");
unsortedMobCountFilter(unsortedMobCount, ironGolemCount, "iron golems");
unsortedMobCountFilter(unsortedMobCount, pigZombieCount, "zombiepigmen");
unsortedMobCountFilter(unsortedMobCount, polarBearCount, "polar bears");
unsortedMobCountFilter(unsortedMobCount, silverfishCount, "silverfish");
unsortedMobCountFilter(unsortedMobCount, skeletonCount, "skeletons");
unsortedMobCountFilter(unsortedMobCount, spiderCount, "spiders");
unsortedMobCountFilter(unsortedMobCount, strayCount, "strays");
unsortedMobCountFilter(unsortedMobCount, witchCount, "witches");
unsortedMobCountFilter(unsortedMobCount, witherSkeletonCount, "wither skeletons");
unsortedMobCountFilter(unsortedMobCount, zombieCount, "zombie");
unsortedMobCountFilter(unsortedMobCount, zombieVillagerCount, "zombie villagers");
getServer().getConsoleSender().sendMessage(messageStringAppender(aggressiveCountMessage, unsortedMobCount));
}
if (passiveCount > 0) {
String passiveCountMessage = "§b" + passiveCount + " §3Passive EliteMobs: §f";
HashMap unsortedMobCount = new HashMap();
unsortedMobCountFilter(unsortedMobCount, chickenCount, "chickens");
unsortedMobCountFilter(unsortedMobCount, cowCount, "cows");
unsortedMobCountFilter(unsortedMobCount, mushroomCowCount, "mushroom cows");
unsortedMobCountFilter(unsortedMobCount, pigCount, "pigs");
unsortedMobCountFilter(unsortedMobCount, sheepCount, "sheep");
getServer().getConsoleSender().sendMessage(messageStringAppender(passiveCountMessage, unsortedMobCount));
}
getServer().getConsoleSender().sendMessage("§5§m-------------------------------------------------------------");
}
}
use of org.bukkit.World in project TotalFreedomMod by TotalFreedom.
the class Command_mobpurge method purgeMobs.
public static int purgeMobs() {
int removed = 0;
for (World world : Bukkit.getWorlds()) {
for (Entity ent : world.getLivingEntities()) {
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient) {
ent.remove();
removed++;
}
}
}
return removed;
}
use of org.bukkit.World in project TotalFreedomMod by TotalFreedom.
the class WorldManager method onStart.
@Override
protected void onStart() {
flatlands.getWorld();
adminworld.getWorld();
// Disable weather
if (ConfigEntry.DISABLE_WEATHER.getBoolean()) {
for (World world : server.getWorlds()) {
world.setThundering(false);
world.setStorm(false);
world.setThunderDuration(0);
world.setWeatherDuration(0);
}
}
}
use of org.bukkit.World in project TotalFreedomMod by TotalFreedom.
the class AdminWorld method generateWorld.
@Override
protected World generateWorld() {
final WorldCreator worldCreator = new WorldCreator(getName());
worldCreator.generateStructures(false);
worldCreator.type(WorldType.NORMAL);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
final World world = Bukkit.getServer().createWorld(worldCreator);
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
welcomeSignBlock.setType(Material.SIGN_POST);
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
signData.setFacingDirection(BlockFace.NORTH);
welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld");
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
welcomeSign.update();
plugin.gr.commitGameRules();
return world;
}
Aggregations