package net.minecraft.stats;

import net.minecraft.world.entity.player.Player;
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;

public class StatsCounter {
    protected final Object2IntMap<Stat<?>> stats;
    
    public StatsCounter() {
        (this.stats = (Object2IntMap<Stat<?>>)Object2IntMaps.synchronize((Object2IntMap)new Object2IntOpenHashMap())).defaultReturnValue(0);
    }
    
    public void increment(final Player ayj, final Stat<?> aao, final int integer) {
        this.setValue(ayj, aao, this.getValue(aao) + integer);
    }
    
    public void setValue(final Player ayj, final Stat<?> aao, final int integer) {
        this.stats.put(aao, integer);
    }
    
    public <T> int getValue(final StatType<T> aaq, final T object) {
        return aaq.contains(object) ? this.getValue(aaq.get(object)) : 0;
    }
    
    public int getValue(final Stat<?> aao) {
        return this.stats.getInt(aao);
    }
}
