Search in sources :

Example 76 with Container

use of com.google.api.services.container.v1beta1.Container in project Panilla by ds58.

the class InventoryCleaner method clean.

@Override
public void clean(IPanillaPlayer player) {
    CraftPlayer craftPlayer = (CraftPlayer) player.getHandle();
    Container container = craftPlayer.getHandle().activeContainer;
    for (int slot = 0; slot < container.slots.size(); slot++) {
        ItemStack itemStack = container.getSlot(slot).getItem();
        if (itemStack == null || !itemStack.hasTag()) {
            continue;
        }
        NBTTagCompound nmsTag = itemStack.getTag();
        INbtTagCompound tag = new NbtTagCompound(nmsTag);
        String itemName = itemStack.getItem().getName();
        if (nmsTag == null || itemName == null) {
            continue;
        }
        FailedNbt failedNbt = NbtChecks.checkAll(tag, itemName, panilla);
        if (FailedNbt.failsThreshold(failedNbt)) {
            container.getSlot(slot).getItem().setTag(null);
        } else if (FailedNbt.fails(failedNbt)) {
            nmsTag.remove(failedNbt.key);
            container.getSlot(slot).getItem().setTag(nmsTag);
        }
    }
}
Also used : Container(net.minecraft.server.v1_15_R1.Container) NbtTagCompound(com.ruinscraft.panilla.craftbukkit.v1_15_R1.nbt.NbtTagCompound) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) ItemStack(net.minecraft.server.v1_15_R1.ItemStack) FailedNbt(com.ruinscraft.panilla.api.exception.FailedNbt)

Example 77 with Container

use of com.google.api.services.container.v1beta1.Container in project mdsal by opendaylight.

the class Mdsal298Test method testUnkeyedDataTreeModification.

@Test
public void testUnkeyedDataTreeModification() throws InterruptedException, ExecutionException {
    final DataTreeChangeListener<Container> listener = assertWrittenContainer(Container.QNAME, Container.class, new ContainerBuilder().build());
    final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
    domTx.put(CONFIGURATION, YangInstanceIdentifier.create(CONTAINER_NID).node(Unkeyed.QNAME), Builders.unkeyedListBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo")).build()).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar")).build()).build());
    domTx.commit().get();
    final ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
    verify(listener).onDataTreeChanged(captor.capture());
    Collection<DataTreeModification<Container>> capture = captor.getValue();
    assertEquals(1, capture.size());
    final DataTreeModification<Container> change = capture.iterator().next();
    assertEquals(CONTAINER_TID, change.getRootPath());
    final DataObjectModification<Container> changedContainer = change.getRootNode();
    assertEquals(Item.of(Container.class), changedContainer.getIdentifier());
    assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
    final Container containerAfter = changedContainer.getDataAfter();
    assertEquals(new ContainerBuilder().setUnkeyed(List.of(new UnkeyedBuilder().setFoo("foo").build(), new UnkeyedBuilder().setFoo("bar").build())).build(), containerAfter);
    final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
    assertEquals(0, changedChildren.size());
}
Also used : DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) UnkeyedBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) Container(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container) ContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) Collection(java.util.Collection) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Test(org.junit.Test)

Example 78 with Container

use of com.google.api.services.container.v1beta1.Container in project mdsal by opendaylight.

the class TestListSquashing method testEmptyUserOrderedList.

@Test
public void testEmptyUserOrderedList() {
    final Container cont = new ContainerBuilder().setKeyed(List.of()).setUnkeyed(List.of()).build();
    // Empty Lists should become null
    assertNull(cont.getKeyed());
    assertNull(cont.getUnkeyed());
}
Also used : Container(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container) ContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder) Test(org.junit.Test)

Example 79 with Container

use of com.google.api.services.container.v1beta1.Container in project flytekit-java by flyteorg.

the class FlyteAdminClientTest method shouldPropagateCreateTaskToStub.

@Test
public void shouldPropagateCreateTaskToStub() {
    TaskIdentifier identifier = TaskIdentifier.builder().domain(DOMAIN).project(PROJECT).name(TASK_NAME).version(TASK_VERSION).build();
    TypedInterface interface_ = TypedInterface.builder().inputs(ImmutableMap.of("x", createVar(SimpleType.STRING))).outputs(ImmutableMap.of("y", createVar(SimpleType.INTEGER))).build();
    Container container = Container.builder().command(ImmutableList.of(COMMAND)).args(ImmutableList.of()).image(IMAGE_NAME).env(ImmutableList.of(KeyValuePair.of("key", "value"))).build();
    RetryStrategy retries = RetryStrategy.builder().retries(4).build();
    TaskTemplate template = TaskTemplate.builder().container(container).type("custom-task").interface_(interface_).custom(Struct.of(emptyMap())).retries(retries).build();
    client.createTask(identifier, template);
    assertThat(stubService.createTaskRequest, equalTo(TaskOuterClass.TaskCreateRequest.newBuilder().setId(newIdentifier(ResourceType.TASK, TASK_NAME, TASK_VERSION)).setSpec(newTaskSpec()).build()));
}
Also used : TaskTemplate(org.flyte.api.v1.TaskTemplate) TypedInterface(org.flyte.api.v1.TypedInterface) Container(org.flyte.api.v1.Container) TaskIdentifier(org.flyte.api.v1.TaskIdentifier) PartialTaskIdentifier(org.flyte.api.v1.PartialTaskIdentifier) RetryStrategy(org.flyte.api.v1.RetryStrategy) Test(org.junit.Test)

Example 80 with Container

use of com.google.api.services.container.v1beta1.Container in project flytekit-java by flyteorg.

the class ProtoUtil method serialize.

static Tasks.TaskTemplate serialize(TaskTemplate taskTemplate) {
    Tasks.RuntimeMetadata runtime = Tasks.RuntimeMetadata.newBuilder().setType(Tasks.RuntimeMetadata.RuntimeType.FLYTE_SDK).setFlavor(RUNTIME_FLAVOR).setVersion(RUNTIME_VERSION).build();
    Tasks.TaskMetadata metadata = Tasks.TaskMetadata.newBuilder().setRuntime(runtime).setRetries(serialize(taskTemplate.retries())).build();
    Container container = requireNonNull(taskTemplate.container(), "Only container based task templates are supported");
    return Tasks.TaskTemplate.newBuilder().setContainer(serialize(container)).setMetadata(metadata).setInterface(serialize(taskTemplate.interface_())).setType(taskTemplate.type()).setCustom(serializeStruct(taskTemplate.custom())).build();
}
Also used : Container(org.flyte.api.v1.Container) Tasks(flyteidl.core.Tasks)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)45 Container (net.minecraft.server.v1_12_R1.Container)9 Container (net.minecraft.server.v1_16_R3.Container)9 Container (org.flyte.api.v1.Container)9 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)8 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)8 Container (net.minecraft.server.v1_11_R1.Container)8 Container (net.minecraft.server.v1_14_R1.Container)8 Container (net.minecraft.server.v1_15_R1.Container)8 Container (net.minecraft.server.v1_16_R1.Container)8 Container (net.minecraft.server.v1_16_R2.Container)8 Container (net.minecraft.server.v1_8_R3.Container)8 Container (net.minecraft.server.v1_13_R1.Container)7 Container (net.minecraft.server.v1_13_R2.Container)6 Container (net.minecraft.server.v1_10_R1.Container)5 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)5 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer)4 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)4 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)4 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)4