45 }
46
47 final BridgePlayer bridgePlayer = playerService.getIfPresent(uniqueId);
48 if (bridgePlayer == null || bridgePlayer.getChoseMaterial() == type) {49 return;
50 }
51
60 return;
61 }
62
63 bridgePlayer.setChosenMaterial(type);64 menuManager.putInCooldown(uniqueId);
65
66 menuManager.showInventory(bridgePlayer);
45 }
46
47 final BridgePlayer bridgePlayer = playerService.getIfPresent(uniqueId);
48 if (bridgePlayer == null || bridgePlayer.getChoseMaterial() == type) {49 return;
50 }
51
45 }
46
47 final BridgePlayer bridgePlayer = playerService.getIfPresent(uniqueId);
48 if (bridgePlayer == null || bridgePlayer.getChoseMaterial() == type) {49 return;
50 }
51
45 }
46
47 final BridgePlayer bridgePlayer = playerService.getIfPresent(uniqueId);
48 if (bridgePlayer == null || bridgePlayer.getChoseMaterial() == type) {49 return;
50 }
51
This code contains a possible null pointer dereference. Double-check the code to ensure that the concerned variable always has a non-null value when accessed.
In the example below, if someCondition
is true, it is possible for value
to be null when it reaches the assignment
of valLen
.
String value = "something";
if (someCondition) {
value = null;
}
// ...
int valLen = value.length; // Null pointer exception!
Check for null before you use the value at the vulnerable point in code.
int valLen = value != null ? value.length : 0;
If value
was instead never intended to be null, consider changing the preceding logic to ensure that value
is at
least set to a safe default wherever possible:
if (someCondition) {
value = "";
}
int valLen = value.length; // No exception thrown.