package eu.mhsl.minenet.minigames.instance.hub.entity;

import eu.mhsl.minenet.minigames.instance.hub.inventory.HubInventory;
import eu.mhsl.minenet.minigames.shared.entity.InteractableEntity;
import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.metadata.villager.AbstractVillagerMeta;
import net.minestom.server.event.entity.EntityAttackEvent;
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
import net.minestom.server.event.player.PlayerEntityInteractEvent;
import org.jetbrains.annotations.NotNull;

public class RoomSelector extends InteractableEntity {
    final AbstractVillagerMeta abstractVillagerMeta;
    public RoomSelector() {
        super(EntityType.VILLAGER);

        abstractVillagerMeta = (AbstractVillagerMeta) this.getEntityMeta();
    }

    @Override
    public void onSpawn(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {

    }

    @Override
    public void onAttack(@NotNull EntityAttackEvent entityAttackEvent) {
        super.onAttack(entityAttackEvent);
        abstractVillagerMeta.setHeadShakeTimer(20);
    }

    @Override
    public void onInteract(@NotNull PlayerEntityInteractEvent playerEntityInteractEvent) {
        playerEntityInteractEvent.getPlayer().openInventory(new HubInventory(playerEntityInteractEvent.getPlayer()));
    }
}
