Merge branch 'develop' of https://github.com/BentoBoxWorld/bentobox.git into develop

This commit is contained in:
tastybento 2019-01-13 14:19:31 -08:00
commit ad3d044e88
5 changed files with 18 additions and 12 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

@ -9,13 +9,16 @@ import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.commands.CompositeCommand;
public class CommandsManager { public class CommandsManager {
private Map<String, CompositeCommand> commands = new HashMap<>(); @NonNull
private Map<@NonNull String, @NonNull CompositeCommand> commands = new HashMap<>();
public void registerCommand(CompositeCommand command) { public void registerCommand(@NonNull CompositeCommand command) {
commands.put(command.getLabel(), command); commands.put(command.getLabel(), command);
// Use reflection to obtain the commandMap method in Bukkit's server. // Use reflection to obtain the commandMap method in Bukkit's server.
try{ try{
@ -40,13 +43,15 @@ public class CommandsManager {
* @param command - command string * @param command - command string
* @return CompositeCommand or null if it does not exist * @return CompositeCommand or null if it does not exist
*/ */
public CompositeCommand getCommand(String command) { @Nullable
public CompositeCommand getCommand(@NonNull String command) {
return commands.get(command); return commands.get(command);
} }
/** /**
* @return the commands * @return the commands
*/ */
@NonNull
public Map<String, CompositeCommand> getCommands() { public Map<String, CompositeCommand> getCommands() {
return commands; return commands;
} }
@ -55,8 +60,8 @@ public class CommandsManager {
* List all commands registered so far * List all commands registered so far
* @return set of commands * @return set of commands
*/ */
@NonNull
public Set<String> listCommands() { public Set<String> listCommands() {
return commands.keySet(); return commands.keySet();
} }
} }

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;