Archiviert
13
0

Don't attempt to add NULL keys to a ConcurrentHashMap. Fixes #21

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-12-06 23:07:56 +01:00
Ursprung 23ebcb47ab
Commit aa3600a337

Datei anzeigen

@ -6,6 +6,7 @@ import java.util.Set;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.injector.packet.PacketRegistry; import com.comphenix.protocol.injector.packet.PacketRegistry;
import com.google.common.base.Preconditions;
import net.minecraft.util.com.google.common.collect.Maps; import net.minecraft.util.com.google.common.collect.Maps;
@ -32,8 +33,12 @@ public class PacketTypeSet {
* @param type - the type to add. * @param type - the type to add.
*/ */
public synchronized void addType(PacketType type) { public synchronized void addType(PacketType type) {
types.add(type); Class<?> packetClass = getPacketClass(type);
classes.add(getPacketClass(type)); types.add(Preconditions.checkNotNull(type, "type cannot be NULL."));
if (packetClass != null) {
classes.add(getPacketClass(type));
}
} }
/** /**
@ -41,8 +46,12 @@ public class PacketTypeSet {
* @param type - the type to remove. * @param type - the type to remove.
*/ */
public synchronized void removeType(PacketType type) { public synchronized void removeType(PacketType type) {
types.remove(type); Class<?> packetClass = getPacketClass(type);
classes.remove(getPacketClass(type)); types.remove(Preconditions.checkNotNull(type, "type cannot be NULL."));
if (packetClass != null) {
classes.remove(getPacketClass(type));
}
} }
/** /**