Address bugs reported by SonarCloud

This commit is contained in:
tastybento 2023-02-09 17:27:57 -08:00
parent d6df904fbc
commit 9e407e659e
4 changed files with 1 additions and 13 deletions

View File

@ -220,7 +220,7 @@ public class Greenhouse implements DataObject {
* @return true if inside the greenhouse
*/
public boolean contains(Location location2) {
return getLocation().getWorld() != null
return getLocation() != null && getLocation().getWorld() != null
&& getLocation().getWorld().equals(location2.getWorld())
&& getBoundingBox().contains(location2.toVector());
}

View File

@ -43,10 +43,6 @@ public class PanelClick implements ClickHandler {
}
private boolean makeGreenhouse(User user, BiomeRecipe br) {
if (user.getLocation() == null) {
addon.logError("User has no location : " + user.getName());
return false;
}
// Check flag
if (!addon.getIslands().getIslandAt(user.getLocation()).map(i -> i.isAllowed(user, Greenhouses.GREENHOUSES)).orElse(false)) {
user.sendMessage("greenhouses.errors.no-rank");

View File

@ -92,10 +92,6 @@ class MakeCommand extends CompositeCommand {
* @return true if successful
*/
private boolean makeGreenhouse(User user, BiomeRecipe br) {
if (user.getLocation() == null) {
getAddon().logError("User had no location");
return false;
}
// Check flag
if (!getIslands().getIslandAt(user.getLocation()).map(i -> i.isAllowed(user, Greenhouses.GREENHOUSES)).orElse(false)) {
user.sendMessage("greenhouses.errors.no-rank");

View File

@ -35,10 +35,6 @@ class RemoveCommand extends CompositeCommand {
*/
@Override
public boolean execute(User user, String label, List<String> args) {
if (user.getLocation() == null) {
getAddon().logError("User had no location");
return false;
}
// Check flag
if (!getIslands().getIslandAt(user.getLocation()).map(i -> i.isAllowed(user, Greenhouses.GREENHOUSES)).orElse(false)) {
user.sendMessage("greenhouses.errors.no-rank");