/** * Get the preferred platform for handling a certain capability. Returns * null if none is available. * * @param capability the capability * @return the platform * @throws NoCapablePlatformException thrown if no platform is capable */ public synchronized Platform queryCapability(Capability capability) throws NoCapablePlatformException { Platform platform = preferences.get(checkNotNull(capability)); if (platform != null) { return platform; } else { if (preferences.isEmpty()) { // Use the first available if preferences have not been decided yet. if (platforms.isEmpty()) { // No platforms registered, this is being called too early! throw new NoCapablePlatformException("No platforms have been registered yet! Please wait until WorldEdit is initialized."); } return platforms.get(0); } throw new NoCapablePlatformException("No platform was found supporting " + capability.name()); } }