org.spongepowered.api.event.game.state.GameAboutToStartServerEvent Java Examples
The following examples show how to use
org.spongepowered.api.event.game.state.GameAboutToStartServerEvent.
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: SpongePlugin.java From BungeeTabListPlus with GNU General Public License v3.0 | 6 votes |
@Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) { // register plugin message channel channel = game.getChannelRegistrar().createRawChannel(this, BridgeProtocolConstants.CHANNEL); channel.addListener(Platform.Type.SERVER, (data, connection, side) -> { if (connection instanceof PlayerConnection) { Player player = ((PlayerConnection) connection).getPlayer(); DataInput input = new DataInputStream(new ChannelBufInputStream(data)); try { bridge.onMessage(player, input); } catch (Throwable e) { rlExecutor.execute(() -> { logger.error("Unexpected error", e); }); } } }); // init bridge initBridge(); }
Example #2
Source File: SpongePlugin.java From ViaVersion with MIT License | 5 votes |
@Listener public void onServerStart(GameAboutToStartServerEvent event) { if (game.getPluginManager().getPlugin("ViaBackwards").isPresent()) { MappingDataLoader.enableMappingsCache(); } // Inject! logger.info("ViaVersion is injecting!"); Via.getManager().init(); }
Example #3
Source File: GriefPreventionPlugin.java From GriefPrevention with MIT License | 4 votes |
@Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) { if (!validateSpongeVersion()) { return; } if (this.permissionService == null) { this.logger.error("Unable to initialize plugin. GriefPrevention requires a permissions plugin such as LuckPerms."); return; } this.loadConfig(); this.customLogger = new CustomLogger(); this.executor = Executors.newFixedThreadPool(GriefPreventionPlugin.getGlobalConfig().getConfig().thread.numExecutorThreads); this.economyService = Sponge.getServiceManager().provide(EconomyService.class); if (Sponge.getPluginManager().getPlugin("mcclans").isPresent()) { this.clanApiProvider = new MCClansApiProvider(); } if (Sponge.getPluginManager().getPlugin("nucleus").isPresent()) { this.nucleusApiProvider = new NucleusApiProvider(); } if (Sponge.getPluginManager().getPlugin("worldedit").isPresent() || Sponge.getPluginManager().getPlugin("fastasyncworldedit").isPresent()) { this.worldEditProvider = new WorldEditApiProvider(); } if (this.dataStore == null) { try { this.dataStore = new FlatFileDataStore(); // Migrator currently only handles pixelmon // Remove pixelmon check after GP 5.0.0 update if (Sponge.getPluginManager().getPlugin("pixelmon").isPresent()) { if (this.dataStore.getMigrationVersion() < DataStore.latestMigrationVersion) { GPPermissionMigrator.getInstance().migrateSubject(GLOBAL_SUBJECT); permissionService.getUserSubjects().applyToAll(GPPermissionMigrator.getInstance().migrateSubjectPermissions()); permissionService.getGroupSubjects().applyToAll(GPPermissionMigrator.getInstance().migrateSubjectPermissions()); this.dataStore.setMigrationVersion(DataStore.latestMigrationVersion); } } this.dataStore.initialize(); } catch (Exception e) { this.getLogger().info("Unable to initialize the file system data store. Details:"); this.getLogger().info(e.getMessage()); e.printStackTrace(); return; } } String dataMode = (this.dataStore instanceof FlatFileDataStore) ? "(File Mode)" : "(Database Mode)"; Sponge.getEventManager().registerListeners(this, new BlockEventHandler(dataStore)); Sponge.getEventManager().registerListeners(this, new PlayerEventHandler(dataStore, this)); Sponge.getEventManager().registerListeners(this, new EntityEventHandler(dataStore)); Sponge.getEventManager().registerListeners(this, new WorldEventHandler()); if (this.nucleusApiProvider != null) { Sponge.getEventManager().registerListeners(this, new NucleusEventHandler()); this.nucleusApiProvider.registerTokens(); } if (this.clanApiProvider != null) { Sponge.getEventManager().registerListeners(this, new MCClansEventHandler()); } addLogEntry("Finished loading data " + dataMode + "."); PUBLIC_USER = Sponge.getServiceManager().provide(UserStorageService.class).get() .getOrCreate(GameProfile.of(GriefPreventionPlugin.PUBLIC_UUID, GriefPreventionPlugin.PUBLIC_NAME)); WORLD_USER = Sponge.getServiceManager().provide(UserStorageService.class).get() .getOrCreate(GameProfile.of(GriefPreventionPlugin.WORLD_USER_UUID, GriefPreventionPlugin.WORLD_USER_NAME)); // run cleanup task int cleanupTaskInterval = GriefPreventionPlugin.getGlobalConfig().getConfig().claim.expirationCleanupInterval; if (cleanupTaskInterval > 0) { CleanupUnusedClaimsTask cleanupTask = new CleanupUnusedClaimsTask(); Sponge.getScheduler().createTaskBuilder().delay(cleanupTaskInterval, TimeUnit.MINUTES).execute(cleanupTask) .submit(GriefPreventionPlugin.instance); } // if economy is enabled if (this.economyService.isPresent()) { GriefPreventionPlugin.addLogEntry("GriefPrevention economy integration enabled."); GriefPreventionPlugin.addLogEntry( "Hooked into economy: " + Sponge.getServiceManager().getRegistration(EconomyService.class).get().getPlugin().getId() + "."); GriefPreventionPlugin.addLogEntry("Ready to buy/sell claim blocks!"); } // load ignore lists for any already-online players Collection<Player> players = Sponge.getGame().getServer().getOnlinePlayers(); for (Player player : players) { new IgnoreLoaderThread(player.getUniqueId(), this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()).ignoredPlayers) .start(); } // TODO - rewrite /gp command //Sponge.getGame().getCommandManager().register(this, CommandGriefPrevention.getCommand().getCommandSpec(), //CommandGriefPrevention.getCommand().getAliases()); registerBaseCommands(); this.dataStore.loadClaimTemplates(); }