use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class ZombieFriends method onHit.
@EventHandler
public void onHit(EliteMobDamagedByPlayerEvent event) {
ZombieFriends zombieFriendConfig = (ZombieFriends) event.getEliteMobEntity().getPower(this);
if (zombieFriendConfig == null)
return;
if (zombieFriendConfig.isFiring())
return;
if (ThreadLocalRandom.current().nextDouble() > 0.01)
return;
zombieFriendConfig.setFiring(true);
CustomBossEntity reinforcement1 = CustomBossEntity.createCustomBossEntity("zombie_friends_friend.yml");
reinforcement1.spawn(event.getEntity().getLocation(), event.getEliteMobEntity().getLevel(), false);
CustomBossEntity reinforcement2 = CustomBossEntity.createCustomBossEntity("zombie_friends_friend.yml");
reinforcement2.spawn(event.getEntity().getLocation(), event.getEliteMobEntity().getLevel(), false);
new BukkitRunnable() {
@Override
public void run() {
if (!event.getEliteMobEntity().isValid() || !reinforcement1.isValid() && !reinforcement2.isValid()) {
if (reinforcement1 != null && reinforcement1.isValid()) {
nameClearer(reinforcement1);
reinforcement1.getLivingEntity().setCustomName(ChatColorConverter.convert(ZombieFriendsConfig.friendDeathMessage.get(ThreadLocalRandom.current().nextInt(ZombieFriendsConfig.friendDeathMessage.size()))));
}
if (reinforcement2 != null && reinforcement2.isValid()) {
nameClearer(reinforcement2);
reinforcement2.getLivingEntity().setCustomName(ChatColorConverter.convert(ZombieFriendsConfig.friendDeathMessage.get(ThreadLocalRandom.current().nextInt(ZombieFriendsConfig.friendDeathMessage.size()))));
}
cancel();
return;
} else {
if (ThreadLocalRandom.current().nextDouble() < 0.5) {
nameClearer(event.getEliteMobEntity());
event.getEliteMobEntity().getLivingEntity().setCustomName(ChatColorConverter.convert(ZombieFriendsConfig.originalEntityDialog.get(ThreadLocalRandom.current().nextInt(ZombieFriendsConfig.originalEntityDialog.size()))));
}
if (ThreadLocalRandom.current().nextDouble() < 0.5 && reinforcement1.isValid()) {
nameClearer(reinforcement1);
reinforcement1.getLivingEntity().setCustomName(ChatColorConverter.convert(ZombieFriendsConfig.reinforcementDialog.get(ThreadLocalRandom.current().nextInt(ZombieFriendsConfig.reinforcementDialog.size()))));
}
if (ThreadLocalRandom.current().nextDouble() < 0.5 && reinforcement2.isValid()) {
nameClearer(reinforcement2);
reinforcement2.getLivingEntity().setCustomName(ChatColorConverter.convert(ZombieFriendsConfig.reinforcementDialog.get(ThreadLocalRandom.current().nextInt(ZombieFriendsConfig.reinforcementDialog.size()))));
}
}
}
}.runTaskTimer(MetadataHandler.PLUGIN, 20, 20 * 8);
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class CustomSummonPower method getFinalSpawnLocation.
private Location getFinalSpawnLocation(EliteEntity summoningEntity, Vector spawnLocationOffset) {
Location finalSpawnLocation;
if (summoningEntity instanceof RegionalBossEntity)
finalSpawnLocation = ((RegionalBossEntity) summoningEntity).getSpawnLocation().clone().add(spawnLocationOffset);
else if (summoningEntity == null)
finalSpawnLocation = null;
else
finalSpawnLocation = summoningEntity.getLocation().add(spawnLocationOffset);
if (summoningEntity instanceof CustomBossEntity && ((CustomBossEntity) summoningEntity).getMinidungeon() != null)
if (summoningEntity instanceof RegionalBossEntity)
return ((CustomBossEntity) summoningEntity).getMinidungeon().getRotatedFinalLocation(((RegionalBossEntity) summoningEntity).getSpawnLocation(), spawnLocationOffset);
else
return ((CustomBossEntity) summoningEntity).getMinidungeon().getRotatedFinalLocation((summoningEntity).getLocation(), spawnLocationOffset);
else
return finalSpawnLocation;
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class SummonWolfEnchantment method summonSnoopy.
private static Wolf summonSnoopy(Player player) {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("summonable_wolf.yml");
customBossEntity.setSpawnLocation(player.getLocation());
customBossEntity.setLevel(ElitePlayerInventory.playerInventories.get(player.getUniqueId()).getFullPlayerTier(true));
if (customBossEntity.getLivingEntity().getType() != EntityType.WOLF) {
new WarningMessage("snoopy.yml boss file was not set to a wolf entity type! It must be a wolf for the summon mechanic to work correctly!");
return null;
}
return (Wolf) customBossEntity.getLivingEntity();
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class SummonWolfEnchantment method summonGenericWolf.
private static Wolf summonGenericWolf(Player player) {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("summonable_wolf.yml");
customBossEntity.setSpawnLocation(player.getLocation());
customBossEntity.setLevel(ElitePlayerInventory.playerInventories.get(player.getUniqueId()).getFullPlayerTier(true));
customBossEntity.spawn(false);
if (customBossEntity.getCustomBossesConfigFields().getEntityType() != EntityType.WOLF) {
new WarningMessage("snoopy.yml boss file was not set to a wolf entity type! It must be a wolf for the summon mechanic to work correctly!");
return null;
}
return (Wolf) customBossEntity.getLivingEntity();
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class ActionEvent method instantiateEvent.
public void instantiateEvent(Location location, Player player) {
this.player = player;
ActionEvent actionEvent = new ActionEvent(customEventsConfigFields);
actionEvent.setEventStartLocation(location);
CustomEventStartEvent customEventStartEvent = new CustomEventStartEvent(actionEvent);
if (customEventStartEvent.isCancelled())
return;
if (!actionEvent.startConditions.areValid())
return;
for (String filename : primaryCustomBossFilenames) {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity(filename);
if (customBossEntity == null) {
new WarningMessage("Failed to generate custom boss " + filename + " ! This has cancelled action event " + customEventsConfigFields.getFilename() + " !");
return;
}
customBossEntity.spawn(actionEvent.getEventStartLocation(), false);
actionEvent.primaryEliteMobs.add(customBossEntity);
}
actionEvent.start();
}
Aggregations