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

The following examples show how to use org.bukkit.entity.ArmorStand#teleport() . 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: ArmorStandDisplayItem.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
public void fixDisplayMovedOld() {
    for (Entity entity : Objects.requireNonNull(this.shop.getLocation().getWorld()).getEntities()) {
        if (!(entity instanceof ArmorStand)) {
            continue;
        }
        ArmorStand eArmorStand = (ArmorStand) entity;
        if (eArmorStand.getUniqueId().equals(Objects.requireNonNull(this.armorStand).getUniqueId())) {
            Util.debugLog(
                    "Fixing moved ArmorStand displayItem "
                            + eArmorStand.getUniqueId()
                            + " at "
                            + eArmorStand.getLocation());
            eArmorStand.teleport(getDisplayLocation());
            return;
        }
    }
}
 
Example 2
Source File: MainListener.java    From ArmorStandTools with MIT License 5 votes vote down vote up
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) {
        ArmorStand as = plugin.carryingArmorStand.get(p.getUniqueId());
        if (as == null || as.isDead()) {
            plugin.carryingArmorStand.remove(p.getUniqueId());
            Utils.actionBarMsg(p, Config.asDropped);
            return;
        }
        as.teleport(Utils.getLocationFacing(event.getTo()));
        Utils.actionBarMsg(p, Config.carrying);
    }
}
 
Example 3
Source File: Main.java    From ArmorStandTools with MIT License 5 votes vote down vote up
void returnArmorStand(ArmorStand as) {
    if(as.hasMetadata("startLoc")) {
        for (MetadataValue value : as.getMetadata("startLoc")) {
            if (value.getOwningPlugin() == this) {
                as.teleport((Location) value.value());
                as.removeMetadata("startLoc", this);
                return;
            }
        }
    }
    as.remove();
}