Search in sources :

Example 1 with GameStoppingServerEvent

use of org.spongepowered.api.event.game.state.GameStoppingServerEvent in project Nucleus by NucleusPowered.

the class CoreListener method onServerAboutToStop.

@Listener
public void onServerAboutToStop(final GameStoppingServerEvent event) {
    plugin.getUserDataManager().getOnlineUsers().forEach(x -> x.getPlayer().ifPresent(y -> onPlayerQuit(x, y)));
    if (this.getKickOnStopMessage != null) {
        Iterator<Player> players = Sponge.getServer().getOnlinePlayers().iterator();
        while (players.hasNext()) {
            Player p = players.next();
            Text msg = this.getKickOnStopMessage.getForCommandSource(p);
            if (msg.isEmpty()) {
                p.kick();
            } else {
                p.kick(msg);
            }
        }
    }
}
Also used : Getter(org.spongepowered.api.event.filter.Getter) CoreUserDataModule(io.github.nucleuspowered.nucleus.modules.core.datamodules.CoreUserDataModule) URL(java.net.URL) GameStoppingServerEvent(org.spongepowered.api.event.game.state.GameStoppingServerEvent) CoreConfigAdapter(io.github.nucleuspowered.nucleus.modules.core.config.CoreConfigAdapter) InetAddress(java.net.InetAddress) Lists(com.google.common.collect.Lists) Text(org.spongepowered.api.text.Text) Order(org.spongepowered.api.event.Order) NucleusTextTemplate(io.github.nucleuspowered.nucleus.api.text.NucleusTextTemplate) IsCancelled(org.spongepowered.api.event.filter.IsCancelled) Task(org.spongepowered.api.scheduler.Task) ListenerBase(io.github.nucleuspowered.nucleus.internal.ListenerBase) CoreConfig(io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig) GameProfile(org.spongepowered.api.profile.GameProfile) Util(io.github.nucleuspowered.nucleus.Util) ServiceChangeListener(io.github.nucleuspowered.nucleus.internal.permissions.ServiceChangeListener) NucleusOnLoginEvent(io.github.nucleuspowered.nucleus.modules.core.events.NucleusOnLoginEvent) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) TextActions(org.spongepowered.api.text.action.TextActions) Location(org.spongepowered.api.world.Location) Nucleus(io.github.nucleuspowered.nucleus.Nucleus) User(org.spongepowered.api.entity.living.player.User) GameReloadEvent(org.spongepowered.api.event.game.GameReloadEvent) Iterator(java.util.Iterator) CommandSource(org.spongepowered.api.command.CommandSource) MalformedURLException(java.net.MalformedURLException) UniqueUserCountTransientModule(io.github.nucleuspowered.nucleus.modules.core.datamodules.UniqueUserCountTransientModule) CauseStackHelper(io.github.nucleuspowered.nucleus.util.CauseStackHelper) Sponge(org.spongepowered.api.Sponge) ModularUserService(io.github.nucleuspowered.nucleus.dataservices.modular.ModularUserService) PaginationService(org.spongepowered.api.service.pagination.PaginationService) Instant(java.time.Instant) ClientConnectionEvent(org.spongepowered.api.event.network.ClientConnectionEvent) Tristate(org.spongepowered.api.util.Tristate) Reloadable(io.github.nucleuspowered.nucleus.internal.interfaces.Reloadable) List(java.util.List) MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) NucleusFirstJoinEvent(io.github.nucleuspowered.nucleus.api.events.NucleusFirstJoinEvent) World(org.spongepowered.api.world.World) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) OnFirstLoginEvent(io.github.nucleuspowered.nucleus.modules.core.events.OnFirstLoginEvent) Listener(org.spongepowered.api.event.Listener) Player(org.spongepowered.api.entity.living.player.Player) Text(org.spongepowered.api.text.Text) ServiceChangeListener(io.github.nucleuspowered.nucleus.internal.permissions.ServiceChangeListener) Listener(org.spongepowered.api.event.Listener)

Aggregations

Lists (com.google.common.collect.Lists)1 Nucleus (io.github.nucleuspowered.nucleus.Nucleus)1 Util (io.github.nucleuspowered.nucleus.Util)1 NucleusFirstJoinEvent (io.github.nucleuspowered.nucleus.api.events.NucleusFirstJoinEvent)1 NucleusTextTemplate (io.github.nucleuspowered.nucleus.api.text.NucleusTextTemplate)1 ModularUserService (io.github.nucleuspowered.nucleus.dataservices.modular.ModularUserService)1 ListenerBase (io.github.nucleuspowered.nucleus.internal.ListenerBase)1 Reloadable (io.github.nucleuspowered.nucleus.internal.interfaces.Reloadable)1 MessageProvider (io.github.nucleuspowered.nucleus.internal.messages.MessageProvider)1 ServiceChangeListener (io.github.nucleuspowered.nucleus.internal.permissions.ServiceChangeListener)1 CoreConfig (io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig)1 CoreConfigAdapter (io.github.nucleuspowered.nucleus.modules.core.config.CoreConfigAdapter)1 CoreUserDataModule (io.github.nucleuspowered.nucleus.modules.core.datamodules.CoreUserDataModule)1 UniqueUserCountTransientModule (io.github.nucleuspowered.nucleus.modules.core.datamodules.UniqueUserCountTransientModule)1 NucleusOnLoginEvent (io.github.nucleuspowered.nucleus.modules.core.events.NucleusOnLoginEvent)1 OnFirstLoginEvent (io.github.nucleuspowered.nucleus.modules.core.events.OnFirstLoginEvent)1 CauseStackHelper (io.github.nucleuspowered.nucleus.util.CauseStackHelper)1 InetAddress (java.net.InetAddress)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1