Search in sources :

Example 6 with CustomBossEntity

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);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Example 7 with CustomBossEntity

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;
}
Also used : CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity) Location(org.bukkit.Location)

Example 8 with CustomBossEntity

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();
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Wolf(org.bukkit.entity.Wolf) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 9 with CustomBossEntity

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();
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Wolf(org.bukkit.entity.Wolf) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 10 with CustomBossEntity

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();
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) CustomEventStartEvent(com.magmaguy.elitemobs.api.CustomEventStartEvent)

Aggregations

CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)22 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)9 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)5 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)5 Location (org.bukkit.Location)5 EventHandler (org.bukkit.event.EventHandler)5 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)5 Vector (org.bukkit.util.Vector)5 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)3 ArrayList (java.util.ArrayList)3 Entity (org.bukkit.entity.Entity)3 LivingEntity (org.bukkit.entity.LivingEntity)3 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Player (org.bukkit.entity.Player)2 Wolf (org.bukkit.entity.Wolf)2 PotionEffect (org.bukkit.potion.PotionEffect)2