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.throwableitemprojectile.Snowball;
import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg;
import net.minecraft.world.entity.projectile.throwableitemprojectile.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;
    }
}
