org.spongepowered.api.event.game.state.GameStartedServerEvent Java Examples

The following examples show how to use org.spongepowered.api.event.game.state.GameStartedServerEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VirtualChestPlugin.java    From VirtualChest with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Listener
public void onStartedServer(GameStartedServerEvent event)
{
    try
    {
        this.logger.info("Start loading config ...");
        this.loadConfig();
        this.saveConfig();
        this.logger.info("Loading config complete.");
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
    this.addMetricsInformation();
}
 
Example #2
Source File: NuVotifier.java    From NuVotifier with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onServerStart(GameStartedServerEvent event) {
    this.scheduler = new SpongeScheduler(this);
    this.loggerAdapter = new SLF4JLogger(logger);

    CommandSpec nvreloadSpec = CommandSpec.builder()
            .description(Text.of("Reloads NuVotifier"))
            .permission("nuvotifier.reload")
            .executor(new NVReloadCmd(this)).build();

    Sponge.getCommandManager().register(this, nvreloadSpec, "nvreload");

    CommandSpec testvoteSpec = CommandSpec.builder()
            .arguments(GenericArguments.allOf(GenericArguments.string(Text.of("args"))))
            .description(Text.of("Sends a test vote to the server's listeners"))
            .permission("nuvotifier.testvote")
            .executor(new TestVoteCmd(this)).build();

    Sponge.getCommandManager().register(this, testvoteSpec, "testvote");

    if (!loadAndBind()) {
        gracefulExit();
    }
}
 
Example #3
Source File: SkinsRestorer.java    From SkinsRestorerX with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onServerStarted(GameStartedServerEvent event) {
    if (!Sponge.getServer().getOnlineMode()) {
        Sponge.getEventManager().registerListener(this, ClientConnectionEvent.Auth.class, new LoginListener(this));
    }

    metrics.addCustomChart(new Metrics2.SingleLineChart("mineskin_calls", MetricsCounter::collectMineskin_calls));
    metrics.addCustomChart(new Metrics2.SingleLineChart("minetools_calls", MetricsCounter::collectMinetools_calls));
    metrics.addCustomChart(new Metrics2.SingleLineChart("mojang_calls", MetricsCounter::collectMojang_calls));
    metrics.addCustomChart(new Metrics2.SingleLineChart("backup_calls", MetricsCounter::collectBackup_calls));
}
 
Example #4
Source File: UChatBungee.java    From UltimateChat with GNU General Public License v3.0 5 votes vote down vote up
public UChatBungee(UChat plugin) {
    Sponge.getEventManager().registerListener(plugin.instance(), GameStartedServerEvent.class, (event) -> {
        this.chan = Sponge.getChannelRegistrar().createRawChannel(plugin.instance(), "bungee:uchat");
        this.listener = this;
        this.chan.addListener(Platform.Type.SERVER, this.listener);
    });
}
 
Example #5
Source File: UChat.java    From UltimateChat with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onServerStart(GameStartedServerEvent event) {
    this.bungee = new UChatBungee(get());

    if (this.UCJDA != null) {
        this.UCJDA.sendRawToDiscord(lang.get("discord.online"));
    }
}
 
Example #6
Source File: Prism.java    From Prism with MIT License 5 votes vote down vote up
@Listener
public void onStartedServer(GameStartedServerEvent event) {
    String engine = getConfig().getStorageCategory().getEngine();
    try {
        if (StringUtils.equalsIgnoreCase(engine, "h2")) {
            storageAdapter = new H2StorageAdapter();
        } else if (StringUtils.equalsAnyIgnoreCase(engine, "mongo", "mongodb")) {
            storageAdapter = new MongoStorageAdapter();
        } else if (StringUtils.equalsIgnoreCase(engine, "mysql")) {
            storageAdapter = new MySQLStorageAdapter();
        } else {
            throw new Exception("Invalid storage engine configured.");
        }

        Preconditions.checkState(getStorageAdapter().connect());

        // Initialize the recording queue manager
        Task.builder()
                .async()
                .name("PrismRecordingQueueManager")
                .interval(1, TimeUnit.SECONDS)
                .execute(recordingQueueManager)
                .submit(getPluginContainer());
        getLogger().info("Prism started successfully. Bad guys beware.");
    } catch (Exception ex) {
        Sponge.getEventManager().unregisterPluginListeners(getPluginContainer());
        getLogger().error("Encountered an error processing {}::onStartedServer", "Prism", ex);
    }
}
 
Example #7
Source File: GeyserSpongePlugin.java    From Geyser with MIT License 4 votes vote down vote up
@Listener
public void onServerStart(GameStartedServerEvent event) {
    onEnable();
}
 
Example #8
Source File: SpongeSparkPlugin.java    From spark with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onEnable(GameStartedServerEvent event) {
    this.platform = new SparkPlatform(this);
    this.platform.enable();
    this.game.getCommandManager().register(this, new SparkCommand(this), "spark");
}
 
Example #9
Source File: ExamplePlugin.java    From bStats-Metrics with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Listener
public void onServerStart(GameStartedServerEvent event) {
    metrics.addCustomChart(new Metrics2.SimplePie("chart_id", () -> "My value"));
}
 
Example #10
Source File: PlanSponge.java    From Plan with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Listener
public void onServerStart(GameStartedServerEvent event) {
    onEnable();
}
 
Example #11
Source File: NationsPlugin.java    From Nations with MIT License 4 votes vote down vote up
@Listener
public void onStart(GameStartedServerEvent event)
{
	LanguageHandler.load();
	ConfigHandler.load();
	DataHandler.load();
	
	Sponge.getServiceManager()
			.getRegistration(EconomyService.class)
			.ifPresent(prov -> economyService = prov.getProvider());


	NationCmds.create(this);

	Sponge.getEventManager().registerListeners(this, new PlayerConnectionListener());
	Sponge.getEventManager().registerListeners(this, new PlayerMoveListener());
	Sponge.getEventManager().registerListeners(this, new GoldenAxeListener());
	Sponge.getEventManager().registerListeners(this, new PvpListener());
	Sponge.getEventManager().registerListeners(this, new FireListener());
	Sponge.getEventManager().registerListeners(this, new ExplosionListener());
	Sponge.getEventManager().registerListeners(this, new MobSpawningListener());
	Sponge.getEventManager().registerListeners(this, new BuildPermListener());
	Sponge.getEventManager().registerListeners(this, new InteractPermListener());
	Sponge.getEventManager().registerListeners(this, new ChatListener());

	LocalDateTime localNow = LocalDateTime.now();
	ZonedDateTime zonedNow = ZonedDateTime.of(localNow, ZoneId.systemDefault());
	ZonedDateTime zonedNext = zonedNow.withHour(12).withMinute(0).withSecond(0);
	if (zonedNow.compareTo(zonedNext) > 0)
		zonedNext = zonedNext.plusDays(1);
	long initalDelay = Duration.between(zonedNow, zonedNext).getSeconds();

	Sponge.getScheduler()
			.createTaskBuilder()
			.execute(new TaxesCollectRunnable())
			.delay(initalDelay, TimeUnit.SECONDS)
			.interval(1, TimeUnit.DAYS)
			.async()
			.submit(this);

	logger.info("Plugin ready");
}
 
Example #12
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onServerStart(GameStartedServerEvent event) {
    notifyHooks(WebHookService.WebHookType.SERVER_START, event);
}
 
Example #13
Source File: RedProtect.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onServerStart(GameStartedServerEvent event) {
    try {
        String v = Sponge.getGame().getPlatform().getContainer(Component.API).getVersion().orElse("0");

        instance = this;
        commandManager = Sponge.getGame().getCommandManager();

        ph = new PermissionHandler();
        rm = new RegionManager();

        // Init schematic
        schematic = new RPSchematics();

        //Init config, lang, listeners and flags
        startLoad();

        if (v.startsWith("7")) {
            rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.VersionHelper7").newInstance();
            Sponge.getGame().getEventManager().registerListeners(container, Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener7").newInstance());
        } else if (v.startsWith("8")) {
            Sponge.getGame().getEventManager().registerListeners(container, Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener8").newInstance());
            rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.VersionHelper8").newInstance();
        } else {
            Sponge.getGame().getEventManager().registerListeners(container, Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.listeners.BlockListenerCompat56").newInstance());
            rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.helpers.VersionHelper56").newInstance();
        }

        logger.info("Loading API...");
        this.redProtectAPI = new RedProtectAPI();
        logger.info("API Loaded!");

        logger.info("Sponge version: " + v);
        logger.clear("\n" +
                "&4 _   _  _  &c _   _   _  _ _  _  _ _ _  __\n" +
                "&4|_| |_ | \\ &c|_| |_| | |  |  |_ |   |    / \n" +
                "&4| \\ |_ |_/ &c|   | \\ |_|  |  |_ |_  |   /\n" +
                "&a¯ Redprotect " + container.getVersion().get() + " enabled\n" +
                "");

    } catch (Exception e) {
        CoreUtil.printJarVersion();
        e.printStackTrace();

        Sponge.getGame().getServer().setHasWhitelist(true);
        Sponge.getGame().getServer().getOnlinePlayers().forEach(Player::kick);

        logger.severe("Error enabling RedProtect, plugin will shut down.");
        logger.severe("Due to an error in RedProtect loading, the whitelist has been turned on and every player has been kicked.");
        logger.severe("DO NOT LET ANYONE ENTER before fixing the problem, otherwise you risk losing protected regions.");
    }
}