use of com.sk89q.worldguard.protection.managers.storage.RegionDatabase in project WorldGuard by EngineHub.
the class DirectoryYamlDriver method getAll.
@Override
public List<RegionDatabase> getAll() throws StorageException {
List<RegionDatabase> stores = new ArrayList<>();
File[] files = rootDir.listFiles();
if (files != null) {
for (File dir : files) {
if (dir.isDirectory() && new File(dir, "regions.yml").isFile()) {
stores.add(new YamlRegionFile(dir.getName(), getPath(dir.getName())));
}
}
}
return stores;
}
use of com.sk89q.worldguard.protection.managers.storage.RegionDatabase in project WorldGuard by EngineHub.
the class DriverMigration method write.
private void write(String name, Set<ProtectedRegion> regions) throws MigrationException {
log.info("Saving the data for '" + name + "' with the new driver...");
RegionDatabase store = target.get(name);
try {
store.saveAll(regions);
} catch (StorageException e) {
throw new MigrationException("Failed to save region data for '" + store.getName() + "' to the new driver", e);
}
}
use of com.sk89q.worldguard.protection.managers.storage.RegionDatabase in project WorldGuard by EngineHub.
the class RegionContainerImpl method createAndLoad.
/**
* Create a new region manager and load the data.
*
* @param name the name of the world
* @return a region manager
* @throws StorageException thrown if loading fals
*/
private RegionManager createAndLoad(String name) throws StorageException {
RegionDatabase store = driver.get(name);
RegionManager manager = new RegionManager(store, indexFactory, flagRegistry);
// Try loading, although it may fail
manager.load();
return manager;
}
use of com.sk89q.worldguard.protection.managers.storage.RegionDatabase in project WorldGuard by EngineHub.
the class SQLDriver method getAll.
@Override
public List<RegionDatabase> getAll() throws StorageException {
Closer closer = Closer.create();
try {
List<RegionDatabase> stores = new ArrayList<>();
Connection connection = closer.register(getConnection());
Statement stmt = connection.createStatement();
ResultSet rs = closer.register(stmt.executeQuery("SELECT name FROM " + config.getTablePrefix() + "world"));
while (rs.next()) {
stores.add(get(rs.getString(1)));
}
return stores;
} catch (SQLException e) {
throw new StorageException("Failed to fetch list of worlds", e);
} finally {
closer.closeQuietly();
}
}
Aggregations