Fixed another bunch of code smells (Sonarcloud)

This commit is contained in:
Florian CUNY 2019-12-30 15:36:17 +01:00
parent f1f48279cc
commit c0a38fb9eb
3 changed files with 10 additions and 13 deletions

View File

@ -44,11 +44,11 @@ public class AdminRangeSetCommand extends CompositeCommand {
}
// Get new range
if (!Util.isInteger(args.get(1), true) || Integer.valueOf(args.get(1)) < 0) {
if (!Util.isInteger(args.get(1), true) || Integer.parseInt(args.get(1)) < 0) {
user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1));
return false;
}
int range = Integer.valueOf(args.get(1));
int range = Integer.parseInt(args.get(1));
// Get island
Island island = getIslands().getIsland(getWorld(), targetUUID);

View File

@ -151,8 +151,8 @@ public class BreakBlocksListener extends FlagListener {
}
// Find out who fired the arrow
if (e.getEntity().getShooter() instanceof Player) {
if (!checkIsland(e, (Player) e.getEntity().getShooter(), e.getHitBlock().getLocation(), Flags.BREAK_BLOCKS)) {
if (e.getEntity().getShooter() instanceof Player &&
!checkIsland(e, (Player) e.getEntity().getShooter(), e.getHitBlock().getLocation(), Flags.BREAK_BLOCKS)) {
final BlockData data = e.getHitBlock().getBlockData();
// We seemingly can't prevent the block from being destroyed
// So we need to put it back with a slight delay (yup, this is hacky - it makes the block flicker sometimes)
@ -161,5 +161,4 @@ public class BreakBlocksListener extends FlagListener {
// Sorry, this might also cause some ghost blocks!
}
}
}
}

View File

@ -32,7 +32,6 @@ class IslandGrid {
if (firstLoaded.getOwner() == null && island.getOwner() != null) {
// This looks fishy. We prefer to load islands that have an owner. Swap the two
plugin.logError("Duplicate island has an owner, so using that one. " + island.getOwner());
Island clone = new Island(firstLoaded);
firstLoaded = new Island(island);
zEntry.put(island.getMinZ(), firstLoaded);
} else if (firstLoaded.getOwner() != null && island.getOwner() != null) {
@ -42,7 +41,6 @@ class IslandGrid {
if (firstLoaded.getCreatedDate() > island.getCreatedDate()) {
plugin.logError("Same owner duplicate. Swaping based on creation date.");
// FirstLoaded is the newer
Island clone = new Island(firstLoaded);
firstLoaded = new Island(island);
zEntry.put(island.getMinZ(), firstLoaded);
} else {