Java Code Examples for org.bukkit.entity.ArmorStand#setVisible()

The following examples show how to use org.bukkit.entity.ArmorStand#setVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArmorStandFactory.java    From CS-CoreLib with GNU General Public License v3.0 6 votes vote down vote up
public static ArmorStand createSmall(Location l, ItemStack item, EulerAngle arm, float yaw) {
	l.setYaw(yaw);
	ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
	armorStand.getEquipment().setItemInMainHand(item);
	armorStand.setVisible(false);
	armorStand.setSilent(true);
	armorStand.setMarker(true);
	armorStand.setGravity(false);
	armorStand.setSmall(true);
	armorStand.setArms(true);
	armorStand.setRightArmPose(arm);
	armorStand.setBasePlate(false);
	armorStand.setRemoveWhenFarAway(false);
	
	return armorStand;
}
 
Example 2
Source File: MainListener.java    From ArmorStandTools with MIT License 6 votes vote down vote up
private ArmorStand spawnArmorStand(Location l) {
    ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
    as.setHelmet(Config.helmet);
    as.setChestplate(Config.chest);
    as.setLeggings(Config.pants);
    as.setBoots(Config.boots);
    as.getEquipment().setItemInMainHand(Config.itemInHand);
    as.getEquipment().setItemInOffHand(Config.itemInOffHand);
    as.setVisible(Config.isVisible);
    as.setSmall(Config.isSmall);
    as.setArms(Config.hasArms);
    as.setBasePlate(Config.hasBasePlate);
    as.setGravity(Config.hasGravity);
    as.setInvulnerable(Config.invulnerable);
    if(Config.defaultName.length() > 0) {
        as.setCustomName(Config.defaultName);
        as.setCustomNameVisible(true);
    }
    Main.nms.setSlotsDisabled(as, Config.equipmentLock);
    return as;
}
 
Example 3
Source File: Holograms.java    From HubBasics with GNU Lesser General Public License v3.0 6 votes vote down vote up
private JSONArray spawnLines(Location loc, String[] lines) {
    int lineIndex = 0;
    JSONArray array = new JSONArray();

    for (String str : lines) {
        ArmorStand armorStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
        armorStand.setGravity(false);
        armorStand.setVisible(false);
        armorStand.setCustomName(ChatColor.translateAlternateColorCodes('&', str));
        armorStand.setCustomNameVisible(true);
        armorStand.setRemoveWhenFarAway(false);
        loc.setY(loc.getY() - 0.25);

        JSONObject object = new JSONObject();
        object.put(ARMORSTAND_LINE, lineIndex);
        object.put(ARMORSTAND_TEXT, str);
        object.put(ARMORSTAND_UUID, armorStand.getUniqueId().toString());
        array.put(lineIndex, object);
        lineIndex++;
    }

    return array;
}
 
Example 4
Source File: TimebombListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
private void spawnChest(){
    spawned = true;

    block1 = loc.getBlock();
    loc.add(-1, 0, 0);
    block2 = loc.getBlock();

    block1.setType(Material.CHEST);
    block2.setType(Material.CHEST);

    Chest chest1 = (Chest) block1.getState();
    Chest chest2 = (Chest) block2.getState();

    String chestName = Lang.SCENARIO_TIMEBOMB_CHEST.replace("%player%", name);
    VersionUtils.getVersionUtils().setChestName(chest1, chestName);
    VersionUtils.getVersionUtils().setChestName(chest2, chestName);

    // Make double chest for 1.13 and up
    VersionUtils.getVersionUtils().setChestSide(chest1, false);
    VersionUtils.getVersionUtils().setChestSide(chest2, true);

    Inventory inv = chest1.getInventory();

    for (ItemStack drop : drops){
        inv.addItem(drop);
    }

    loc.add(1,-1,.5);

    armorStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
    armorStand.setCustomNameVisible(true);
    armorStand.setGravity(false);
    armorStand.setVisible(false);
    armorStand.setCustomName("");
}
 
Example 5
Source File: AreaTarget.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public Set<?> getTargets() {
    int level = getLevel();
    Spell spell = getSpell();
    Set<LivingEntity> returnSet = new HashSet<>();
    if (!(getOrigin() instanceof LivingEntity)) {
        return returnSet;
    }
    LivingEntity player = (LivingEntity) getOrigin();
    ConfigurationSection config = getConfig();
    int range = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("range","15"), level, null, spell));
    int radius = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("radius", "5"), level, null, spell));
    int maxTargets = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("max-targets", "-1"), level, null, spell));
    Collection<Entity> nearbyEntities;
    if (range < 1) {
        nearbyEntities = player.getNearbyEntities(radius, radius, radius);
    } else {
        HashSet<Material> materialHashSet = new HashSet<>();
        Location center = player.getTargetBlock(materialHashSet, range).getLocation();
        center = applyTargetSettings(center);
        ArmorStand removeMe = (ArmorStand) center.getWorld().spawnEntity(center, EntityType.ARMOR_STAND);
        removeMe.setVisible(false);
        nearbyEntities = removeMe.getNearbyEntities(radius, radius, radius);
        removeMe.remove();
    }

    for (Entity target : nearbyEntities) {
        if (maxTargets > 0 && returnSet.size() >= maxTargets) {
            break;
        }

        if (target != player &&
                target instanceof LivingEntity) {

            returnSet.add((LivingEntity) target);
        }
    }
    return returnSet;
}
 
Example 6
Source File: ArmorStandFactory.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
public static ArmorStand createHidden(Location l) {
	ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
	armorStand.setVisible(false);
	armorStand.setSilent(true);
	armorStand.setMarker(true);
	armorStand.setGravity(false);
	armorStand.setBasePlate(false);
	armorStand.setCustomNameVisible(true);
	armorStand.setRemoveWhenFarAway(false);
	
	return armorStand;
}
 
Example 7
Source File: ArmorStandFactory.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
public static ArmorStand createSmall(Location l, ItemStack head, float yaw) {
	l.setYaw(yaw);
	ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
	armorStand.getEquipment().setHelmet(head);
	armorStand.setVisible(false);
	armorStand.setSilent(true);
	armorStand.setMarker(true);
	armorStand.setGravity(false);
	armorStand.setSmall(true);
	armorStand.setBasePlate(false);
	armorStand.setRemoveWhenFarAway(false);
	
	return armorStand;
}
 
Example 8
Source File: SimpleHologram.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public static ArmorStand create(Location l) {
    ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
    armorStand.setVisible(false);
    armorStand.setSilent(true);
    armorStand.setMarker(true);
    armorStand.setGravity(false);
    armorStand.setBasePlate(false);
    armorStand.setCustomNameVisible(true);
    armorStand.setRemoveWhenFarAway(false);
    return armorStand;
}
 
Example 9
Source File: FlagObjective.java    From CardinalPGM with MIT License 5 votes vote down vote up
private ArmorStand createArmorStand() {
    Location loc = getCurrentFlagLocation().add(0,0.6875,0);
    ArmorStand armorStand = GameHandler.getGameHandler().getMatchWorld().spawn(loc, ArmorStand.class);
    armorStand.setGravity(false);
    armorStand.setVisible(false);
    armorStand.setSmall(true);
    armorStand.setBasePlate(false);
    armorStand.setCustomNameVisible(true);
    armorStand.setCustomName(getDisplayName());
    return armorStand;
}
 
Example 10
Source File: DamageDisplay.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
public static void displayDamage(Entity entity, double damage) {

        if (!ConfigValues.mobCombatSettingsConfig.getBoolean(MobCombatSettingsConfig.DISPLAY_DAMAGE_ON_HIT)) return;

        Location entityLocation = entity.getLocation();

        Random random = new Random();
        double randomCoordX = (random.nextDouble() * 2) - 1 + entityLocation.getX();
        double randomCoordZ = (random.nextDouble() * 2) - 1 + entityLocation.getZ();

        Location newLocation = new Location(entityLocation.getWorld(), randomCoordX, entityLocation.getY() + 1.7, randomCoordZ);

         /*
        Dirty fix: armorstands don't render invisibly on their first tick, so it gets moved elsewhere temporarily
         */
        ArmorStand armorStand = (ArmorStand) newLocation.getWorld().spawnEntity(newLocation.add(new Vector(0, -50, 0)), EntityType.ARMOR_STAND);

        armorStand.setVisible(false);
        armorStand.setMarker(true);
        int newDisplayDamage = (int) damage;
        armorStand.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "" + newDisplayDamage + "");
        armorStand.setGravity(false);
        EntityTracker.registerArmorStands(armorStand);
        armorStand.setCustomNameVisible(false);

        new BukkitRunnable() {

            int taskTimer = 0;

            @Override
            public void run() {

                if (taskTimer == 0) {
                    armorStand.teleport(new Location(armorStand.getWorld(), armorStand.getLocation().getX(),
                            armorStand.getLocation().getY() + 50, armorStand.getLocation().getZ()));
                } else
                    armorStand.teleport(new Location(armorStand.getWorld(), armorStand.getLocation().getX(),
                            armorStand.getLocation().getY() + 0.1, armorStand.getLocation().getZ()));

                if (taskTimer == 1)
                    armorStand.setCustomNameVisible(true);

                taskTimer++;

                if (taskTimer > 15) {

                    EntityTracker.unregisterArmorStand(armorStand);
                    cancel();

                }

            }

        }.runTaskTimer(Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS), 0, 1);

    }
 
Example 11
Source File: NPCChatBubble.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
public NPCChatBubble(String message, NPCEntity npcEntity, Player player) {

        if (npcEntity.getVillager().hasPotionEffect(PotionEffectType.INVISIBILITY)) return;
        if (npcEntity.getIsTalking()) return;
        npcEntity.startTalkingCooldown();

        int lineCounter = 0;

        for (String substring : message.split("\\\\n")) {

            Location newLocation = npcEntity.getVillager().getEyeLocation().clone()
                    .add(player.getLocation().clone().subtract(npcEntity.getVillager().getLocation()).toVector().normalize().multiply(0.5))
                    .add(new Vector(0, -50 - (0.2 * lineCounter), 0));

            ArmorStand messageBubble = (ArmorStand) newLocation.getWorld().spawnEntity(newLocation, EntityType.ARMOR_STAND);
            EntityTracker.registerArmorStands(messageBubble);
            messageBubble.setVisible(false);
            messageBubble.setMarker(true);
            messageBubble.setCustomName(ChatColorConverter.convert(substring));
            messageBubble.setCustomNameVisible(true);
            messageBubble.setGravity(false);

            new BukkitRunnable() {
                int counter = 0;

                @Override
                public void run() {
                    if (counter > 20 * 3) {
                        messageBubble.remove();
                        cancel();
                        return;
                    }

                    if (counter == 1)
                        messageBubble.teleport(messageBubble.getLocation().add(new Vector(0, 49.2, 0)));

                    if (counter > 1)
                        messageBubble.teleport(messageBubble.getLocation().clone().add(new Vector(0, 0.01, 0)));

                    counter++;
                }
            }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);

            lineCounter++;

        }

    }
 
Example 12
Source File: HealthDisplay.java    From EliteMobs with GNU General Public License v3.0 2 votes vote down vote up
public static void displayHealth(LivingEntity livingEntity, double damage) {

        if (!ConfigValues.mobCombatSettingsConfig.getBoolean(MobCombatSettingsConfig.DISPLAY_HEALTH_ON_HIT)) return;

        int maxHealth = (int) livingEntity.getMaxHealth();
        int currentHealth = (int) (livingEntity.getHealth() - damage);

        Location entityLocation = new Location(livingEntity.getWorld(), livingEntity.getLocation().getX(),
                livingEntity.getLocation().getY() + livingEntity.getEyeHeight() + 0.5, livingEntity.getLocation().getZ());

        /*
        Dirty fix: armorstands don't render invisibly on their first tick, so it gets moved elsewhere temporarily
         */
        ArmorStand armorStand = (ArmorStand) entityLocation.getWorld().spawnEntity(entityLocation.add(new Vector(0, -50, 0)), EntityType.ARMOR_STAND);

        armorStand.setVisible(false);
        armorStand.setMarker(true);
        armorStand.setCustomName(setHealthColor(currentHealth, maxHealth) + "" + currentHealth + "/" + maxHealth);
        armorStand.setGravity(false);
        EntityTracker.registerArmorStands(armorStand);
        armorStand.setCustomNameVisible(false);


        new BukkitRunnable() {

            int taskTimer = 0;

            @Override
            public void run() {

                Location newLocation = new Location(livingEntity.getWorld(), livingEntity.getLocation().getX(),
                        livingEntity.getLocation().getY() + livingEntity.getEyeHeight() + 0.5, livingEntity.getLocation().getZ());

                armorStand.teleport(newLocation);

                if (taskTimer == 1)
                    armorStand.setCustomNameVisible(true);

                taskTimer++;

                if (taskTimer > 15) {

                    EntityTracker.unregisterArmorStand(armorStand);
                    cancel();

                }

            }

        }.runTaskTimer(Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS), 0, 1L);

    }