// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.modules.entity.damage;

import com.hypixel.hytale.component.dependency.SystemGroupDependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.Dependency;
import java.util.Set;
import com.hypixel.hytale.server.core.modules.entityui.EntityUIModule;
import com.hypixel.hytale.server.core.modules.entitystats.EntityStatsModule;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.component.ComponentRegistryProxy;
import com.hypixel.hytale.server.core.command.system.AbstractCommand;
import com.hypixel.hytale.server.core.modules.entity.damage.commands.DesyncDamageCommand;
import com.hypixel.hytale.server.core.entity.knockback.KnockbackSystems;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;

public class DamageModule extends JavaPlugin
{
    public static final PluginManifest MANIFEST;
    private static DamageModule instance;
    private ComponentType<EntityStore, DeathComponent> deathComponentType;
    private ComponentType<EntityStore, DeferredCorpseRemoval> deferredCorpseRemovalComponentType;
    private SystemGroup<EntityStore> gatherDamageGroup;
    private SystemGroup<EntityStore> filterDamageGroup;
    private SystemGroup<EntityStore> inspectDamageGroup;
    
    public static DamageModule get() {
        return DamageModule.instance;
    }
    
    public DamageModule(@Nonnull final JavaPluginInit init) {
        super(init);
        DamageModule.instance = this;
    }
    
    @Override
    protected void setup() {
        final ComponentRegistryProxy<EntityStore> entityStoreRegistry = this.getEntityStoreRegistry();
        this.deathComponentType = entityStoreRegistry.registerComponent(DeathComponent.class, "Death", DeathComponent.CODEC);
        this.deferredCorpseRemovalComponentType = entityStoreRegistry.registerComponent(DeferredCorpseRemoval.class, () -> {
            throw new UnsupportedOperationException("not supported");
        });
        this.gatherDamageGroup = entityStoreRegistry.registerSystemGroup();
        this.filterDamageGroup = entityStoreRegistry.registerSystemGroup();
        this.inspectDamageGroup = entityStoreRegistry.registerSystemGroup();
        entityStoreRegistry.registerSystem(new OrderGatherFilter());
        entityStoreRegistry.registerSystem(new DamageSystems.ApplyDamage());
        entityStoreRegistry.registerSystem(new DamageSystems.CanBreathe());
        entityStoreRegistry.registerSystem(new DamageSystems.OutOfWorldDamage());
        entityStoreRegistry.registerSystem(new DamageSystems.FallDamagePlayers());
        entityStoreRegistry.registerSystem(new DamageSystems.FallDamageNPCs());
        entityStoreRegistry.registerSystem(new DamageSystems.FilterPlayerWorldConfig());
        entityStoreRegistry.registerSystem(new DamageSystems.FilterNPCWorldConfig());
        entityStoreRegistry.registerSystem(new DamageSystems.FilterUnkillable());
        entityStoreRegistry.registerSystem(new DamageSystems.PlayerDamageFilterSystem());
        entityStoreRegistry.registerSystem(new DamageSystems.WieldingDamageReduction());
        entityStoreRegistry.registerSystem(new DamageSystems.WieldingKnockbackReduction());
        entityStoreRegistry.registerSystem(new DamageSystems.ArmorKnockbackReduction());
        entityStoreRegistry.registerSystem(new DamageSystems.ArmorDamageReduction());
        entityStoreRegistry.registerSystem(new DamageSystems.HackKnockbackValues());
        entityStoreRegistry.registerSystem(new DamageSystems.RecordLastCombat());
        entityStoreRegistry.registerSystem(new DamageSystems.ApplyParticles());
        entityStoreRegistry.registerSystem(new DamageSystems.ApplySoundEffects());
        entityStoreRegistry.registerSystem(new DamageSystems.HitAnimation());
        entityStoreRegistry.registerSystem(new DamageSystems.TrackLastDamage());
        entityStoreRegistry.registerSystem(new DamageSystems.DamageArmor());
        entityStoreRegistry.registerSystem(new DamageSystems.DamageStamina());
        entityStoreRegistry.registerSystem(new DamageSystems.DamageAttackerTool());
        entityStoreRegistry.registerSystem(new DamageSystems.PlayerHitIndicators());
        entityStoreRegistry.registerSystem(new DamageSystems.ReticleEvents());
        entityStoreRegistry.registerSystem(new DamageSystems.EntityUIEvents());
        entityStoreRegistry.registerSystem(new KnockbackSystems.ApplyKnockback());
        entityStoreRegistry.registerSystem(new KnockbackSystems.ApplyPlayerKnockback());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.ClearHealth());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.ClearInteractions());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.ClearEntityEffects());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.PlayerKilledPlayer());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.DropPlayerDeathItems());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.PlayerDropItemsConfig());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.RunDeathInteractions());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.KillFeed());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.PlayerDeathScreen());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.PlayerDeathMarker());
        entityStoreRegistry.registerSystem(new DeathSystems.CorpseRemoval());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new DeathSystems.DeathAnimation());
        entityStoreRegistry.registerSystem(new DeathSystems.SpawnedDeathAnimation());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new RespawnSystems.ResetStatsRespawnSystem());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new RespawnSystems.ResetPlayerRespawnSystem());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new RespawnSystems.ClearEntityEffectsRespawnSystem());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new RespawnSystems.ClearInteractionsRespawnSystem());
        entityStoreRegistry.registerSystem((ISystem<EntityStore>)new RespawnSystems.CheckBrokenItemsRespawnSystem());
        entityStoreRegistry.registerSystem(new DamageCalculatorSystems.SequenceModifier());
        this.getCommandRegistry().registerCommand(new DesyncDamageCommand());
    }
    
    public ComponentType<EntityStore, DeathComponent> getDeathComponentType() {
        return this.deathComponentType;
    }
    
    public ComponentType<EntityStore, DeferredCorpseRemoval> getDeferredCorpseRemovalComponentType() {
        return this.deferredCorpseRemovalComponentType;
    }
    
    public SystemGroup<EntityStore> getGatherDamageGroup() {
        return this.gatherDamageGroup;
    }
    
    public SystemGroup<EntityStore> getFilterDamageGroup() {
        return this.filterDamageGroup;
    }
    
    public SystemGroup<EntityStore> getInspectDamageGroup() {
        return this.inspectDamageGroup;
    }
    
    static {
        MANIFEST = PluginManifest.corePlugin(DamageModule.class).depends(EntityModule.class).depends(EntityStatsModule.class).depends(EntityUIModule.class).build();
    }
    
    @Deprecated
    public static class OrderGatherFilter implements ISystem<EntityStore>
    {
        private final Set<Dependency<EntityStore>> dependencies;
        
        public OrderGatherFilter() {
            this.dependencies = (Set<Dependency<EntityStore>>)Set.of(new SystemGroupDependency(Order.AFTER, DamageModule.get().getGatherDamageGroup()), new SystemGroupDependency(Order.BEFORE, DamageModule.get().getFilterDamageGroup()));
        }
        
        @Nonnull
        @Override
        public Set<Dependency<EntityStore>> getDependencies() {
            return this.dependencies;
        }
    }
}
