Search in sources :

Example 1 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method getNearbyItems.

@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    List<Entity> entityList = new ArrayList<>();
    if (onlyChunk) {
        Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
        for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
        entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
    } else {
        AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
        entityList = world.getEntities(null, boundingBox, entity -> entity instanceof EntityItem);
    }
    return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder) DataInputStream(java.io.DataInputStream) AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Entity(net.minecraft.server.v1_16_R3.Entity) Item(org.bukkit.entity.Item) Inventory(org.bukkit.inventory.Inventory) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) BigInteger(java.math.BigInteger) ChestType(com.bgsoftware.wildchests.api.objects.ChestType) KeySet(com.bgsoftware.wildchests.key.KeySet) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) TileEntityChest(net.minecraft.server.v1_16_R3.TileEntityChest) World(net.minecraft.server.v1_16_R3.World) HumanEntity(org.bukkit.entity.HumanEntity) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) DataOutput(java.io.DataOutput) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) EntityHuman(net.minecraft.server.v1_16_R3.EntityHuman) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Collectors(java.util.stream.Collectors) Particle(org.bukkit.Particle) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) NBTReadLimiter(net.minecraft.server.v1_16_R3.NBTReadLimiter) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) NBTCompressedStreamTools(net.minecraft.server.v1_16_R3.NBTCompressedStreamTools) Entity(net.minecraft.server.v1_16_R3.Entity) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Item(org.bukkit.entity.Item) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) ArrayList(java.util.ArrayList) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) EntityItem(net.minecraft.server.v1_16_R3.EntityItem)

Example 2 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.

the class EntityDataServiceTest method testCreateWithIdentifyingAttributes.

@Test
public void testCreateWithIdentifyingAttributes() {
    AttributeValue randomUUIDAttrValue = generateRandomUUIDAttrValue();
    Entity entity = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), randomUUIDAttrValue).build();
    Entity createdEntity = entityDataServiceClient.upsert(entity);
    assertNotNull(createdEntity.getEntityId());
    Entity entity1 = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service 1").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), randomUUIDAttrValue).build();
    Entity createdEntity1 = entityDataServiceClient.upsert(entity1);
    // Should be same entity since identifying attributes are the same
    assertEquals(createdEntity.getEntityId(), createdEntity1.getEntityId());
}
Also used : EnrichedEntity(org.hypertrace.entity.data.service.v1.EnrichedEntity) Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeValue(org.hypertrace.entity.data.service.v1.AttributeValue) Test(org.junit.jupiter.api.Test)

Example 3 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.

the class EntityDataServiceTest method testEntityQueryAttributeWithExistsFiltering.

@Test
public void testEntityQueryAttributeWithExistsFiltering() {
    String stringRandomizer1 = UUID.randomUUID().toString();
    Entity entity1 = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), AttributeValue.newBuilder().setValue(Value.newBuilder().setString("value1").build()).build()).putAttributes("simpleValue1" + "-" + stringRandomizer1, AttributeValue.newBuilder().setValue(Value.newBuilder().setString("StringValue1").build()).build()).build();
    Entity createdEntity1 = entityDataServiceClient.upsert(entity1);
    assertNotNull(createdEntity1.getEntityId());
    String stringRandomizer2 = UUID.randomUUID().toString();
    Entity entity2 = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), AttributeValue.newBuilder().setValue(Value.newBuilder().setString("value2").build()).build()).putAttributes("simpleValue2" + "-" + stringRandomizer2, AttributeValue.newBuilder().setValue(Value.newBuilder().setString("StringValue2").build()).build()).putAttributes("test" + "-" + stringRandomizer2, AttributeValue.newBuilder().setValue(Value.newBuilder().setString("test").build()).build()).build();
    Entity createdEntity2 = entityDataServiceClient.upsert(entity2);
    assertNotNull(createdEntity2.getEntityId());
    // test for exists operator
    AttributeFilter existsFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("simpleValue1" + "-" + stringRandomizer1)).setOperator(Operator.EXISTS).build();
    List<Entity> entities = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(existsFilter).build());
    assertEquals(1, entities.size());
    assertEquals(createdEntity1, entities.get(0));
    // test for not-exists operator
    AttributeFilter notExistsFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("simpleValue3")).setOperator(Operator.NOT_EXISTS).build();
    entities = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(notExistsFilter).build());
    assertTrue(entities.size() > 0);
    // test with AND operator
    AttributeFilter eqFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("test" + "-" + stringRandomizer2)).setOperator(Operator.EQ).setAttributeValue(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("test").build()).build()).build();
    existsFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("simpleValue2" + "-" + stringRandomizer2)).setOperator(Operator.EXISTS).build();
    AttributeFilter andFilter = AttributeFilter.newBuilder().setOperator(Operator.AND).addChildFilter(eqFilter).addChildFilter(existsFilter).build();
    entities = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(andFilter).build());
    assertEquals(1, entities.size());
    assertEquals(createdEntity2, entities.get(0));
    // exists with attribute value - discard the value
    existsFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("simpleValue1" + "-" + stringRandomizer1)).setOperator(Operator.EXISTS).setAttributeValue(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("StringValue").build()).build()).build();
    entities = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(existsFilter).build());
    assertEquals(1, entities.size());
    assertEquals(createdEntity1, entities.get(0));
}
Also used : EnrichedEntity(org.hypertrace.entity.data.service.v1.EnrichedEntity) Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeFilter(org.hypertrace.entity.data.service.v1.AttributeFilter) Test(org.junit.jupiter.api.Test)

Example 4 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.

the class EntityDataServiceTest method testCreateV2EntityTypeWithoutIdentifyingAttributes.

@Test
public void testCreateV2EntityTypeWithoutIdentifyingAttributes() {
    Entity firstInputEntity = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(TEST_ENTITY_TYPE_V2).setEntityId(UUID.randomUUID().toString()).setEntityName("Test entity v2").putAttributes("foo", AttributeValue.newBuilder().setValue(Value.newBuilder().setString("foo1")).build()).build();
    Entity firstCreatedEntity = entityDataServiceClient.upsert(firstInputEntity);
    assertNotSame(firstInputEntity, firstCreatedEntity);
    assertEntityEquals(firstInputEntity, firstCreatedEntity);
    Entity secondInputEntity = firstInputEntity.toBuilder().clearAttributes().build();
    Entity secondCreatedEntity = entityDataServiceClient.upsert(secondInputEntity);
    assertEntityEquals(firstCreatedEntity, secondCreatedEntity);
}
Also used : EnrichedEntity(org.hypertrace.entity.data.service.v1.EnrichedEntity) Entity(org.hypertrace.entity.data.service.v1.Entity) Test(org.junit.jupiter.api.Test)

Example 5 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.

the class EntityDataServiceTest method testEntityQueryAttributeFiltering.

@Test
public void testEntityQueryAttributeFiltering() {
    long timeBeforeQuery = System.currentTimeMillis();
    String stringRandomizer = UUID.randomUUID().toString();
    Entity entity = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), AttributeValue.newBuilder().setValue(Value.newBuilder().setString("value1").build()).build()).putAttributes("simpleValue" + "-" + stringRandomizer, AttributeValue.newBuilder().setValue(Value.newBuilder().setString("StringValue").build()).build()).putAttributes("listValue" + "-" + stringRandomizer, AttributeValue.newBuilder().setValueList(AttributeValueList.newBuilder().addValues(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("item1").build()).build()).addValues(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("item2").build()).build()).build()).build()).putAttributes("mapValue" + "-" + stringRandomizer, AttributeValue.newBuilder().setValueMap(AttributeValueMap.newBuilder().putValues("nestedKey", AttributeValue.newBuilder().setValue(Value.newBuilder().setString("nestedValue").build()).build()).build()).build()).build();
    Entity createdEntity = entityDataServiceClient.upsert(entity);
    assertNotNull(createdEntity.getEntityId());
    AttributeFilter stringFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("simpleValue" + "-" + stringRandomizer)).setOperator(Operator.EQ).setAttributeValue(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("StringValue").build()).build()).build();
    List<Entity> entities1 = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(stringFilter).build());
    Entity foundEntity1 = entities1.get(0);
    assertEquals(createdEntity, foundEntity1);
    // filter by createdTime, which is treated as attribute filtering because it should be able
    // to support different operations like regular attribtues
    AttributeFilter createTimeFilter = AttributeFilter.newBuilder().setName(EntityServiceConstants.ENTITY_CREATED_TIME).setOperator(Operator.GT).setAttributeValue(AttributeValue.newBuilder().setValue(Value.newBuilder().setLong(timeBeforeQuery).build()).build()).build();
    List<Entity> entities11 = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(createTimeFilter).build());
    Entity foundEntity11 = entities11.get(0);
    assertEquals(createdEntity, foundEntity11);
    AttributeFilter nestedFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("mapValue" + "-" + stringRandomizer)).setOperator(Operator.EQ).setAttributeValue(AttributeValue.newBuilder().setValueMap(AttributeValueMap.newBuilder().putValues("nestedKey", AttributeValue.newBuilder().setValue(Value.newBuilder().setString("nestedValue").build()).build()).build()).build()).build();
    List<Entity> entities2 = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(nestedFilter).build());
    Entity foundEntity2 = entities2.get(0);
    assertEquals(createdEntity, foundEntity2);
    AttributeFilter listFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("listValue" + "-" + stringRandomizer)).setOperator(Operator.EQ).setAttributeValue(AttributeValue.newBuilder().setValueList(AttributeValueList.newBuilder().addValues(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("item1").build()).build()).addValues(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("item2").build()).build()).build()).build()).build();
    List<Entity> entities3 = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(listFilter).build());
    Entity foundEntity3 = entities3.get(0);
    assertEquals(createdEntity, foundEntity3);
    AttributeFilter listInFilter = AttributeFilter.newBuilder().setName(EntityConstants.attributeMapPathFor("listValue" + "-" + stringRandomizer)).setOperator(Operator.CONTAINS).setAttributeValue(AttributeValue.newBuilder().setValueList(AttributeValueList.newBuilder().addValues(AttributeValue.newBuilder().setValue(Value.newBuilder().setString("item1").build()).build()).build()).build()).build();
    List<Entity> entities4 = entityDataServiceClient.query(TENANT_ID, Query.newBuilder().setFilter(listInFilter).build());
    Entity foundEntity4 = entities4.get(0);
    assertEquals(createdEntity, foundEntity4);
}
Also used : EnrichedEntity(org.hypertrace.entity.data.service.v1.EnrichedEntity) Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeFilter(org.hypertrace.entity.data.service.v1.AttributeFilter) Test(org.junit.jupiter.api.Test)

Aggregations

Entity (org.hypertrace.entity.data.service.v1.Entity)110 LivingEntity (org.bukkit.entity.LivingEntity)95 Test (org.junit.jupiter.api.Test)95 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)40 org.bukkit.entity (org.bukkit.entity)40 Entity (com.google.datastore.v1.Entity)33 ArrayList (java.util.ArrayList)33 Location (org.bukkit.Location)33 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Mob (net.minecraft.world.entity.Mob)20 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Entity (net.minecraft.server.v1_8_R3.Entity)18 AnnotateVideoProgress (com.google.cloud.videointelligence.v1.AnnotateVideoProgress)17 AnnotateVideoRequest (com.google.cloud.videointelligence.v1.AnnotateVideoRequest)17 AnnotateVideoResponse (com.google.cloud.videointelligence.v1.AnnotateVideoResponse)17 Entity (com.google.cloud.videointelligence.v1.Entity)17