    001    package net.minecraft.network.packet;
    002
    003    import java.util.HashMap;
    004    import java.util.Map;
    005
    006    public class PacketCount
    007    {
    008        /** If false, countPacket does nothing */
    009        public static boolean allowCounting = true;
    010
    011        /** A count of the total number of each packet sent grouped by IDs. */
    012        private static final Map packetCountForID = new HashMap();
    013
    014        /** A count of the total size of each packet sent grouped by IDs. */
    015        private static final Map sizeCountForID = new HashMap();
    016
    017        /** Used to make threads queue to add packets */
    018        private static final Object lock = new Object();
    019
    020        public static void countPacket(int par0, long par1)
    021        {
    022            if (allowCounting)
    023            {
    024                Object var3 = lock;
    025
    026                synchronized (lock)
    027                {
    028                    if (packetCountForID.containsKey(Integer.valueOf(par0)))
    029                    {
    030                        packetCountForID.put(Integer.valueOf(par0), Long.valueOf(((Long)packetCountForID.get(Integer.valueOf(par0))).longValue() + 1L));
    031                        sizeCountForID.put(Integer.valueOf(par0), Long.valueOf(((Long)sizeCountForID.get(Integer.valueOf(par0))).longValue() + par1));
    032                    }
    033                    else
    034                    {
    035                        packetCountForID.put(Integer.valueOf(par0), Long.valueOf(1L));
    036                        sizeCountForID.put(Integer.valueOf(par0), Long.valueOf(par1));
    037                    }
    038                }
    039            }
    040        }
    041    }