Java Code Examples for org.bukkit.entity.Item#getTicksLived()

The following examples show how to use org.bukkit.entity.Item#getTicksLived() . 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: GunGizmo.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void run() {
    for(Item item : Bukkit.getWorlds().get(0).getEntitiesByClass(Item.class)) {
        if(item.getItemStack().getType() != Material.GHAST_TEAR) continue;
        UUID skip = Gizmos.gunGizmo.items.get(item);

        for(Entity entity : item.getNearbyEntities(0.5d, 0.5d, 0.5d)) {
            if(entity instanceof Player && !entity.getUniqueId().equals(skip)) {
                Player player = (Player) entity;
                if(player.hasPermission("gizmo.immunity")) continue;
                player.damage(0d, item);
                Gizmos.gunGizmo.gifts.add(player.getUniqueId());
                item.remove();
                break;
            }
        }

        if(item.getTicksLived() >= 6000) item.remove();
    }
}