Fixed a number of simple bugs discovered by FindBugs.

This commit is contained in:
Kristian S. Stangeland 2012-09-20 18:35:45 +02:00
parent 3899704774
commit 8839c03948
5 changed files with 23 additions and 10 deletions

View File

@ -62,7 +62,7 @@ public class ListeningWhitelist {
* @return TRUE if there are any packets, FALSE otherwise.
*/
public boolean isEnabled() {
return whitelist != null || whitelist.size() > 0;
return whitelist != null && whitelist.size() > 0;
}
/**

View File

@ -88,8 +88,8 @@ class MinecraftRegistry {
Map<Integer, Class> lookup = forceVanilla ? previousValues : overwrittenPackets;
// Optimized lookup
if (lookup.containsKey(packetToID)) {
return lookup.get(packetToID);
if (lookup.containsKey(packetID)) {
return lookup.get(packetID);
}
// Will most likely not be used

View File

@ -48,7 +48,7 @@ class NetworkFieldInjector extends PlayerInjector {
}
@Override
protected void initialize() throws IllegalAccessException {
protected synchronized void initialize() throws IllegalAccessException {
super.initialize();
// Get the sync field as well

View File

@ -522,12 +522,12 @@ public final class PacketFilterManager implements ProtocolManager {
if (!hasClosed && player != null) {
PlayerInjector injector = playerInjection.get(player);
DataInputStream input = injector.getInputStream(true);
if (injector != null) {
DataInputStream input = injector.getInputStream(true);
injector.cleanupAll();
playerInjection.remove(injector);
playerInjection.remove(player);
connectionLookup.remove(input);
}
}

View File

@ -63,8 +63,20 @@ public class StructureModifier<TField> {
initialize(targetType, Object.class, fields, defaults, null, new HashMap<Class, StructureModifier>());
}
private StructureModifier() {
// Consumers of this method should call "initialize"
/**
* Consumers of this method should call "initialize".
*/
protected StructureModifier() {
}
/**
* Initialize using the same field types.
* @param other - information to set.
*/
protected void initialize(StructureModifier<TField> other) {
initialize(other.targetType, other.fieldType, other.data,
other.defaultFields, other.converter, other.subtypeCache);
}
/**
@ -358,7 +370,7 @@ public class StructureModifier<TField> {
public List<Field> getFields() {
return ImmutableList.copyOf(data);
}
/**
* Retrieve every value stored in the fields of the current type.
* @return Every field value.
@ -367,8 +379,9 @@ public class StructureModifier<TField> {
public List<TField> getValues() throws FieldAccessException {
List<TField> values = new ArrayList<TField>();
for (int i = 0; i < size(); i++)
for (int i = 0; i < size(); i++) {
values.add(read(i));
}
return values;
}