Fixed code smells

This commit is contained in:
Florian CUNY 2019-01-13 18:27:14 +01:00
parent 5f990b9103
commit a66bc90746
4 changed files with 9 additions and 8 deletions

View File

@ -109,7 +109,7 @@ public class MongoDBDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
@Override @Override
public boolean deleteID(String uniqueId) { public boolean deleteID(String uniqueId) {
try { try {
return collection.findOneAndDelete(new Document(MONGO_ID, uniqueId)) == null ? false : true; return collection.findOneAndDelete(new Document(MONGO_ID, uniqueId)) != null;
} catch (Exception e) { } catch (Exception e) {
plugin.logError("Could not delete object " + dataObject.getCanonicalName() + " " + uniqueId + " " + e.getMessage()); plugin.logError("Could not delete object " + dataObject.getCanonicalName() + " " + uniqueId + " " + e.getMessage());
return false; return false;

View File

@ -46,7 +46,7 @@ public class IslandDeletionManager implements Listener {
public void onBentoBoxReady(BentoBoxReadyEvent e) { public void onBentoBoxReady(BentoBoxReadyEvent e) {
// Load list of islands that were mid deletion and delete them // Load list of islands that were mid deletion and delete them
List<IslandDeletion> toBeDeleted = handler.loadObjects(); List<IslandDeletion> toBeDeleted = handler.loadObjects();
if (toBeDeleted != null && toBeDeleted.size() > 0) { if (!toBeDeleted.isEmpty()) {
plugin.log("There are " + toBeDeleted.size() + " islands pending deletion."); plugin.log("There are " + toBeDeleted.size() + " islands pending deletion.");
toBeDeleted.forEach(di -> { toBeDeleted.forEach(di -> {
plugin.log("Resuming deletion of island at " + di.getLocation().getWorld().getName() + " " + Util.xyz(di.getLocation().toVector())); plugin.log("Resuming deletion of island at " + di.getLocation().getWorld().getName() + " " + Util.xyz(di.getLocation().toVector()));

View File

@ -78,6 +78,7 @@ public class Clipboard {
private static final String ENTITY = "entity"; private static final String ENTITY = "entity";
private static final String COLOR = "color"; private static final String COLOR = "color";
private static final String LOAD_ERROR = "Could not load schems file - does not exist : "; private static final String LOAD_ERROR = "Could not load schems file - does not exist : ";
private static final String LINES = "lines";
private YamlConfiguration blockConfig = new YamlConfiguration(); private YamlConfiguration blockConfig = new YamlConfiguration();
private Location pos1; private Location pos1;
@ -234,7 +235,7 @@ public class Clipboard {
count++; count++;
} }
while (it3 != null && pasteState.equals(PasteState.ENTITIES) && count < pasteSpeed && it3.hasNext()) { while (it3 != null && pasteState.equals(PasteState.ENTITIES) && count < pasteSpeed && it3.hasNext()) {
pasteEntity(world, island, loc, blockConfig.getConfigurationSection(ENTITIES_YAML_PREFIX + it3.next())); pasteEntity(world, loc, blockConfig.getConfigurationSection(ENTITIES_YAML_PREFIX + it3.next()));
count++; count++;
} }
// STATE SHIFT // STATE SHIFT
@ -336,7 +337,7 @@ public class Clipboard {
} }
} }
private void pasteEntity(World world, Island island, Location location, ConfigurationSection config) { private void pasteEntity(World world, Location location, ConfigurationSection config) {
String[] pos = config.getName().split(","); String[] pos = config.getName().split(",");
int x = location.getBlockX() + Integer.valueOf(pos[0]); int x = location.getBlockX() + Integer.valueOf(pos[0]);
int y = location.getBlockY() + Integer.valueOf(pos[1]); int y = location.getBlockY() + Integer.valueOf(pos[1]);
@ -403,7 +404,7 @@ public class Clipboard {
BlockState bs = block.getState(); BlockState bs = block.getState();
// Signs // Signs
if (bs instanceof Sign) { if (bs instanceof Sign) {
List<String> lines = config.getStringList("lines"); List<String> lines = config.getStringList(LINES);
writeSign(island, block, lines); writeSign(island, block, lines);
} }
// Chests, in general // Chests, in general
@ -500,7 +501,7 @@ public class Clipboard {
// Signs // Signs
if (bs instanceof Sign) { if (bs instanceof Sign) {
Sign sign = (Sign)bs; Sign sign = (Sign)bs;
a.set("lines", Arrays.asList(sign.getLines())); a.set(LINES, Arrays.asList(sign.getLines()));
} }
return true; return true;
} else { } else {
@ -508,7 +509,7 @@ public class Clipboard {
// Signs // Signs
if (bs instanceof Sign) { if (bs instanceof Sign) {
Sign sign = (Sign)bs; Sign sign = (Sign)bs;
s.set("lines", Arrays.asList(sign.getLines())); s.set(LINES, Arrays.asList(sign.getLines()));
} }
} }

View File

@ -19,7 +19,7 @@ public class DeleteIslandChunks {
/** /**
* This is how many chunks per world will be done in one tick. * This is how many chunks per world will be done in one tick.
*/ */
private final static int SPEED = 5; private static final int SPEED = 5;
private int x; private int x;
private int z; private int z;
private BukkitTask task; private BukkitTask task;