org.bukkit.entity.ArmorStand

Here are the examples of the java api org.bukkit.entity.ArmorStand taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

96 Examples 7

19 Source : MobMetadataUtils.java
with Apache License 2.0
from Wauzmons

/**
 * Sets the tier of a strongobx, used to determine loot contents.
 *
 * @param strongbox The strongbox mob that receives the metadata.
 * @param strongboxTier The tier of the strongbox.
 */
public static void setStrongboxTier(ArmorStand strongbox, int strongboxTier) {
    addMetadata(strongbox, STRONGBOX_TIER, strongboxTier);
}

19 Source : MobMetadataUtils.java
with Apache License 2.0
from Wauzmons

/**
 * Gets the tier of a strongobx, used to determine loot contents.
 *
 * @param strongbox The strongbox mob that gets its metadata checked.
 *
 * @return The tier of the strongobx.
 */
public static int getStrongboxTier(ArmorStand strongbox) {
    return getMetadata(strongbox, STRONGBOX_TIER).asInt();
}

19 Source : ChairManager.java
with MIT License
from SpraxDev

/**
 * This does not yet guarantee that {@link #getChair(ArmorStand)} is not {@code null}<br>
 * This may return true for ArmorStand not yet spawned and thus not yet a {@link Chair} that is ready
 *
 * @param armorStand The {@link ArmorStand} to check
 *
 * @return true if the {@link ArmorStand} is used or may be used as {@link Chair}
 */
public boolean isChair(@NotNull ArmorStand armorStand) {
    return getChair(armorStand) != null || chairNMS.isChair(armorStand);
}

19 Source : Stand.java
with GNU General Public License v3.0
from Plugily-Projects

/**
 * @author Plajer
 * <p>
 * Created at 07.08.2018
 */
public clreplaced Stand {

    private final ArmorStandHologram hologram;

    private final ArmorStand stand;

    public Stand(ArmorStandHologram hologram, ArmorStand stand) {
        this.hologram = hologram;
        this.stand = stand;
    }

    public ArmorStandHologram getHologram() {
        return hologram;
    }

    public ArmorStand getStand() {
        return stand;
    }
}

19 Source : ChunksListener.java
with GNU General Public License v3.0
from OmerBenGera

private static boolean isHologram(ArmorStand armorStand) {
    return !armorStand.hasGravity() && armorStand.isSmall() && !armorStand.isVisible() && armorStand.isCustomNameVisible() && armorStand.isMarker() && armorStand.getCustomName() != null;
}

19 Source : ArmorStandEntityTracker.java
with GNU General Public License v3.0
from MagmaGuy

public clreplaced ArmorStandEnreplacedyTracker extends TrackedEnreplacedy implements AbstractTrackedEnreplacedy {

    public static HashMap<UUID, ArmorStand> armorStands = new HashMap<>();

    public UUID uuid;

    public ArmorStand armorStand;

    public ArmorStandEnreplacedyTracker(UUID uuid, ArmorStand armorStand) {
        super(uuid, armorStand, true, true, armorStands);
        this.uuid = uuid;
        this.armorStand = armorStand;
        armorStands.put(uuid, armorStand);
        armorStand.setMetadata(MetadataHandler.ARMOR_STAND, new FixedMetadataValue(MetadataHandler.PLUGIN, true));
    }

    @Override
    public void specificRemoveHandling(RemovalReason removalReason) {
        if (armorStand != null)
            armorStand.removeMetadata(MetadataHandler.ARMOR_STAND, MetadataHandler.PLUGIN);
    }
}

19 Source : BazaarManager.java
with GNU General Public License v3.0
from Lix3nn53

public static void clearBazaarToPlayer(ArmorStand armorStand) {
    bazaarToPlayer.remove(armorStand);
}

18 Source : THologramHandler.java
with MIT License
from TabooLib

/**
 * 全息逻辑处理类
 *
 * @author sky
 * @since 2020-03-07 14:23
 */
@TListener
clreplaced THologramHandler implements Listener {

    private static ArmorStand learnTarget = null;

    private static Packet packetInit = null;

    private static Packet packetSpawn = null;

    private static Packet packetName = null;

    private static THologramSchedule currentSchedule = null;

    private static final Queue<THologramSchedule> queueSchedule = Queues.newArrayDeque();

    private static boolean learned = false;

    @TPacket(type = TPacket.Type.RECEIVE)
    static boolean d(Player player, Packet packet) {
        if (packet.is("PacketPlayInPosition") && !learned) {
            learned = true;
            TabooLib.getPlugin().runTask(() -> learn(player));
        }
        if (packet.is("PacketPlayInUseEnreplacedy")) {
            int id = packet.read("a", Integer.TYPE);
            for (Hologram hologram : THologram.getHolograms()) {
                HologramViewer viewer = hologram.getViewer(player);
                if (viewer != null && viewer.getId() == id) {
                    hologram.getEvent().accept(player);
                }
            }
        }
        return true;
    }

    @TPacket(type = TPacket.Type.SEND)
    static boolean e(Player player, Packet packet) {
        if (learnTarget == null) {
            return true;
        }
        if (packet.is("PacketPlayOutSpawnEnreplacedyLiving") && packet.read("a", 0) == learnTarget.getEnreplacedyId()) {
            packetSpawn = packet;
            return false;
        }
        if (packet.is("PacketPlayOutEnreplacedyMetadata") && packet.read("a", 0) == learnTarget.getEnreplacedyId()) {
            if (currentSchedule != null) {
                currentSchedule.after(packet);
            } else {
                packetInit = packet;
            }
            return false;
        }
        return true;
    }

    /**
     * 是否学习完成。
     * 指 TabooLib 会在首位玩家进入服务器时学习服务端向玩家发送的 ArmorStand 数据包,并在之后借助该数据包结构伪向玩家发送造虚假的 ArmorStand 实体。
     */
    public static boolean isLearned() {
        return packetInit != null && packetSpawn != null && packetName != null;
    }

    /**
     * 克隆一个 ArmorStand 生成数据包
     *
     * @param id       序号
     * @param location 新的实体坐标
     * @return 数据包对象
     */
    public static Packet copy(int id, Location location) {
        Packet packet = THologramHandler.getPacketSpawn().copy(NMS.handle().asNMS("PacketPlayOutSpawnEnreplacedyLiving"), "c", "g", "h", "i", "j", "k", "l");
        packet.write("a", id);
        packet.write("b", UUID.randomUUID());
        packet.write("d", location.getX());
        packet.write("e", location.getY());
        packet.write("f", location.getZ());
        if (Version.isBefore(Version.v1_15)) {
            packet.write("m", THologramHandler.getPacketSpawn().read("m"));
        }
        return packet;
    }

    public static Packet copy(int id) {
        Packet packet = THologramHandler.getPacketInit().copy("b");
        packet.write("a", id);
        return packet;
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static Packet copy(int id, String name) {
        Packet packet = THologramHandler.getPacketName().copy();
        packet.write("a", id);
        List copy = Lists.newArrayList();
        List item = THologramHandler.getPacketName().read("b", List.clreplaced);
        for (Object element : item) {
            SimpleReflection.checkAndSave(element.getClreplaced());
            if (Version.isAfter(Version.v1_9)) {
                Object a = SimpleReflection.getFieldValue(element.getClreplaced(), element, "a");
                Object c = SimpleReflection.getFieldValue(element.getClreplaced(), element, "c");
                try {
                    Object i = Ref.getUnsafe().allocateInstance(element.getClreplaced());
                    SimpleReflection.setFieldValue(element.getClreplaced(), i, "a", a);
                    SimpleReflection.setFieldValue(element.getClreplaced(), i, "c", c);
                    if (Version.isAfter(Version.v1_14)) {
                        SimpleReflection.setFieldValue(element.getClreplaced(), i, "b", Optional.of(NMS.handle().ofChatComponentText(name)));
                    } else {
                        SimpleReflection.setFieldValue(element.getClreplaced(), i, "b", name);
                    }
                    copy.add(i);
                } catch (InstantiationException e) {
                    e.printStackTrace();
                }
            } else {
                Object a = SimpleReflection.getFieldValue(element.getClreplaced(), element, "a");
                Object b = SimpleReflection.getFieldValue(element.getClreplaced(), element, "b");
                Object d = SimpleReflection.getFieldValue(element.getClreplaced(), element, "d");
                try {
                    Object i = Ref.getUnsafe().allocateInstance(element.getClreplaced());
                    SimpleReflection.setFieldValue(element.getClreplaced(), i, "a", a);
                    SimpleReflection.setFieldValue(element.getClreplaced(), i, "b", b);
                    SimpleReflection.setFieldValue(element.getClreplaced(), i, "c", name);
                    SimpleReflection.setFieldValue(element.getClreplaced(), i, "d", d);
                    copy.add(i);
                } catch (InstantiationException e) {
                    e.printStackTrace();
                }
            }
        }
        packet.write("b", copy);
        return packet;
    }

    /**
     * 重置数据包结构
     */
    public static void reset() {
        queueSchedule.clear();
        queueSchedule.offer(new THologramSchedule(() -> packetInit != null) {

            @Override
            public void before() {
                learnTarget.setCustomName("  ");
            }

            @Override
            public void after(Packet packet) {
                packetName = packet;
            }
        });
    }

    /**
     * 学习服务端即将向该玩家发送的 ArmorStand 数据包结构。
     *
     * @param player 玩家
     */
    public static void learn(Player player) {
        NMS.handle().spawn(player.getLocation(), ArmorStand.clreplaced, c -> {
            learnTarget = c;
            learnTarget.setMarker(true);
            learnTarget.setVisible(false);
            learnTarget.setCustomName(" ");
            learnTarget.setCustomNameVisible(true);
            learnTarget.setBasePlate(false);
        });
        reset();
        new BukkitRunnable() {

            @Override
            public void run() {
                THologramSchedule schedule = queueSchedule.peek();
                if (schedule == null) {
                    cancel();
                    learnTarget.remove();
                } else if (schedule.check()) {
                    currentSchedule = queueSchedule.poll();
                    if (currentSchedule != null) {
                        currentSchedule.before();
                    }
                }
            }
        }.runTaskTimer(TabooLib.getPlugin(), 1, 1);
    }

    @EventHandler
    public void e(PlayerJoinEvent e) {
        THologram.refresh(e.getPlayer());
    }

    @EventHandler
    public void e(PlayerQuitEvent e) {
        THologram.remove(e.getPlayer());
    }

    @EventHandler
    public void e(PlayerTeleportEvent e) {
        THologram.refresh(e.getPlayer());
    }

    @EventHandler
    public void e(PlayerChangedWorldEvent e) {
        THologram.refresh(e.getPlayer());
    }

    @TSchedule(period = 200, async = true)
    public void e() {
        Bukkit.getOnlinePlayers().forEach(THologram::refresh);
    }

    public static ArmorStand getLearnTarget() {
        return learnTarget;
    }

    public static Packet getPacketSpawn() {
        return packetSpawn;
    }

    public static Packet getPacketInit() {
        return packetInit;
    }

    public static Packet getPacketName() {
        return packetName;
    }
}

18 Source : v1_9_R2.java
with MIT License
from SpraxDev

@Override
public boolean isChair(@NotNull ArmorStand armorStand) {
    return ((CraftArmorStand) armorStand).getHandle() instanceof CustomArmorStand;
}

18 Source : ChairManager.java
with MIT License
from SpraxDev

@Nullable
public Chair getChair(@NotNull ArmorStand armorStand) {
    if (!Bukkit.isPrimaryThread())
        throw new IllegalStateException(Messages.ERR_ASYNC_API_CALL);
    for (Chair c : new ArrayList<>(chairs)) {
        if (armorStand == c.armorStand && !c.destroyOnNoPreplacedenger()) {
            return c;
        }
    }
    return null;
}

18 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testVisible() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    armorStand.setVisible(true);
    replacedertTrue(armorStand.isVisible());
    armorStand.setVisible(false);
    replacedertFalse(armorStand.isVisible());
}

18 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testBasePlate() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    armorStand.setBasePlate(true);
    replacedertTrue(armorStand.hasBasePlate());
    armorStand.setBasePlate(false);
    replacedertFalse(armorStand.hasBasePlate());
}

18 Source : ActivePowerup.java
with GNU General Public License v3.0
from SamaGames

/*
 * This file is part of SamaGamesAPI.
 *
 * SamaGamesAPI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SamaGamesAPI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SamaGamesAPI.  If not, see <http://www.gnu.org/licenses/>.
 */
public clreplaced ActivePowerup implements Listener {

    private final UUID uuid;

    private final Powerup parent;

    private final Location location;

    private Item enreplacedyItem;

    private ArmorStand enreplacedyBase;

    private ArmorStand enreplacedyreplacedle;

    private BukkitTask particlesTask;

    private boolean alive;

    public ActivePowerup(Powerup parent, Location location) {
        this.uuid = UUID.randomUUID();
        this.parent = parent;
        this.location = location;
        this.spawn();
    }

    public void remove(boolean got) {
        this.enreplacedyreplacedle.remove();
        this.enreplacedyItem.remove();
        this.enreplacedyBase.remove();
        Color fwColor = got ? Color.BLUE : Color.RED;
        Firework fw = this.location.getWorld().spawn(this.location.clone().add(0.5, 1, 0.5), Firework.clreplaced);
        FireworkMeta fwm = fw.getFireworkMeta();
        FireworkEffect effect = FireworkEffect.builder().withColor(fwColor).with(this.parent.isSpecial() ? FireworkEffect.Type.STAR : FireworkEffect.Type.BALL).build();
        fwm.addEffects(effect);
        fwm.setPower(0);
        fw.setFireworkMeta(fwm);
        Bukkit.getScheduler().runTaskLater(SamaGamesAPI.get().getPlugin(), fw::detonate, 1L);
        this.particlesTask.cancel();
        this.alive = false;
    }

    private void spawn() {
        World world = this.location.getWorld();
        ItemStack powerupItem = this.parent.getIcon().clone();
        ItemMeta powerupItemMeta = powerupItem.gereplacedemMeta();
        powerupItemMeta.setDisplayName(this.uuid.toString());
        powerupItem.sereplacedemMeta(powerupItemMeta);
        this.enreplacedyBase = world.spawn(this.location.clone().add(0, -0.5, 0), ArmorStand.clreplaced);
        this.enreplacedyBase.setVisible(false);
        this.enreplacedyBase.setSmall(true);
        this.enreplacedyBase.setGravity(false);
        this.enreplacedyItem = world.dropItem(this.location, powerupItem);
        this.enreplacedyItem.setPickupDelay(0);
        this.enreplacedyreplacedle = world.spawn(this.location, ArmorStand.clreplaced);
        this.enreplacedyreplacedle.setGravity(false);
        this.enreplacedyreplacedle.setVisible(false);
        this.enreplacedyreplacedle.setSmall(true);
        this.enreplacedyreplacedle.setCustomName(this.parent.getName());
        this.enreplacedyreplacedle.setCustomNameVisible(true);
        this.enreplacedyreplacedle.setCanPickupItems(false);
        this.enreplacedyBase.setPreplacedenger(this.enreplacedyItem);
        this.enreplacedyItem.setPreplacedenger(this.enreplacedyreplacedle);
        this.particlesTask = Bukkit.getScheduler().runTaskTimerAsynchronously(SamaGamesAPI.get().getPlugin(), () -> ParticleEffect.SPELL_INSTANT.display(0.5F, 0.5F, 0.5F, 0.1F, 2, this.location, 100.0), 1L, 5L);
        this.alive = true;
        Bukkit.getPluginManager().registerEvents(this, SamaGamesAPI.get().getPlugin());
    }

    @EventHandler
    private void onPlayerPickupItem(PlayerPickupItemEvent event) {
        if (event.gereplacedem().gereplacedemStack() != null && event.gereplacedem().gereplacedemStack().gereplacedemMeta() != null && event.gereplacedem().gereplacedemStack().gereplacedemMeta().getDisplayName() != null) {
            if (this.alive && event.gereplacedem().gereplacedemStack().gereplacedemMeta().getDisplayName().equals(this.uuid.toString())) {
                event.setCancelled(true);
                HandlerList.unregisterAll(this);
                this.remove(true);
                this.parent.onPickup(event.getPlayer());
            }
        }
    }

    public boolean isAlive() {
        return this.alive;
    }
}

18 Source : Hologram.java
with MIT License
from Redempt

/**
 * Inserts a line in this Hologram
 * @param line The position to insert at
 * @param text The text to insert
 */
public void insert(int line, String text) {
    ArmorStand stand = spawn(line, text);
    stands.add(line, EnreplacedyPersistor.wrap(stand));
    fixStands();
}

18 Source : ModelPiece.java
with GNU General Public License v2.0
from PatoTheBest

public clreplaced ModelPiece {

    private final ArmorStand armorStand;

    private final AbstractModel abstractModel;

    private final Vector offset;

    private final ItemStack blockType;

    public ModelPiece(AbstractModel abstractModel, Vector offset, ItemStack blockType) {
        this.abstractModel = abstractModel;
        this.offset = offset.multiply(0.6);
        this.blockType = blockType;
        armorStand = (ArmorStand) abstractModel.originLocation.getWorld().spawnEnreplacedy(abstractModel.getLocation(), EnreplacedyType.ARMOR_STAND);
        armorStand.setGravity(false);
        armorStand.setVisible(false);
        // armorStand.setInvulnerable(true);
        armorStand.setHelmet(blockType);
        Utils.setAiEnabled(armorStand, false);
        updateLocation();
    }

    public void updateLocation() {
        Location location = abstractModel.getLocation();
        Vector tmpOffset = offset.clone();
        Utils.rotateX(tmpOffset, Math.toRadians(-location.getPitch()));
        Utils.rotateY(tmpOffset, Math.toRadians(-location.getYaw()));
        location.add(tmpOffset).add(0, -0.75, 0);
        armorStand.setHeadPose(new EulerAngle(Math.toRadians(abstractModel.getLocation().getPitch()), 0, 0));
        abstractModel.nms.setPositionAndRotation(armorStand, location.getX(), location.getY(), location.getZ(), location.getYaw(), 0);
    }

    public void destroy() {
        armorStand.remove();
    }
}

18 Source : CharacterSelectionScreenManager.java
with GNU General Public License v3.0
from Lix3nn53

private static void removeHolograms() {
    for (int charNo = 1; charNo <= 8; charNo++) {
        if (characterNoToArmorStands.containsKey(charNo)) {
            List<ArmorStand> armorStands = characterNoToArmorStands.get(charNo);
            for (ArmorStand armorStand : armorStands) {
                armorStand.remove();
            }
            characterNoToArmorStands.remove(charNo);
        }
    }
}

18 Source : Portal.java
with GNU General Public License v3.0
from Lix3nn53

public clreplaced Portal {

    private final Location baseLocation;

    private final PortalColor portalColor;

    private final String replacedle;

    private ArmorStand armorStand;

    public Portal(Location baseLocation, PortalColor portalColor, String replacedle) {
        this.baseLocation = baseLocation;
        this.portalColor = portalColor;
        this.replacedle = replacedle;
    }

    public void createModel() {
        double x = Math.toRadians(baseLocation.getPitch());
        double y = Math.toRadians(baseLocation.getYaw());
        EulerAngle eulerAngle = new EulerAngle(x, y, 0);
        Location clone = baseLocation.clone();
        clone.setPitch(0);
        clone.setYaw(0);
        this.armorStand = (ArmorStand) clone.getWorld().spawnEnreplacedy(clone, EnreplacedyType.ARMOR_STAND);
        armorStand.setHeadPose(eulerAngle);
        ItemStack itemStack = new ItemStack(Material.WOODEN_SHOVEL);
        ItemMeta itemMeta = itemStack.gereplacedemMeta();
        itemMeta.setCustomModelData(this.portalColor.getCustomModelData());
        itemMeta.setUnbreakable(true);
        itemStack.sereplacedemMeta(itemMeta);
        EnreplacedyEquipment equipment = armorStand.getEquipment();
        equipment.setHelmet(itemStack);
        armorStand.setVisible(false);
        armorStand.setInvulnerable(true);
        armorStand.setGravity(false);
        armorStand.setCustomNameVisible(true);
        String s = ChatColor.translateAlternateColorCodes('&', replacedle);
        armorStand.setCustomName(s);
    }

    public Location getBaseLocation() {
        return baseLocation;
    }

    public ArmorStand getArmorStand() {
        return armorStand;
    }
}

18 Source : Tomb.java
with GNU General Public License v3.0
from Lix3nn53

public clreplaced Tomb {

    private final Player owner;

    private final Location baseLocation;

    private ArmorStand tombModel;

    public Tomb(Player owner, Location deathLocation) {
        this.owner = owner;
        this.baseLocation = deathLocation.clone();
        this.baseLocation.setYaw(0f);
        this.baseLocation.setPitch(0f);
        createModel();
    }

    public void createModel() {
        this.tombModel = (ArmorStand) baseLocation.getWorld().spawnEnreplacedy(baseLocation, EnreplacedyType.ARMOR_STAND);
        ItemStack itemStack = new ItemStack(Material.IRON_PICKAXE);
        ItemMeta itemMeta = itemStack.gereplacedemMeta();
        itemMeta.setCustomModelData(1);
        itemMeta.setUnbreakable(true);
        itemStack.sereplacedemMeta(itemMeta);
        EnreplacedyEquipment equipment = tombModel.getEquipment();
        equipment.setHelmet(itemStack);
        this.tombModel.setVisible(false);
        this.tombModel.setCustomName(ChatColor.DARK_PURPLE + "< Tomb " + ChatColor.LIGHT_PURPLE + owner.getName() + ChatColor.DARK_PURPLE + " >");
        this.tombModel.setCustomNameVisible(true);
        this.tombModel.setInvulnerable(true);
        this.tombModel.setGravity(false);
        this.tombModel.setGlowing(true);
    }

    public void remove() {
        this.tombModel.remove();
        TombManager.onTombRemove(this);
    }

    public boolean isNear() {
        if (owner.getWorld().getName().equals("world")) {
            return owner.getLocation().distanceSquared(baseLocation) < 20;
        }
        return false;
    }

    public Location getBaseLocation() {
        return baseLocation;
    }

    public Player getOwner() {
        return owner;
    }
}

18 Source : QuestNPCManager.java
with GNU General Public License v3.0
from Lix3nn53

public static boolean isQuestIcon(ArmorStand armorStand) {
    for (ArmorStand holo : questHologramArmorStands) {
        if (holo.equals(armorStand))
            return true;
    }
    return false;
}

18 Source : Checkpoint.java
with GNU General Public License v3.0
from Lix3nn53

public clreplaced Checkpoint {

    private final Location location;

    private ArmorStand armorStand;

    public Checkpoint(Location location) {
        this.location = location;
    }

    public void createModel() {
        ArmorStand rider = new Hologram(location).getArmorStand();
        Hologram hologram = new Hologram(location, rider);
        this.armorStand = hologram.getArmorStand();
        ItemStack holoItem = new ItemStack(Material.STONE_PICKAXE);
        ItemMeta itemMeta = holoItem.gereplacedemMeta();
        itemMeta.setCustomModelData(39);
        itemMeta.setUnbreakable(true);
        holoItem.sereplacedemMeta(itemMeta);
        MiscDisguise disguise = new MiscDisguise(DisguiseType.DROPPED_ITEM);
        DroppedItemWatcher watcher = (DroppedItemWatcher) disguise.gereplacedcher();
        watcher.sereplacedemStack(holoItem);
        DisguiseAPI.disguiseToAll(hologram.getArmorStand().getPreplacedengers().get(0), disguise);
    }

    public Location getLocation() {
        return location;
    }

    public ArmorStand getArmorStand() {
        return armorStand;
    }
}

18 Source : GatheringModel.java
with GNU General Public License v3.0
from Lix3nn53

public clreplaced GatheringModel {

    private final Location baseLocation;

    private final int customModelData;

    private final int cooldownCustomModelData;

    private final String replacedle;

    private ArmorStand armorStand;

    private boolean onCooldown = false;

    private boolean beingGathered = false;

    public GatheringModel(Location baseLocation, int customModelData, int cooldownCustomModelData, String replacedle) {
        this.baseLocation = baseLocation;
        this.customModelData = customModelData;
        this.cooldownCustomModelData = cooldownCustomModelData;
        this.replacedle = ChatColor.translateAlternateColorCodes('&', replacedle);
    }

    public void createModel() {
        double x = Math.toRadians(baseLocation.getPitch());
        double y = Math.toRadians(baseLocation.getYaw());
        EulerAngle eulerAngle = new EulerAngle(x, y, 0);
        Location clone = baseLocation.clone();
        clone.setPitch(0);
        clone.setYaw(0);
        this.armorStand = (ArmorStand) clone.getWorld().spawnEnreplacedy(clone, EnreplacedyType.ARMOR_STAND);
        armorStand.setHeadPose(eulerAngle);
        ItemStack itemStack = new ItemStack(GatheringManager.gatheringMaterial);
        ItemMeta itemMeta = itemStack.gereplacedemMeta();
        if (onCooldown) {
            itemMeta.setCustomModelData(this.cooldownCustomModelData);
            armorStand.setCustomName(replacedle + ChatColor.GRAY + " (On Cooldown)");
        } else {
            itemMeta.setCustomModelData(this.customModelData);
            armorStand.setCustomName(replacedle);
        }
        itemMeta.setUnbreakable(true);
        itemStack.sereplacedemMeta(itemMeta);
        EnreplacedyEquipment equipment = armorStand.getEquipment();
        equipment.setHelmet(itemStack);
        armorStand.setVisible(false);
        armorStand.setInvulnerable(true);
        armorStand.setGravity(false);
        armorStand.setCustomNameVisible(true);
        armorStand.setSmall(true);
    }

    public Location getBaseLocation() {
        return baseLocation;
    }

    public ArmorStand getArmorStand() {
        return armorStand;
    }

    public int getCustomModelData() {
        return customModelData;
    }

    public void onLoot() {
        onCooldown = true;
        setBeingGathered(false);
        armorStand.setCustomName(replacedle + ChatColor.GRAY + " (On Cooldown)");
        EnreplacedyEquipment equipment = armorStand.getEquipment();
        ItemStack helmet = equipment.getHelmet();
        ItemMeta itemMeta = helmet.gereplacedemMeta();
        itemMeta.setCustomModelData(this.cooldownCustomModelData);
        helmet.sereplacedemMeta(itemMeta);
        equipment.setHelmet(helmet);
        new BukkitRunnable() {

            @Override
            public void run() {
                onCooldown = false;
                if (baseLocation.getChunk().isLoaded()) {
                    armorStand.setCustomName(replacedle);
                    EnreplacedyEquipment equipment = armorStand.getEquipment();
                    ItemStack helmet = equipment.getHelmet();
                    ItemMeta itemMeta = helmet.gereplacedemMeta();
                    itemMeta.setCustomModelData(customModelData);
                    helmet.sereplacedemMeta(itemMeta);
                    equipment.setHelmet(helmet);
                }
            }
        }.runTaskLater(GuardiansOfAdelia.getInstance(), 20 * 60L);
    }

    public void resetName() {
        armorStand.setCustomName(replacedle);
    }

    public boolean isBeingGathered() {
        return beingGathered;
    }

    public void setBeingGathered(boolean beingGathered) {
        this.beingGathered = beingGathered;
    }

    public boolean isOnCooldown() {
        return onCooldown;
    }
}

18 Source : BazaarManager.java
with GNU General Public License v3.0
from Lix3nn53

public static boolean isBazaar(ArmorStand enreplacedy) {
    return bazaarToPlayer.containsKey(enreplacedy);
}

17 Source : MobMetadataUtils.java
with Apache License 2.0
from Wauzmons

/**
 * Sets the uuid of the strongbox, the given mob belongs to.
 *
 * @param mob The mob that receives the metadata.
 * @param strongbox The strongbox mob to which the mob belongs.
 */
public static void setStrongboxMob(Enreplacedy mob, ArmorStand strongbox) {
    addMetadata(mob, STRONGBOX_MOB_UUID, strongbox.getUniqueId().toString());
}

17 Source : v1_9_R2.java
with MIT License
from SpraxDev

@Override
public void killChairArmorStand(@NotNull ArmorStand armorStand) {
    EnreplacedyArmorStand nmsArmorStand = ((CraftArmorStand) armorStand).getHandle();
    if (!(nmsArmorStand instanceof CustomArmorStand))
        throw new IllegalArgumentException(String.format(Messages.ERR_NOT_CUSTOM_ARMOR_STAND, CustomArmorStand.clreplaced.getName()));
    ((CustomArmorStand) nmsArmorStand).remove = true;
    armorStand.remove();
}

17 Source : Chair.java
with MIT License
from SpraxDev

/**
 * Holds a spawned chair<br>
 * Instances of this clreplaced get disposed
 * as soon the the player leaves the chair
 */
public clreplaced Chair {

    private static final String ERR_MANAGER_NOT_AVAILABLE = "ChairManager is not available yet - Did BetterChairs successfully enable?";

    protected final Block block;

    protected final ArmorStand armorStand;

    protected final Player player;

    private final Location playerOriginalLoc;

    Chair(Block block, ArmorStand armorStand, Player player) {
        this.block = block;
        this.armorStand = armorStand;
        this.player = player;
        this.playerOriginalLoc = player.getLocation();
    }

    /**
     * This method checks if it is a stair block.<br>
     * <s>Currently only Stairs and Slabs may be used for chairs.</s>
     *
     * @return true if the chair's block is a stair, false otherwise
     *
     * @see #getType()
     * @deprecated Since v1.1.0 Chairs may be any block and not just stairs and slabs
     */
    @Deprecated
    public boolean isStair() {
        if (ChairManager.getInstance() == null)
            throw new IllegalStateException(ERR_MANAGER_NOT_AVAILABLE);
        return ChairManager.getInstance().chairNMS.isStair(block);
    }

    /**
     * This method checks if it is a stair or slab block.<br>
     *
     * @return true if the chair's block is a stair, false otherwise
     */
    @NotNull
    public ChairType getType() {
        if (ChairManager.getInstance() == null)
            throw new IllegalStateException(ERR_MANAGER_NOT_AVAILABLE);
        if (ChairManager.getInstance().chairNMS.isStair(block))
            return ChairType.STAIR;
        if (ChairManager.getInstance().chairNMS.isSlab(block))
            return ChairType.SLAB;
        return ChairType.CUSTOM;
    }

    @SuppressWarnings("unused")
    @NotNull
    public Location getOriginPlayerLocation() {
        return this.playerOriginalLoc.clone();
    }

    @NotNull
    public Block getBlock() {
        return this.block;
    }

    @NotNull
    public ArmorStand getArmorStand() {
        return this.armorStand;
    }

    @NotNull
    public Player getPlayer() {
        return this.player;
    }

    @Nullable
    public Location getPlayerLeavingLocation() {
        if (!Settings.LEAVING_CHAIR_TELEPORT_TO_OLD_LOCATION.getValueAsBoolean())
            return null;
        Location loc = playerOriginalLoc.clone();
        if (Settings.LEAVING_CHAIR_KEEP_HEAD_ROTATION.getValueAsBoolean()) {
            loc.setDirection(this.player.getLocation().getDirection());
        }
        return loc;
    }

    /**
     * Sometimes the {@link org.spigotmc.event.enreplacedy.EnreplacedyDismountEvent}
     * is not fired for ArmorStands (e.g. Fallback NMS)<br>
     * This will check for preplacedengers and destroy the {@link Chair} if there is none
     *
     * @return true if the chair is being destroyed, false otherwise
     */
    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    protected boolean destroyOnNoPreplacedenger() {
        if (this.armorStand.getPreplacedenger() == null) {
            if (ChairManager.getInstance() == null)
                throw new IllegalStateException(ERR_MANAGER_NOT_AVAILABLE);
            ChairManager.getInstance().destroy(this, false);
            return true;
        }
        return false;
    }
}

17 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testHasEquipment() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    replacedertNotNull(armorStand.getEquipment());
}

17 Source : Hologram.java
with MIT License
from Redempt

private ArmorStand spawn(int line, String text) {
    Location loc;
    if (stands.size() > 0) {
        loc = stands.get(0).get().getLocation();
        loc.subtract(0, lineSpacing * (double) line, 0);
    } else {
        loc = start;
    }
    ArmorStand stand = (ArmorStand) loc.getWorld().spawnEnreplacedy(loc, EnreplacedyType.ARMOR_STAND);
    initiate(stand, text);
    return stand;
}

17 Source : Hologram.java
with MIT License
from Redempt

private static void setId(ArmorStand stand, int id) {
    objective.getScore(stand.getUniqueId().toString()).setScore(id);
}

17 Source : Hologram.java
with MIT License
from Redempt

/**
 * Removes a line from this Hologram
 * @param line The line number to remove
 */
public void remove(int line) {
    ArmorStand stand = stands.remove(line).get();
    stand.remove();
    fixStands();
}

17 Source : Hologram.java
with MIT License
from Redempt

/**
 * Adds a line at the bottom of this Hologram
 * @param text The text to append
 */
public void append(String text) {
    ArmorStand stand = spawn(stands.size(), text);
    stands.add(EnreplacedyPersistor.wrap(stand));
}

17 Source : Hologram.java
with MIT License
from Redempt

private static int getId(ArmorStand stand) {
    return objective.getScore(stand.getUniqueId().toString()).getScore();
}

17 Source : Uncarried.java
with GNU Affero General Public License v3.0
from PGMDev

/**
 * Base clreplaced for flag states in which the banner is placed on the ground somewhere as a block
 */
public abstract clreplaced Uncarried extends Spawned {

    protected final Location location;

    protected final BlockState oldBlock;

    protected final BlockState oldBase;

    protected ArmorStand labelEnreplacedy;

    @Nullable
    private MatchPlayer pickingUp;

    public Uncarried(Flag flag, Post post, @Nullable Location location) {
        super(flag, post);
        if (location == null)
            location = flag.getReturnPoint(post);
        this.location = new Location(location.getWorld(), location.getBlockX() + 0.5, location.getBlockY(), location.getBlockZ() + 0.5, location.getYaw(), location.getPitch());
        Block block = this.location.getBlock();
        if (block.getType() == Material.STANDING_BANNER) {
            // Banner may already be here at match start
            this.oldBlock = BlockStates.cloneWithMaterial(block, Material.AIR);
        } else {
            this.oldBlock = block.getState();
        }
        this.oldBase = block.getRelative(BlockFace.DOWN).getState();
    }

    @Override
    public Location getLocation() {
        return this.location;
    }

    protected void placeBanner() {
        if (!this.flag.canDropOn(oldBase)) {
            oldBase.getBlock().setType(Material.SEA_LANTERN, false);
        } else if (Materials.isWater(oldBase.getType())) {
            oldBase.getBlock().setType(Material.ICE, false);
        }
        Materials.placeStanding(this.location, this.flag.getBannerMeta());
        this.labelEnreplacedy = this.location.getWorld().spawn(this.location.clone().add(0, 1.7, 0), ArmorStand.clreplaced);
        this.labelEnreplacedy.setVisible(false);
        this.labelEnreplacedy.setMarker(true);
        this.labelEnreplacedy.setGravity(false);
        this.labelEnreplacedy.setRemoveWhenFarAway(false);
        this.labelEnreplacedy.setSmall(true);
        this.labelEnreplacedy.setArms(false);
        this.labelEnreplacedy.setBasePlate(false);
        this.labelEnreplacedy.setCustomName(this.flag.getColoredName());
        this.labelEnreplacedy.setCustomNameVisible(true);
    }

    protected void breakBanner() {
        this.labelEnreplacedy.remove();
        oldBase.update(true, false);
        oldBlock.update(true, false);
    }

    @Override
    public void enterState() {
        super.enterState();
        this.placeBanner();
    }

    @Override
    public void leaveState() {
        this.breakBanner();
        super.leaveState();
    }

    @Override
    public boolean isCarrying(MatchPlayer player) {
        // This allows CarryingFlagFilter to match and cancel the pickup before it actually happens
        return player == this.pickingUp || super.isCarrying(player);
    }

    @Override
    public boolean isCarrying(Party party) {
        return (this.pickingUp != null && party == this.pickingUp.getParty()) || super.isCarrying(party);
    }

    protected boolean pickupFlag(MatchPlayer carrier) {
        try {
            this.pickingUp = carrier;
            FlagPickupEvent event = new FlagPickupEvent(this.flag, carrier, this.location);
            this.flag.getMatch().callEvent(event);
            if (event.isCancelled())
                return false;
        } finally {
            this.pickingUp = null;
        }
        this.flag.playStatusSound(Flag.PICKUP_SOUND_OWN, Flag.PICKUP_SOUND);
        this.flag.touch(carrier.getParticipantState());
        this.flag.transition(new Carried(this.flag, this.post, carrier, this.location));
        return true;
    }

    protected boolean inPickupRange(Location playerLoc) {
        Location flagLoc = this.getLocation();
        if (playerLoc.getY() < flagLoc.getY() + 2 && playerLoc.getY() >= flagLoc.getY() - 2) {
            double dx = playerLoc.getX() - flagLoc.getX();
            double dz = playerLoc.getZ() - flagLoc.getZ();
            if (dx * dx + dz * dz <= 1) {
                return true;
            }
        }
        return false;
    }

    protected boolean canPickup(MatchPlayer player) {
        // Prevent infinite recursion
        if (this.pickingUp != null)
            return false;
        for (Flag flag : this.flag.getMatch().getModule(FlagMatchModule.clreplaced).getFlags()) {
            if (flag.isCarrying(player))
                return false;
        }
        return this.flag.canPickup(player, this.post);
    }

    @Override
    public void onEvent(PlayerMoveEvent event) {
        super.onEvent(event);
        MatchPlayer player = this.flag.getMatch().getPlayer(event.getPlayer());
        if (player == null || !player.canInteract() || player.getBukkit().isDead())
            return;
        if (this.inPickupRange(player.getBukkit().getLocation()) && this.canPickup(player)) {
            this.pickupFlag(player);
        }
    }

    @Override
    public void onEvent(BlockTransformEvent event) {
        super.onEvent(event);
        Block block = event.getOldState().getBlock();
        Block flagBlock = this.location.getBlock();
        if (block.equals(flagBlock) || block.equals(flagBlock.getRelative(BlockFace.UP))) {
            event.setCancelled(translatable("flag.cannotBreakFlag"));
        } else if (block.equals(flagBlock.getRelative(BlockFace.DOWN))) {
            event.setCancelled(translatable("flag.cannotBreakBlockUnder"));
        }
    }

    @Override
    public void onEvent(EnreplacedyDamageEvent event) {
        super.onEvent(event);
        if (event.getEnreplacedy() == this.labelEnreplacedy) {
            event.setCancelled(true);
            if (event instanceof EnreplacedyDamageByEnreplacedyEvent && ((EnreplacedyDamageByEnreplacedyEvent) event).getDamager() instanceof Projectile) {
                ((EnreplacedyDamageByEnreplacedyEvent) event).getDamager().remove();
            }
        }
    }
}

17 Source : Uncarried.java
with GNU Affero General Public License v3.0
from OvercastNetwork

/**
 * Base clreplaced for flag states in which the banner is placed
 * on the ground somewhere as a block
 */
public abstract clreplaced Uncarried extends Spawned {

    protected final Location location;

    protected final BlockState oldBlock;

    protected final BlockState oldBase;

    protected ArmorStand labelEnreplacedy;

    @Nullable
    private MatchPlayer pickingUp;

    public Uncarried(Flag flag, Post post, @Nullable Location location) {
        super(flag, post);
        if (location == null)
            location = flag.getReturnPoint(post);
        this.location = new Location(location.getWorld(), location.getBlockX() + 0.5, location.getBlockY(), location.getBlockZ() + 0.5, location.getYaw(), location.getPitch());
        if (!flag.getMatch().getWorld().equals(this.location.getWorld())) {
            throw new IllegalStateException("Tried to place flag in the wrong world");
        }
        Block block = this.location.getBlock();
        if (block.getType() == Material.STANDING_BANNER) {
            // Banner may already be here at match start
            this.oldBlock = BlockStateUtils.cloneWithMaterial(block, Material.AIR);
        } else {
            this.oldBlock = block.getState();
        }
        this.oldBase = block.getRelative(BlockFace.DOWN).getState();
    }

    @Override
    public Location getLocation() {
        return this.location;
    }

    protected void placeBanner() {
        if (!this.flag.canDropOn(oldBase)) {
            oldBase.getBlock().setType(Material.SEA_LANTERN, false);
        } else if (Materials.isWater(oldBase.getType())) {
            oldBase.getBlock().setType(Material.ICE, false);
        }
        if (!Banners.placeStanding(this.location, this.flag.getBannerMeta())) {
            PGM.get().getRootMapLogger().severe("Failed to place flag at " + location);
            forceRecover();
            return;
        }
        this.labelEnreplacedy = this.location.getWorld().spawn(this.location.clone().add(0, 0.7, 0), ArmorStand.clreplaced);
        this.labelEnreplacedy.setVisible(false);
        this.labelEnreplacedy.setGravity(false);
        this.labelEnreplacedy.setRemoveWhenFarAway(false);
        this.labelEnreplacedy.setSmall(true);
        this.labelEnreplacedy.setArms(false);
        this.labelEnreplacedy.setBasePlate(false);
        this.labelEnreplacedy.setCustomName(this.flag.getColoredName());
        this.labelEnreplacedy.setCustomNameVisible(true);
        NMSHacks.enableArmorSlots(this.labelEnreplacedy, false);
    }

    protected void breakBanner() {
        this.labelEnreplacedy.remove();
        oldBase.update(true, false);
        oldBlock.update(true, false);
    }

    @Override
    public void enterState() {
        super.enterState();
        this.placeBanner();
        this.flag.playFlareEffect();
    }

    @Override
    public void leaveState() {
        this.flag.playFlareEffect();
        this.breakBanner();
        super.leaveState();
    }

    @Override
    public boolean isCarrying(MatchPlayer player) {
        // This allows CarryingFlagFilter to match and cancel the pickup before it actually happens
        return player == this.pickingUp || super.isCarrying(player);
    }

    @Override
    public boolean isCarrying(Party party) {
        return (this.pickingUp != null && party == this.pickingUp.getParty()) || super.isCarrying(party);
    }

    protected boolean pickupFlag(MatchPlayer carrier) {
        try {
            this.pickingUp = carrier;
            FlagPickupEvent event = new FlagPickupEvent(this.flag, carrier, this.location);
            this.flag.getMatch().getPluginManager().callEvent(event);
            if (event.isCancelled())
                return false;
        } finally {
            this.pickingUp = null;
        }
        this.flag.playStatusSound(Flag.PICKUP_SOUND_OWN, Flag.PICKUP_SOUND);
        this.flag.touch(carrier.getParticipantState());
        this.flag.transition(new Carried(this.flag, this.post, carrier, this.location));
        return true;
    }

    protected boolean inPickupRange(Location playerLoc) {
        Location flagLoc = this.getLocation();
        if (playerLoc.getY() < flagLoc.getY() + 2 && playerLoc.getY() >= flagLoc.getY() - 2) {
            double dx = playerLoc.getX() - flagLoc.getX();
            double dz = playerLoc.getZ() - flagLoc.getZ();
            if (dx * dx + dz * dz <= 1) {
                return true;
            }
        }
        return false;
    }

    protected boolean canPickup(MatchPlayer player) {
        // Prevent infinite recursion
        if (this.pickingUp != null)
            return false;
        if (flag.getMatch().features().all(Flag.clreplaced).anyMatch(flag -> flag.isCarrying(player))) {
            return false;
        }
        return this.flag.canPickup(player, this.post);
    }

    @Override
    public void onEvent(PlayerMoveEvent event) {
        super.onEvent(event);
        MatchPlayer player = this.flag.getMatch().getPlayer(event.getPlayer());
        if (player == null || !player.canInteract() || player.getBukkit().isDead())
            return;
        if (this.inPickupRange(player.getBukkit().getLocation()) && this.canPickup(player)) {
            this.pickupFlag(player);
        }
    }

    @Override
    public void onEvent(BlockTransformEvent event) {
        super.onEvent(event);
        Block block = event.getOldState().getBlock();
        Block flagBlock = this.location.getBlock();
        if (block.equals(flagBlock) || block.equals(flagBlock.getRelative(BlockFace.UP))) {
            event.setCancelled(true, new TranslatableComponent("match.flag.cannotBreak"));
        } else if (block.equals(flagBlock.getRelative(BlockFace.DOWN))) {
            event.setCancelled(true, new TranslatableComponent("match.flag.cannotBreakBlockUnder"));
        }
    }

    @Override
    public void onEvent(EnreplacedyDamageEvent event) {
        super.onEvent(event);
        if (event.getEnreplacedy() == this.labelEnreplacedy) {
            event.setCancelled(true);
            if (event instanceof EnreplacedyDamageByEnreplacedyEvent && ((EnreplacedyDamageByEnreplacedyEvent) event).getDamager() instanceof Projectile) {
                ((EnreplacedyDamageByEnreplacedyEvent) event).getDamager().remove();
            }
        }
    }

    @Override
    public void tickLoaded() {
        super.tickLoaded();
        if (this.particleClock % 10 == 0) {
            this.flag.getMatch().getWorld().playEffect(this.getLocation().clone().add(0, 1, 0), Effect.PORTAL, 0, 0, 0, 0, 0, 1, 8, 64);
        }
    }
}

17 Source : DialogArmorStand.java
with GNU General Public License v3.0
from MagmaGuy

public static ArmorStand createDialogArmorStand(LivingEnreplacedy sourceEnreplacedy, String dialog) {
    ArmorStand armorStand = VisualArmorStand.VisualArmorStand(sourceEnreplacedy.getLocation().clone().add(new Vector(0, -50, 0)), dialog);
    // This part is necessary because armorstands are visible on their first tick to players
    new BukkitRunnable() {

        int taskTimer = 0;

        Location tickLocation = sourceEnreplacedy.getEyeLocation().clone();

        @Override
        public void run() {
            if (sourceEnreplacedy.isValid())
                tickLocation = sourceEnreplacedy.getLocation().clone();
            if (taskTimer > 0)
                armorStand.teleport(tickLocation.clone().add(new Vector(0, 2.3, 0)));
            if (taskTimer == 1)
                armorStand.setCustomNameVisible(true);
            if (taskTimer > 15) {
                EnreplacedyTracker.unregister(armorStand, RemovalReason.EFFECT_TIMEOUT);
                cancel();
            }
            taskTimer++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
    return armorStand;
}

17 Source : Hologram.java
with GNU General Public License v3.0
from Lix3nn53

public clreplaced Hologram {

    private final Location loc;

    private String replacedle;

    private Enreplacedy rider;

    private ArmorStand as;

    private final HologramType type;

    public Hologram(Location loc, String replacedle) {
        this.loc = loc;
        this.replacedle = replacedle;
        as = (ArmorStand) loc.getWorld().spawnEnreplacedy(loc, EnreplacedyType.ARMOR_STAND);
        as.setVisible(false);
        as.setGravity(false);
        as.setMarker(true);
        as.setInvulnerable(true);
        as.setCustomNameVisible(true);
        as.setCustomName(replacedle);
        type = HologramType.TEXT;
    }

    public Hologram(Location loc, Enreplacedy rider) {
        this.loc = loc;
        this.rider = rider;
        as = (ArmorStand) loc.getWorld().spawnEnreplacedy(loc, EnreplacedyType.ARMOR_STAND);
        as.setVisible(false);
        as.setGravity(false);
        as.setMarker(true);
        as.setInvulnerable(true);
        as.addPreplacedenger(rider);
        type = HologramType.PreplacedENGER;
    }

    public Hologram(Location loc) {
        this.loc = loc;
        as = (ArmorStand) loc.getWorld().spawnEnreplacedy(loc, EnreplacedyType.ARMOR_STAND);
        as.setVisible(false);
        as.setGravity(false);
        as.setMarker(true);
        as.setInvulnerable(true);
        as.setCustomNameVisible(false);
        as.setCustomName("");
        type = HologramType.INVISIBLE;
    }

    public ArmorStand getArmorStand() {
        return as;
    }

    public HologramType getType() {
        return type;
    }

    public enum HologramType {

        TEXT, PreplacedENGER, INVISIBLE
    }

    public void respawn() {
        as = (ArmorStand) loc.getWorld().spawnEnreplacedy(loc, EnreplacedyType.ARMOR_STAND);
        as.setVisible(false);
        as.setGravity(false);
        as.setMarker(true);
        as.setInvulnerable(true);
        if (replacedle != null) {
            as.setCustomNameVisible(true);
            as.setCustomName(replacedle);
        }
        if (rider != null) {
            as.addPreplacedenger(rider);
        }
    }

    public Location getLocation() {
        return loc;
    }
}

17 Source : TeleportationUtils.java
with GNU General Public License v3.0
from Lix3nn53

private static void nextStep(Player player, ArmorStand hologramTop, ArmorStand hologramBottom, String destination, int countDown) {
    player.sendreplacedle(ChatColor.BLUE + "Teleporting..", ChatColor.AQUA.toString() + countDown, 5, 20, 5);
    hologramTop.setCustomName(ChatColor.BLUE + "< " + ChatColor.YELLOW + destination + ChatColor.BLUE + " >");
    hologramBottom.setCustomName(ChatColor.AQUA + "Teleporting.. " + countDown);
}

17 Source : PortalManager.java
with GNU General Public License v3.0
from Lix3nn53

public static Portal getPortalFromArmorStand(ArmorStand armorStand) {
    for (String key : chunkKeyToPortal.keySet()) {
        List<Portal> portals = chunkKeyToPortal.get(key);
        for (Portal portal : portals) {
            if (portal.getArmorStand() != null) {
                if (portal.getArmorStand().equals(armorStand)) {
                    return portal;
                }
            }
        }
    }
    return null;
}

17 Source : CheckpointManager.java
with GNU General Public License v3.0
from Lix3nn53

public static Checkpoint getCheckpointFromArmorStand(ArmorStand armorStand) {
    for (String key : chunkKeyToCheckpoint.keySet()) {
        List<Checkpoint> checkpoints = chunkKeyToCheckpoint.get(key);
        for (Checkpoint checkpoint : checkpoints) {
            if (checkpoint.getArmorStand() != null) {
                if (checkpoint.getArmorStand().equals(armorStand)) {
                    return checkpoint;
                }
            }
        }
    }
    return null;
}

17 Source : GatheringManager.java
with GNU General Public License v3.0
from Lix3nn53

public static GatheringModel getGatheringModelFromArmorStand(ArmorStand armorStand) {
    for (String key : chunkKeyToGatheringCustomModelData.keySet()) {
        List<GatheringModel> gatheringModels = chunkKeyToGatheringCustomModelData.get(key);
        for (GatheringModel gatheringModel : gatheringModels) {
            if (gatheringModel.getArmorStand() != null) {
                if (gatheringModel.getArmorStand().equals(armorStand)) {
                    return gatheringModel;
                }
            }
        }
    }
    return null;
}

17 Source : BazaarManager.java
with GNU General Public License v3.0
from Lix3nn53

public static void putBazaarToPlayer(Player player, ArmorStand armorStand) {
    bazaarToPlayer.put(armorStand, player);
}

17 Source : Bazaar.java
with GNU General Public License v3.0
from Lix3nn53

public clreplaced Bazaar {

    private final Player owner;

    private final BazaarCustomerGui customerGui;

    private final List<Player> customers = new ArrayList<>();

    private ArmorStand bazaarModel;

    private boolean open = false;

    private int moneyEarned = 0;

    private final Location baseLocation;

    public Bazaar(Player owner) {
        this.owner = owner;
        this.customerGui = new BazaarCustomerGui(owner);
        this.baseLocation = owner.getLocation().clone();
        this.baseLocation.setYaw(0f);
        this.baseLocation.setPitch(0f);
        BazaarManager.onBazaarCreate(this.baseLocation, this);
    }

    public boolean addItem(ItemStack itemStack, int price) {
        if (GuardianDataManager.hasGuardianData(owner)) {
            GuardianData guardianData = GuardianDataManager.getGuardianData(owner);
            if (guardianData.bazaarStorageIsEmpty()) {
                if (customerGui.anyEmpty()) {
                    itemStack = EconomyUtils.setShopPrice(itemStack, price);
                    guardianData.addToBazaarStorage(itemStack);
                    customerGui.addItem(itemStack);
                    return true;
                }
            }
        }
        return false;
    }

    public boolean removeItem(ItemStack itemStack) {
        if (GuardianDataManager.hasGuardianData(owner)) {
            GuardianData guardianData = GuardianDataManager.getGuardianData(owner);
            if (gereplacedemsOnSale().contains(itemStack)) {
                guardianData.removeFromBazaarStorage(itemStack);
                customerGui.removeItem(itemStack, itemStack.getAmount());
                return true;
            }
        }
        return false;
    }

    public List<ItemStack> gereplacedemsOnSale() {
        List<ItemStack> itemsOnSale = new ArrayList<>();
        for (int i = 0; i < 18; i++) {
            if (customerGui.gereplacedem(i) != null) {
                ItemStack item = customerGui.gereplacedem(i);
                if (!item.getType().equals(Material.AIR)) {
                    itemsOnSale.add(item);
                }
            }
        }
        return itemsOnSale;
    }

    public boolean buyItem(Player buyer, ItemStack itemToBuy) {
        if (GuardianDataManager.hasGuardianData(owner)) {
            GuardianData guardianData = GuardianDataManager.getGuardianData(owner);
            if (gereplacedemsOnSale().contains(itemToBuy) && !buyer.equals(owner)) {
                boolean pay = EconomyUtils.pay(buyer, itemToBuy);
                if (pay) {
                    guardianData.removeFromBazaarStorage(itemToBuy);
                    removeItem(itemToBuy);
                    ItemStack clone = EconomyUtils.removeShopPrice(itemToBuy);
                    InventoryUtils.giveItemToPlayer(buyer, clone);
                    int price = EconomyUtils.gereplacedemPrice(itemToBuy);
                    moneyEarned += price;
                    List<Coin> coins = EconomyUtils.priceToCoins(price);
                    for (Coin coin : coins) {
                        if (coin.getAmount() > 0) {
                            boolean addedToBazaarStorage = guardianData.addToBazaarStorage(coin.getCoin());
                            if (!addedToBazaarStorage) {
                                InventoryUtils.giveItemToPlayer(owner, coin.getCoin());
                            }
                        }
                    }
                    owner.sendMessage(ChatColor.WHITE + buyer.getName() + ChatColor.GOLD + " purchased this item " + itemToBuy.gereplacedemMeta().getDisplayName() + ChatColor.GOLD + " from your bazaar. " + ChatColor.GREEN + coins.get(0).getAmount() + " " + ChatColor.WHITE + coins.get(1).getAmount() + " " + ChatColor.YELLOW + coins.get(2).getAmount() + ChatColor.GOLD + " coins added to your bazaar storage");
                    buyer.sendMessage(ChatColor.GOLD + "You purchased this item " + itemToBuy.gereplacedemMeta().getDisplayName() + " from " + ChatColor.WHITE + owner.getName() + ChatColor.GOLD + " for " + ChatColor.GREEN + coins.get(0).getAmount() + " " + ChatColor.WHITE + coins.get(1).getAmount() + " " + ChatColor.YELLOW + coins.get(2).getAmount() + ChatColor.GOLD + " coins");
                }
            }
        }
        return false;
    }

    public void createModel() {
        this.bazaarModel = (ArmorStand) baseLocation.getWorld().spawnEnreplacedy(baseLocation, EnreplacedyType.ARMOR_STAND);
        ItemStack itemStack = new ItemStack(Material.IRON_PICKAXE);
        ItemMeta itemMeta = itemStack.gereplacedemMeta();
        itemMeta.setCustomModelData(3);
        itemMeta.setUnbreakable(true);
        itemStack.sereplacedemMeta(itemMeta);
        EnreplacedyEquipment equipment = this.bazaarModel.getEquipment();
        equipment.setHelmet(itemStack);
        this.bazaarModel.setVisible(false);
        this.bazaarModel.setCustomName(ChatColor.GOLD + "< Bazaar " + ChatColor.YELLOW + owner.getName() + ChatColor.GOLD + " >");
        this.bazaarModel.setCustomNameVisible(true);
        this.bazaarModel.setInvulnerable(true);
        this.bazaarModel.setGravity(false);
        BazaarManager.putBazaarToPlayer(owner, bazaarModel);
    }

    public boolean isOpen() {
        return open;
    }

    public void setOpen(boolean isOpen) {
        this.open = isOpen;
    }

    public void edit() {
        List<Player> copy = new ArrayList<>();
        copy.addAll(customers);
        for (Player customer : copy) {
            customer.closeInventory();
        }
        GuiGeneric customerGui = new GuiGeneric(27, ChatColor.GOLD + "Edit your bazaar", 0);
        ItemStack glreplacedInfo = new ItemStack(Material.YELLOW_STAINED_GLreplaced_PANE);
        ItemMeta itemMeta = glreplacedInfo.gereplacedemMeta();
        itemMeta.setDisplayName(ChatColor.GOLD + "Click an item in your inventory to add");
        ArrayList<String> lore = new ArrayList<>();
        lore.add(ChatColor.GOLD + "to your bazaar. Click an item in your bazaar");
        lore.add(ChatColor.GOLD + "to remove from your bazaar.");
        lore.add("");
        lore.add(ChatColor.GREEN + "Click green wool to set up your bazaar");
        lore.add("");
        lore.add(ChatColor.RED + "Click red wool to destroy your bazaar");
        itemMeta.setLore(lore);
        glreplacedInfo.sereplacedemMeta(itemMeta);
        for (int i = 18; i <= 26; i++) {
            customerGui.sereplacedem(i, glreplacedInfo);
        }
        ItemStack redWool = new ItemStack(Material.RED_WOOL);
        ItemMeta redMeta = redWool.gereplacedemMeta();
        redMeta.setDisplayName(ChatColor.RED + "Click to destroy your bazaar");
        redWool.sereplacedemMeta(redMeta);
        customerGui.sereplacedem(18, redWool);
        ItemStack greenWool = new ItemStack(Material.LIME_WOOL);
        ItemMeta greenMeta = greenWool.gereplacedemMeta();
        greenMeta.setDisplayName(ChatColor.GREEN + "Click to set up your bazaar");
        greenWool.sereplacedemMeta(greenMeta);
        customerGui.sereplacedem(26, greenWool);
        int i = 0;
        for (ItemStack itemStack : gereplacedemsOnSale()) {
            customerGui.sereplacedem(i, itemStack);
            i++;
        }
        setOpen(false);
        new BukkitRunnable() {

            @Override
            public void run() {
                customerGui.openInventory(owner);
            }
        }.runTask(GuardiansOfAdelia.getInstance());
    }

    public void showToCustomer(Player customer) {
        if (open) {
            customerGui.openInventory(customer);
            customers.add(customer);
        }
    }

    public void remove() {
        List<Player> copy = new ArrayList<>();
        copy.addAll(customers);
        for (Player customer : copy) {
            customer.closeInventory();
        }
        BazaarManager.clearBazaarToPlayer(bazaarModel);
        if (this.bazaarModel != null) {
            this.bazaarModel.remove();
        }
        this.open = false;
        BazaarManager.onBazaarRemove(this);
    }

    public void setUp() {
        if (!gereplacedemsOnSale().isEmpty()) {
            if (this.bazaarModel == null) {
                createModel();
            }
            setOpen(true);
            owner.closeInventory();
        }
    }

    public List<Player> getCustomers() {
        return customers;
    }

    public int getMoneyEarned() {
        return moneyEarned;
    }

    public void removeCustomer(Player player) {
        customers.remove(player);
    }

    public Location getBaseLocation() {
        return baseLocation;
    }
}

17 Source : ChestRegenerateTask.java
with MIT License
from Avicus

/**
 * Task used to deolay the generator of containers and show a visual clock above them.
 */
public clreplaced ChestRegenerateTask extends Countdown {

    /**
     * Module to pull generation data from.
     */
    private final ChestsModule module;

    /**
     * Block that represents the container is being regenerated.
     */
    private final Block block;

    /**
     * Material of the block that represents the container is being regenerated.
     */
    private final Material material;

    /**
     * Armor stand used to display the clock.
     */
    private ArmorStand stand;

    /**
     * Constructor.
     *
     * @param module module to pull generation data from
     * @param block block that represents the container is being regenerated
     * @param delay material of the block that represents the container is being regenerated
     */
    public ChestRegenerateTask(ChestsModule module, Block block, Duration delay) {
        super(delay);
        this.module = module;
        this.block = block;
        this.material = block.getType();
    }

    @Override
    public Localizable getName() {
        return Messages.GENERIC_COUNTDOWN_CHEST_REGENERATE_NAME.with();
    }

    @Override
    public void onStart() {
        final Location location = this.block.getLocation().add(0.5, 0.8, 0.5);
        this.stand = location.getWorld().spawn(location, ArmorStand.clreplaced);
        this.stand.setGravity(false);
        this.stand.setSmall(true);
        this.stand.setMarker(true);
        this.stand.setVisible(false);
    }

    /**
     * Update armor stand if the block is still present and the material still matches.
     *
     * @param elapsedTime The amount of time elapsed.
     * @param remainingTime The amount of time remaining in the countdown.
     */
    @Override
    protected void onTick(Duration elapsedTime, Duration remainingTime) {
        if (this.block.getType() != this.material) {
            this.removeStand();
            return;
        }
        String clock = StringUtil.secondsToClock((int) remainingTime.getStandardSeconds());
        this.stand.setCustomName(ChatColor.GREEN + ChatColor.BOLD.toString() + clock);
        this.stand.setCustomNameVisible(true);
    }

    /**
     * Remove the stand and allow population to begin.
     */
    @Override
    protected void onEnd() {
        this.removeStand();
        this.module.clearGenerated(this.block);
    }

    @Override
    protected void onCancel() {
        this.removeStand();
    }

    private void removeStand() {
        this.stand.remove();
    }
}

16 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testEnreplacedySpawning() {
    Location location = new Location(world, 100, 100, 100);
    ArmorStand orb = (ArmorStand) world.spawnEnreplacedy(location, EnreplacedyType.ARMOR_STAND);
    // Does our enreplacedy exist in the correct World?
    replacedertTrue(world.getEnreplacedies().contains(orb));
    // Is it at the right location?
    replacedertEquals(location, orb.getLocation());
}

16 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testMarker() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    armorStand.setMarker(true);
    replacedertTrue(armorStand.isMarker());
    armorStand.setMarker(false);
    replacedertFalse(armorStand.isMarker());
}

16 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testSmall() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    armorStand.setSmall(true);
    replacedertTrue(armorStand.isSmall());
    armorStand.setSmall(false);
    replacedertFalse(armorStand.isSmall());
}

16 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testArms() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    armorStand.setArms(true);
    replacedertTrue(armorStand.hasArms());
    armorStand.setArms(false);
    replacedertFalse(armorStand.hasArms());
}

16 Source : ArmorStandMockTest.java
with MIT License
from seeseemelk

@Test
public void testEnreplacedyType() {
    ArmorStand armorStand = new ArmorStandMock(server, UUID.randomUUID());
    replacedertEquals(EnreplacedyType.ARMOR_STAND, armorStand.getType());
}

16 Source : Hologram.java
with MIT License
from Redempt

public List<String> getLines() {
    List<String> lines = new ArrayList<>();
    for (ArmorStand stand : getStands()) {
        lines.add(stand.getCustomName());
    }
    return lines;
}

16 Source : ArmorStandHologram.java
with GNU General Public License v3.0
from Plugily-Projects

public void delete() {
    for (ArmorStand armor : armorStands) {
        armor.setCustomNameVisible(false);
        armor.remove();
        HologramManager.getArmorStands().remove(armor);
    }
    if (enreplacedyItem != null) {
        enreplacedyItem.remove();
    }
    armorStands.clear();
}

16 Source : NMSHacks.java
with GNU Affero General Public License v3.0
from OvercastNetwork

public static void enableArmorSlots(ArmorStand armorStand, boolean enabled) {
    CraftArmorStand craftArmorStand = (CraftArmorStand) armorStand;
    NBTTagCompound nbt = new NBTTagCompound();
    craftArmorStand.getHandle().b(nbt);
    nbt.setInt("DisabledSlots", enabled ? 0 : 0x1f1f00);
    craftArmorStand.getHandle().a(nbt);
}

See More Examples