Search in sources :

Example 1 with NPCEntity

use of com.magmaguy.elitemobs.npcs.NPCEntity in project EliteMobs by MagmaGuy.

the class NPCCommands method set.

public static void set(Player player, String npcFileName) {
    NPCsConfigFields npCsConfigFields = NPCsConfig.getNpcEntities().get(npcFileName);
    if (npCsConfigFields == null) {
        player.sendMessage("[EliteMobs] Invalid NPC filename.");
        return;
    }
    Location playerLocation = player.getLocation();
    String location = playerLocation.getWorld().getName() + "," + Round.twoDecimalPlaces(playerLocation.getX()) + "," + Round.twoDecimalPlaces(playerLocation.getY()) + "," + Round.twoDecimalPlaces(playerLocation.getZ()) + "," + Round.twoDecimalPlaces(playerLocation.getYaw()) + "," + Round.twoDecimalPlaces(playerLocation.getPitch());
    try {
        for (NPCEntity npcEntity : EntityTracker.getNpcEntities().values()) if (npcEntity.npCsConfigFields.equals(npCsConfigFields))
            npcEntity.remove(RemovalReason.REMOVE_COMMAND);
    } catch (Exception ex) {
    }
    npCsConfigFields.setEnabled(true);
    npCsConfigFields.setLocation(location);
    new NPCEntity(npCsConfigFields);
}
Also used : NPCsConfigFields(com.magmaguy.elitemobs.config.npcs.NPCsConfigFields) NPCEntity(com.magmaguy.elitemobs.npcs.NPCEntity) Location(org.bukkit.Location)

Example 2 with NPCEntity

use of com.magmaguy.elitemobs.npcs.NPCEntity in project EliteMobs by MagmaGuy.

the class EntityTracker method unregisterNPCEntity.

public static void unregisterNPCEntity(Entity entity, RemovalReason removalReason) {
    NPCEntity npcEntity = getNPCEntity(entity);
    if (npcEntity == null)
        return;
    // Removal from the hashmap is not guaranteed here as some forms of removal don't completely wipe the elite entity out
    npcEntity.remove(removalReason);
}
Also used : NPCEntity(com.magmaguy.elitemobs.npcs.NPCEntity)

Example 3 with NPCEntity

use of com.magmaguy.elitemobs.npcs.NPCEntity in project EliteMobs by MagmaGuy.

the class EntityTracker method wipeShutdown.

public static void wipeShutdown() {
    for (EliteEntity eliteEntity : ((HashMap<UUID, EliteEntity>) eliteMobEntities.clone()).values()) eliteEntity.remove(RemovalReason.SHUTDOWN);
    getEliteMobEntities().clear();
    for (NPCEntity npcEntity : ((HashMap<UUID, NPCEntity>) npcEntities.clone()).values()) npcEntity.remove(RemovalReason.SHUTDOWN);
    getNpcEntities().clear();
    for (Block block : temporaryBlocks) block.setType(Material.AIR);
    temporaryBlocks.clear();
    // Necessary for things such as visual effects which are not stored in memory, only tagged
    for (World world : Bukkit.getWorlds()) for (Entity entity : world.getEntities()) unregister(entity, RemovalReason.SHUTDOWN);
    SimplePersistentEntity.getPersistentEntities().clear();
    CustomBossEntity.getTrackableCustomBosses().clear();
    CrashFix.knownSessionChunks.clear();
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) SimplePersistentEntity(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity) NPCEntity(com.magmaguy.elitemobs.npcs.NPCEntity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) NPCEntity(com.magmaguy.elitemobs.npcs.NPCEntity) Block(org.bukkit.block.Block) World(org.bukkit.World)

Aggregations

NPCEntity (com.magmaguy.elitemobs.npcs.NPCEntity)3 NPCsConfigFields (com.magmaguy.elitemobs.config.npcs.NPCsConfigFields)1 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)1 SimplePersistentEntity (com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity)1 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1 Block (org.bukkit.block.Block)1 Entity (org.bukkit.entity.Entity)1 LivingEntity (org.bukkit.entity.LivingEntity)1