Search in sources :

Example 1 with EmptyRconService

use of org.lanternpowered.server.network.rcon.EmptyRconService 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();
}
Also used : PermissionService(org.spongepowered.api.service.permission.PermissionService) LanternPermissionService(org.lanternpowered.server.service.permission.LanternPermissionService) LanternCauseStack(org.lanternpowered.server.event.LanternCauseStack) CauseStack(org.lanternpowered.server.event.CauseStack) LanternMinecraftVersion(org.lanternpowered.server.game.version.LanternMinecraftVersion) EmptyRconService(org.lanternpowered.server.network.rcon.EmptyRconService) LanternPermissionService(org.lanternpowered.server.service.permission.LanternPermissionService) Cause(org.spongepowered.api.event.cause.Cause) DefaultCommandsCollection(org.lanternpowered.server.command.DefaultCommandsCollection) IOException(java.io.IOException) LanternContextCalculator(org.lanternpowered.server.service.permission.LanternContextCalculator)

Aggregations

IOException (java.io.IOException)1 DefaultCommandsCollection (org.lanternpowered.server.command.DefaultCommandsCollection)1 CauseStack (org.lanternpowered.server.event.CauseStack)1 LanternCauseStack (org.lanternpowered.server.event.LanternCauseStack)1 LanternMinecraftVersion (org.lanternpowered.server.game.version.LanternMinecraftVersion)1 EmptyRconService (org.lanternpowered.server.network.rcon.EmptyRconService)1 LanternContextCalculator (org.lanternpowered.server.service.permission.LanternContextCalculator)1 LanternPermissionService (org.lanternpowered.server.service.permission.LanternPermissionService)1 Cause (org.spongepowered.api.event.cause.Cause)1 PermissionService (org.spongepowered.api.service.permission.PermissionService)1