use of org.lanternpowered.server.service.permission.LanternContextCalculator in project LanternServer by LanternPowered.
the class LanternGame method initialize.
public void initialize() throws IOException {
final LanternMinecraftVersion versionCacheEntry = this.minecraftVersionCache.getVersionOrUnknown(Protocol.CURRENT_VERSION, false);
if (!LanternMinecraftVersion.CURRENT.equals(versionCacheEntry)) {
throw new RuntimeException("The current version and version in the cache don't match: " + LanternMinecraftVersion.CURRENT + " != " + versionCacheEntry);
}
// Load the plugin instances
try {
// By default, use the '--scanClasspath <true|false>' option, if it can't
// be found, fall back to a environment based decision
Boolean scanClasspath = this.scanClasspath;
if (scanClasspath == null) {
scanClasspath = Environment.get() == Environment.DEVELOPMENT;
}
this.pluginManager.loadPlugins(scanClasspath);
} catch (IOException e) {
throw new RuntimeException("An error occurred while loading the plugins.", e);
}
this.gameRegistry.registerDefaults();
this.gameRegistry.earlyRegistry();
// Load the global configuration
this.globalConfig.load();
// Save missing settings
this.globalConfig.save();
// They should not be replaced by now
this.whitelistService.extended(WhitelistConfig.class).get().load();
this.banService.extended(BanConfig.class).get().load();
// Create the event manager instance
this.eventManager.registerListeners(this.implContainer, LanternServiceListeners.getInstance());
this.pluginManager.registerPluginInstances();
// Call pre registry phase.
this.gameRegistry.preRegistry();
// Register temporarily a empty rcon service
registerService(RconService.class, new EmptyRconService(this.globalConfig.getRconPassword()));
// Create the cause to post events...
final CauseStack causeStack = CauseStack.current();
causeStack.pushCause(this);
final Cause gameCause = causeStack.getCurrentCause();
// Call the construction events
postGameStateChange(SpongeEventFactory.createGameConstructionEvent(gameCause));
// Call pre init phase for registry
this.gameRegistry.preInit();
LanternServiceListeners.getInstance().registerServiceCallback(PermissionService.class, input -> {
this.server.getConsole().getContainingCollection();
input.registerContextCalculator(new LanternContextCalculator());
});
// Pre-init phase
postGameStateChange(SpongeEventFactory.createGamePreInitializationEvent(gameCause));
// Call init phase for registry
this.gameRegistry.init();
final PermissionService permissionService = this.permissionService.get();
if (permissionService instanceof LanternPermissionService) {
final LanternPermissionService service = (LanternPermissionService) permissionService;
service.getGroupForOpLevel(Permissions.SELECTOR_LEVEL).getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, Permissions.SELECTOR_PERMISSION, Tristate.TRUE);
service.getGroupForOpLevel(Permissions.COMMAND_BLOCK_LEVEL).getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, Permissions.COMMAND_BLOCK_PERMISSION, Tristate.TRUE);
service.getGroupForOpLevel(Permissions.Login.BYPASS_PLAYER_LIMIT_LEVEL).getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, Permissions.Login.BYPASS_PLAYER_LIMIT_PERMISSION, Tristate.FALSE);
service.getGroupForOpLevel(Permissions.Login.BYPASS_WHITELIST_LEVEL).getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, Permissions.Login.BYPASS_WHITELIST_PERMISSION, Tristate.TRUE);
service.getGroupForOpLevel(Permissions.Chat.FORMAT_URLS_LEVEL).getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, Permissions.Chat.FORMAT_URLS, Tristate.TRUE);
}
// Load the default commands
this.injector.getInstance(DefaultCommandsCollection.class).load();
// Init phase
postGameStateChange(SpongeEventFactory.createGameInitializationEvent(gameCause));
// Call post init phase for registry
this.gameRegistry.postInit();
// Post-init phase
postGameStateChange(SpongeEventFactory.createGamePostInitializationEvent(gameCause));
// Load-complete phase
postGameStateChange(SpongeEventFactory.createGameLoadCompleteEvent(gameCause));
// Pop off the game instance
causeStack.popCause();
}
Aggregations