mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 21:26:17 +01:00
Fixed a number of simple bugs discovered by FindBugs.
This commit is contained in:
parent
3899704774
commit
8839c03948
@ -62,7 +62,7 @@ public class ListeningWhitelist {
|
|||||||
* @return TRUE if there are any packets, FALSE otherwise.
|
* @return TRUE if there are any packets, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return whitelist != null || whitelist.size() > 0;
|
return whitelist != null && whitelist.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,8 +88,8 @@ class MinecraftRegistry {
|
|||||||
Map<Integer, Class> lookup = forceVanilla ? previousValues : overwrittenPackets;
|
Map<Integer, Class> lookup = forceVanilla ? previousValues : overwrittenPackets;
|
||||||
|
|
||||||
// Optimized lookup
|
// Optimized lookup
|
||||||
if (lookup.containsKey(packetToID)) {
|
if (lookup.containsKey(packetID)) {
|
||||||
return lookup.get(packetToID);
|
return lookup.get(packetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will most likely not be used
|
// Will most likely not be used
|
||||||
|
@ -48,7 +48,7 @@ class NetworkFieldInjector extends PlayerInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() throws IllegalAccessException {
|
protected synchronized void initialize() throws IllegalAccessException {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
// Get the sync field as well
|
// Get the sync field as well
|
||||||
|
@ -522,12 +522,12 @@ public final class PacketFilterManager implements ProtocolManager {
|
|||||||
if (!hasClosed && player != null) {
|
if (!hasClosed && player != null) {
|
||||||
|
|
||||||
PlayerInjector injector = playerInjection.get(player);
|
PlayerInjector injector = playerInjection.get(player);
|
||||||
DataInputStream input = injector.getInputStream(true);
|
|
||||||
|
|
||||||
if (injector != null) {
|
if (injector != null) {
|
||||||
|
DataInputStream input = injector.getInputStream(true);
|
||||||
injector.cleanupAll();
|
injector.cleanupAll();
|
||||||
|
|
||||||
playerInjection.remove(injector);
|
playerInjection.remove(player);
|
||||||
connectionLookup.remove(input);
|
connectionLookup.remove(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,20 @@ public class StructureModifier<TField> {
|
|||||||
initialize(targetType, Object.class, fields, defaults, null, new HashMap<Class, StructureModifier>());
|
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() {
|
public List<Field> getFields() {
|
||||||
return ImmutableList.copyOf(data);
|
return ImmutableList.copyOf(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve every value stored in the fields of the current type.
|
* Retrieve every value stored in the fields of the current type.
|
||||||
* @return Every field value.
|
* @return Every field value.
|
||||||
@ -367,8 +379,9 @@ public class StructureModifier<TField> {
|
|||||||
public List<TField> getValues() throws FieldAccessException {
|
public List<TField> getValues() throws FieldAccessException {
|
||||||
List<TField> values = new ArrayList<TField>();
|
List<TField> values = new ArrayList<TField>();
|
||||||
|
|
||||||
for (int i = 0; i < size(); i++)
|
for (int i = 0; i < size(); i++) {
|
||||||
values.add(read(i));
|
values.add(read(i));
|
||||||
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user