mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-30 21:17:49 +01:00
Updated VaultExtension
- Fixed economy call when player has no economy account - Adds support for permission groups Affects issues: - Fixed #1331
This commit is contained in:
parent
d2c72050dd
commit
d3fd60a92e
@ -29,7 +29,7 @@ dependencies {
|
||||
compile 'com.djrapitops:Extension-SuperbVote:0.5.4-R0.1'
|
||||
compile 'com.djrapitops:Extension-Tebex:R0.3'
|
||||
compile 'com.djrapitops:Extension-Towny:0.92.0.0-R0.1'
|
||||
compile 'com.djrapitops:Extension-Vault:1.7-R0.2'
|
||||
compile 'com.djrapitops:Extension-Vault:1.7-R0.3'
|
||||
compile 'com.djrapitops:Extension-ViaVersion:2.1.3-R1.2'
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.extension.extractor.ExtensionExtractor;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
@ -76,7 +77,7 @@ public class ExtensionRegister {
|
||||
register(new LitebansExtensionFactory(), LitebansExtensionFactory::createExtension, LitebansExtensionFactory::registerEvents);
|
||||
register(new LuckPermsExtensionFactory(), LuckPermsExtensionFactory::createExtension);
|
||||
register(new McMMOExtensionFactory(), McMMOExtensionFactory::createExtension);
|
||||
registerMinigameLibExtensions();
|
||||
registerMany(new MinigameLibExtensionFactory(), MinigameLibExtensionFactory::createExtensions);
|
||||
register(new NucleusExtensionFactory(), NucleusExtensionFactory::createExtension);
|
||||
register(new NuVotifierExtensionFactory(), NuVotifierExtensionFactory::createExtension);
|
||||
register(new ProtocolSupportExtensionFactory(), ProtocolSupportExtensionFactory::createExtension);
|
||||
@ -84,7 +85,7 @@ public class ExtensionRegister {
|
||||
register(new SpongeEconomyExtensionFactory(), SpongeEconomyExtensionFactory::createExtension);
|
||||
register(new SuperbVoteExtensionFactory(), SuperbVoteExtensionFactory::createExtension);
|
||||
register(new TownyExtensionFactory(), TownyExtensionFactory::createExtension);
|
||||
register(new VaultExtensionFactory(), VaultExtensionFactory::createExtension);
|
||||
registerMany(new VaultExtensionFactory(), VaultExtensionFactory::createExtensions);
|
||||
register(new ViaVersionExtensionFactory(), ViaVersionExtensionFactory::createExtension);
|
||||
|
||||
if (registerException != null) throw registerException;
|
||||
@ -99,12 +100,6 @@ public class ExtensionRegister {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerMinigameLibExtensions() {
|
||||
for (DataExtension minigame : new MinigameLibExtensionFactory().createExtensions()) {
|
||||
register(minigame);
|
||||
}
|
||||
}
|
||||
|
||||
private void suppressException(Class<?> factory, Throwable e) {
|
||||
String factoryName = factory.getSimpleName();
|
||||
String extensionName = factoryName.replace("ExtensionFactory", "");
|
||||
@ -151,6 +146,21 @@ public class ExtensionRegister {
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void registerMany(
|
||||
T factory,
|
||||
Function<T, Collection<DataExtension>> createExtension
|
||||
) {
|
||||
try {
|
||||
// Creates the extension with factory and registers it
|
||||
createExtension.apply(factory).forEach(this::register);
|
||||
} catch (NotReadyException ignore) {
|
||||
// This exception signals that the extension can not be registered right now (Intended fail).
|
||||
} catch (Exception | NoClassDefFoundError | IncompatibleClassChangeError e) {
|
||||
// Places all exceptions to one exception with plugin information so that they can be reported.
|
||||
suppressException(factory.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void register(
|
||||
T factory,
|
||||
Function<T, Optional<DataExtension>> createExtension,
|
||||
|
Loading…
Reference in New Issue
Block a user