// Path: src/main/java/tc/oc/tracker/DamageInfo.java
// public interface DamageInfo {
//     /**
//      * Gets the living entity most responsible for this damage.
//      *
//      * @return Resolved damager or null if none exists
//      */
//     @Nullable LivingEntity getResolvedDamager();
// }
// 
// Path: src/main/java/tc/oc/tracker/DamageResolver.java
// public interface DamageResolver {
//     @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent);
// }
// 
// Path: src/main/java/tc/oc/tracker/Lifetime.java
// public interface Lifetime {
//     @Nullable Instant getStart();
// 
//     void setStart(@Nonnull Instant start);
// 
//     @Nullable Instant getEnd();
// 
//     void setEnd(@Nonnull Instant end);
// 
//     @Nonnull List<Damage> getDamage();
// 
//     @Nonnull ListIterator<Damage> getDamageFirst();
// 
//     @Nonnull ListIterator<Damage> getDamageLast();
// 
//     @Nullable Damage getFirstDamage();
// 
//     @Nullable Damage getLastDamage();
// 
//     /**
//      * Gets the last damage instance where the info object is an instance of
//      * the specified class. Uses {@link Class#isInstance(Object)} to check info
//      * objects.
//      *
//      * @param damageInfoClass DamageInfo class to check for
//      * @return Last damage that matched or null if none matched
//      *
//      * @throws NullPointerException if damageInfoClass is null
//      */
//     @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass);
// 
//     void addDamage(@Nonnull Damage damage);
// }
// 
// Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java
// public class AnvilDamageInfo extends AbstractDamageInfo {
// 
//     public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) {
//         super(resolvedDamager);
//         
//         this.anvil = anvil;
//         this.offlinePlayer = offlinePlayer;
//     }
//     
//     public @Nonnull FallingBlock getAnvil() {
//         return this.anvil;
//     }
//     
//     public @Nullable OfflinePlayer getOffinePlayer() {
//         return this.offlinePlayer;
//     }
// 
//     protected final @Nonnull FallingBlock anvil;
//     protected final @Nullable OfflinePlayer offlinePlayer;
//     
//     @Override
//     public @Nonnull String toString() {
//         return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}";
//     }
// }
// 
// Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java
// public interface AnvilTracker extends Tracker {
//     boolean hasOwner(@Nonnull FallingBlock entity);
// 
//     @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil);
// 
//     @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer);
// 
//     boolean hasPlacer(@Nonnull Block block);
// 
//     @Nullable OfflinePlayer getPlacer(@Nonnull Block block);
// 
//     @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer);
// 
//     @Nonnull OfflinePlayer clearPlacer(@Nullable Block block);
// }


import org.bukkit.OfflinePlayer;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import tc.oc.tracker.DamageInfo;
import tc.oc.tracker.DamageResolver;
import tc.oc.tracker.Lifetime;
import tc.oc.tracker.damage.AnvilDamageInfo;
import tc.oc.tracker.trackers.AnvilTracker;
package tc.oc.tracker.damage.resolvers;



public class AnvilDamageResolver implements DamageResolver {
    private final AnvilTracker anvilTracker;

    public AnvilDamageResolver(AnvilTracker anvilTracker) {
        this.anvilTracker = anvilTracker;
    }

    public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) {
        if(damageEvent instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

            if(event.getDamager() instanceof FallingBlock) {
                FallingBlock anvil = (FallingBlock) event.getDamager();
                OfflinePlayer offlineOwner = this.anvilTracker.getOwner(anvil);
                Player onlineOwner = null;

                if(offlineOwner != null) onlineOwner = offlineOwner.getPlayer();

// Path: src/main/java/tc/oc/tracker/DamageInfo.java
// public interface DamageInfo {
//     /**
//      * Gets the living entity most responsible for this damage.
//      *
//      * @return Resolved damager or null if none exists
//      */
//     @Nullable LivingEntity getResolvedDamager();
// }
// 
// Path: src/main/java/tc/oc/tracker/DamageResolver.java
// public interface DamageResolver {
//     @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent);
// }
// 
// Path: src/main/java/tc/oc/tracker/Lifetime.java
// public interface Lifetime {
//     @Nullable Instant getStart();
// 
//     void setStart(@Nonnull Instant start);
// 
//     @Nullable Instant getEnd();
// 
//     void setEnd(@Nonnull Instant end);
// 
//     @Nonnull List<Damage> getDamage();
// 
//     @Nonnull ListIterator<Damage> getDamageFirst();
// 
//     @Nonnull ListIterator<Damage> getDamageLast();
// 
//     @Nullable Damage getFirstDamage();
// 
//     @Nullable Damage getLastDamage();
// 
//     /**
//      * Gets the last damage instance where the info object is an instance of
//      * the specified class. Uses {@link Class#isInstance(Object)} to check info
//      * objects.
//      *
//      * @param damageInfoClass DamageInfo class to check for
//      * @return Last damage that matched or null if none matched
//      *
//      * @throws NullPointerException if damageInfoClass is null
//      */
//     @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass);
// 
//     void addDamage(@Nonnull Damage damage);
// }
// 
// Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java
// public class AnvilDamageInfo extends AbstractDamageInfo {
// 
//     public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) {
//         super(resolvedDamager);
//         
//         this.anvil = anvil;
//         this.offlinePlayer = offlinePlayer;
//     }
//     
//     public @Nonnull FallingBlock getAnvil() {
//         return this.anvil;
//     }
//     
//     public @Nullable OfflinePlayer getOffinePlayer() {
//         return this.offlinePlayer;
//     }
// 
//     protected final @Nonnull FallingBlock anvil;
//     protected final @Nullable OfflinePlayer offlinePlayer;
//     
//     @Override
//     public @Nonnull String toString() {
//         return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}";
//     }
// }
// 
// Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java
// public interface AnvilTracker extends Tracker {
//     boolean hasOwner(@Nonnull FallingBlock entity);
// 
//     @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil);
// 
//     @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer);
// 
//     boolean hasPlacer(@Nonnull Block block);
// 
//     @Nullable OfflinePlayer getPlacer(@Nonnull Block block);
// 
//     @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer);
// 
//     @Nonnull OfflinePlayer clearPlacer(@Nullable Block block);
// }


// Path: src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import tc.oc.tracker.DamageInfo;
import tc.oc.tracker.DamageResolver;
import tc.oc.tracker.Lifetime;
import tc.oc.tracker.damage.AnvilDamageInfo;
import tc.oc.tracker.trackers.AnvilTracker;

package tc.oc.tracker.damage.resolvers;



public class AnvilDamageResolver implements DamageResolver {
    private final AnvilTracker anvilTracker;

    public AnvilDamageResolver(AnvilTracker anvilTracker) {
        this.anvilTracker = anvilTracker;
    }

    public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) {
        if(damageEvent instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

            if(event.getDamager() instanceof FallingBlock) {
                FallingBlock anvil = (FallingBlock) event.getDamager();
                OfflinePlayer offlineOwner = this.anvilTracker.getOwner(anvil);
                Player onlineOwner = null;

                if(offlineOwner != null) onlineOwner = offlineOwner.getPlayer();

                return new AnvilDamageInfo(anvil, onlineOwner, offlineOwner);