package com.mineplex.studio;

import com.mineplex.studio.config.MineplexGlobalConfig;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.projectile.Snowball;
import net.minecraft.world.entity.projectile.ThrownEgg;
import net.minecraft.world.entity.projectile.ThrownEnderpearl;

public class InvalidDamageAmountHandler {
    public static boolean allowDamageEvent(double originalDamage, DamageSource damageSource) {
        Entity directEntity = damageSource.getDirectEntity();
        if (directEntity == null) {
            return false;
        }

        if (originalDamage != 0) {
            return false;
        }

        if (directEntity instanceof Snowball) {
            return MineplexGlobalConfig.get().getKnockback().isSnowballKnockback();
        }

        if (directEntity instanceof ThrownEgg) {
            return MineplexGlobalConfig.get().getKnockback().isEggKnockback();
        }

        if (directEntity instanceof ThrownEnderpearl) {
            return MineplexGlobalConfig.get().getKnockback().isEnderpealKnockback();
        }

        return false;
    }
}
