use of com.sk89q.worldguard.protection.managers.migration.UUIDMigration in project WorldGuard by EngineHub.
the class RegionContainer method autoMigrate.
/**
* Execute auto-migration.
*/
protected void autoMigrate() {
ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
if (config.migrateRegionsToUuid) {
RegionDriver driver = getDriver();
UUIDMigration migrator = new UUIDMigration(driver, WorldGuard.getInstance().getProfileService(), WorldGuard.getInstance().getFlagRegistry());
migrator.setKeepUnresolvedNames(config.keepUnresolvedNames);
try {
migrate(migrator);
WorldGuard.logger.info("Regions saved after UUID migration! This won't happen again unless " + "you change the relevant configuration option in WorldGuard's config.");
config.disableUuidMigration();
} catch (MigrationException e) {
WorldGuard.logger.log(Level.WARNING, "Failed to execute the migration", e);
}
}
}
use of com.sk89q.worldguard.protection.managers.migration.UUIDMigration in project WorldGuard by EngineHub.
the class RegionCommands method migrateUuid.
/**
* Migrate the region databases to use UUIDs rather than name.
*
* @param args the arguments
* @param sender the sender
* @throws CommandException any error
*/
@Command(aliases = { "migrateuuid" }, desc = "Migrate loaded databases to use UUIDs", max = 0)
public void migrateUuid(CommandContext args, Actor sender) throws CommandException {
// Check permissions
if (!getPermissionModel(sender).mayMigrateRegionNames()) {
throw new CommandPermissionsException();
}
LoggerToChatHandler handler = null;
Logger minecraftLogger = null;
if (sender instanceof LocalPlayer) {
handler = new LoggerToChatHandler(sender);
handler.setLevel(Level.ALL);
minecraftLogger = Logger.getLogger("com.sk89q.worldguard");
minecraftLogger.addHandler(handler);
}
try {
ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionDriver driver = container.getDriver();
UUIDMigration migration = new UUIDMigration(driver, WorldGuard.getInstance().getProfileService(), WorldGuard.getInstance().getFlagRegistry());
migration.setKeepUnresolvedNames(config.keepUnresolvedNames);
sender.print("Now performing migration... this may take a while.");
container.migrate(migration);
sender.print("Migration complete!");
} catch (MigrationException e) {
log.log(Level.WARNING, "Failed to migrate", e);
throw new CommandException("Error encountered while migrating: " + e.getMessage());
} finally {
if (minecraftLogger != null) {
minecraftLogger.removeHandler(handler);
}
}
}
Aggregations