Fixed code smells.

This commit is contained in:
tastybento 2019-05-18 16:13:10 -07:00
parent e911a5593d
commit 362d9f8362
3 changed files with 12 additions and 8 deletions

View File

@ -56,6 +56,8 @@ public class BlueprintPaster {
CANCEL
}
private static final String MINECRAFT = "minecraft:";
private Map<String, String> BLOCK_CONVERSION = ImmutableMap.of("sign", "oak_sign", "wall_sign", "oak_wall_sign");
private BentoBox plugin;
@ -189,9 +191,9 @@ public class BlueprintPaster {
plugin.logWarning("World: " + world.getName() + " Failed block data: " + bpBlock.getBlockData());
// Try to fix
for (Entry<String, String> en : BLOCK_CONVERSION.entrySet()) {
if (bpBlock.getBlockData().startsWith("minecraft:" + en.getKey())) {
if (bpBlock.getBlockData().startsWith(MINECRAFT + en.getKey())) {
bd = Bukkit.createBlockData(
bpBlock.getBlockData().replace("minecraft:" + en.getKey(), "minecraft:" + en.getValue()));
bpBlock.getBlockData().replace(MINECRAFT + en.getKey(), MINECRAFT + en.getValue()));
break;
}
}

View File

@ -18,6 +18,8 @@ import world.bentobox.bentobox.database.objects.Players;
*/
public class BentoBoxMigrateCommand extends ConfirmableCommand {
private static final String MIGRATED = "commands.bentobox.migrate.migrated";
/**
* Reloads settings, addons and localization command
* @param parent command parent
@ -38,16 +40,16 @@ public class BentoBoxMigrateCommand extends ConfirmableCommand {
// Migrate BentoBox data
user.sendMessage("commands.bentobox.migrate.players");
new Database<>(getPlugin(), Players.class).loadObjects();
user.sendMessage("commands.bentobox.migrate.migrated");
user.sendMessage(MIGRATED);
user.sendMessage("commands.bentobox.migrate.names");
new Database<>(getPlugin(), Names.class).loadObjects();
user.sendMessage("commands.bentobox.migrate.migrated");
user.sendMessage(MIGRATED);
// Migrate addons data
user.sendMessage("commands.bentobox.migrate.addons");
getPlugin().getAddonsManager().getDataObjects().forEach(t -> {
user.sendMessage("commands.bentobox.migrate.class", TextVariables.DESCRIPTION, t.getCanonicalName());
new Database<>(getPlugin(), t).loadObjects();
user.sendMessage("commands.bentobox.migrate.migrated");
user.sendMessage(MIGRATED);
});
});
return true;

View File

@ -71,7 +71,7 @@ public class SchemToBlueprint {
// Make a new blueprint bundle
BlueprintBundle bb = new BlueprintBundle();
// TODO: This is just placeholder text
if (name.equalsIgnoreCase("island")) {
if (name.equalsIgnoreCase(DEFAULT_SCHEM_NAME)) {
bb.setUniqueId(BlueprintsManager.DEFAULT_BUNDLE_NAME);
bb.setDisplayName(ChatColor.YELLOW + "The Original");
bb.setDescription(ChatColor.AQUA + "Standard set of islands");
@ -109,9 +109,9 @@ public class SchemToBlueprint {
try {
SchemLoader loader = new SchemLoader(plugin, schems);
loader.load(name);
plugin.log("Loaded " + name + ".schem");
plugin.log("Loaded " + name + FILE_EXTENSION);
// Convert blueprint
plugin.log("Converting " + name + ".schem to a blueprint");
plugin.log("Converting " + name + FILE_EXTENSION + " to a blueprint");
Blueprint bp = new Converter().convert(loader.getBlockConfig());
bp.setName(name);
plugin.log("Saving blueprint");