classpublicPriority 3
ClearObjectiveItemsCompletion
com.hypixel.hytale.builtin.adventure.objectives.completion.ClearObjectiveItemsCompletion
extends ObjectiveCompletion
3
Methods
3
Public Methods
0
Fields
1
Constructors
Constructors
public
ClearObjectiveItemsCompletion(ObjectiveCompletionAsset asset)Methods
Public Methods (3)
public
ClearObjectiveItemsCompletionAsset getAsset()@Nonnull
public
void handle(Objective objective, ComponentAccessor<EntityStore> componentAccessor)@Override
public
String toString()@Nonnull@Override
Inheritance
Parent
Current
Interface
Child
Use mouse wheel to zoom, drag to pan. Click nodes to navigate.
Related Classes
Source Code
package com.hypixel.hytale.builtin.adventure.objectives.completion;
import com.hypixel.hytale.builtin.adventure.objectives.Objective;
import com.hypixel.hytale.builtin.adventure.objectives.config.completion.ClearObjectiveItemsCompletionAsset;
import com.hypixel.hytale.builtin.adventure.objectives.config.completion.ObjectiveCompletionAsset;
import com.hypixel.hytale.builtin.adventure.objectives.interactions.StartObjectiveInteraction;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.server.core.entity.Entity;
import com.hypixel.hytale.server.core.entity.EntityUtils;
import com.hypixel.hytale.server.core.entity.LivingEntity;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import com.hypixel.hytale.server.core.inventory.container.CombinedItemContainer;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.UUID;
import javax.annotation.Nonnull;
public class ClearObjectiveItemsCompletion extends ObjectiveCompletion {
public ClearObjectiveItemsCompletion(@Nonnull ObjectiveCompletionAsset asset) {
super(asset);
}
@Nonnull
public ClearObjectiveItemsCompletionAsset getAsset() {
return (ClearObjectiveItemsCompletionAsset)super.getAsset();
}
@Override
public void handle(@Nonnull Objective objective, @Nonnull ComponentAccessor<EntityStore> componentAccessor) {
objective.forEachParticipant((participantReference, objectiveUuid) -> {
Entity entity = EntityUtils.getEntity(participantReference, componentAccessor);
if (entity instanceof LivingEntity) {
CombinedItemContainer inventory = ((LivingEntity)entity).getInventory().getCombinedHotbarFirst();
for (short i = 0; i < inventory.getCapacity(); i++) {
ItemStack itemStack = inventory.getItemStack(i);
if (itemStack != null) {
UUID savedObjectiveUuid = itemStack.getFromMetadataOrNull(StartObjectiveInteraction.OBJECTIVE_UUID);
if (objectiveUuid.equals(savedObjectiveUuid)) {
inventory.removeItemStackFromSlot(i);
}
}
}
}
}, objective.getObjectiveUUID());
}
@Nonnull
@Override
public String toString() {
return "ClearObjectiveItemsCompletion{} " + super.toString();
}
}