-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
4 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
common/src/main/java/it/mycraft/powerlib/common/configuration/ProviderRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package it.mycraft.powerlib.common.configuration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ProviderRegistry { | ||
|
||
private static final Map<Class<? extends ConfigurationProvider>, ConfigurationProvider> providers = new HashMap<>(); | ||
|
||
static { | ||
try { | ||
providers.put(YamlConfiguration.class, new YamlConfiguration()); | ||
} catch (NoClassDefFoundError ex) { | ||
// Ignore, no SnakeYAML | ||
} | ||
|
||
try { | ||
providers.put(JsonConfiguration.class, new JsonConfiguration()); | ||
} catch (NoClassDefFoundError ex) { | ||
// Ignore, no Gson | ||
} | ||
} | ||
|
||
public static ConfigurationProvider getProvider(Class<? extends ConfigurationProvider> provider) { | ||
return providers.get(provider); | ||
} | ||
} |