mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-06 02:51:32 +01:00
[Experimental] Also catch provider instanciation exceptions
This commit is contained in:
parent
8793add589
commit
51b52ac343
@ -17,15 +17,15 @@ public class SpawnerProviderFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SpawnerProvider getProvider() {
|
public SpawnerProvider getProvider() {
|
||||||
List<SpawnerProvider> availableProviders = Arrays.asList(
|
List<Class<? extends SpawnerProvider>> availableProviders = Arrays.asList(
|
||||||
new BlockMetaSpawnerProvider(),
|
BlockMetaSpawnerProvider.class,
|
||||||
new v1_8_R1SpawnerProvider(),
|
v1_8_R1SpawnerProvider.class,
|
||||||
new LegacyProvider()
|
LegacyProvider.class
|
||||||
);
|
);
|
||||||
SpawnerProvider finalProvider = null;
|
SpawnerProvider finalProvider = null;
|
||||||
for (SpawnerProvider provider : availableProviders) {
|
for (Class<? extends SpawnerProvider> providerClass : availableProviders) {
|
||||||
finalProvider = provider;
|
finalProvider = loadProvider(providerClass);
|
||||||
if (finalProvider.tryProvider()) {
|
if (finalProvider != null && finalProvider.tryProvider()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,4 +33,14 @@ public class SpawnerProviderFactory {
|
|||||||
ess.getLogger().info("Using " + finalProvider.getHumanName() + " as spawner provider.");
|
ess.getLogger().info("Using " + finalProvider.getHumanName() + " as spawner provider.");
|
||||||
return finalProvider;
|
return finalProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SpawnerProvider loadProvider(Class<? extends SpawnerProvider> providerClass) {
|
||||||
|
SpawnerProvider provider;
|
||||||
|
try {
|
||||||
|
provider = providerClass.newInstance();
|
||||||
|
return provider;
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user