当前位置: 首页>>代码示例>>Java>>正文


Java ClientConnectionEvent.Disconnect方法代码示例

本文整理汇总了Java中org.spongepowered.api.event.network.ClientConnectionEvent.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:Java ClientConnectionEvent.Disconnect方法的具体用法?Java ClientConnectionEvent.Disconnect怎么用?Java ClientConnectionEvent.Disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.event.network.ClientConnectionEvent的用法示例。


在下文中一共展示了ClientConnectionEvent.Disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerLeave

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerLeave(ClientConnectionEvent.Disconnect event, @Root Player player) {
	Date now = new Date(java.util.Date.from(Instant.now()).getTime());
	UserData userData = dataStore.getOrCreateUserData(player);

	int index[] = new int[1];
	index[0] = 0;
	dataStore.getPlayerRegions(player.getUniqueId()).forEach(region -> {
		if (region.getType() == LoadedRegion.ChunkType.PERSONAL) {
			region.unForceChunks();
			index[0]++;
		}
	});

	logger.info(String.format("Unloaded %s chunks for %s", index[0], player.getName()));

	// Update the userData in case it's an existing userData
	dataStore.getOrCreateUserData(player).setLastSeen(now).update();
	database.saveUserData(userData);
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:21,代码来源:PlayerConnectionListener.java

示例2: onClientConnectionEvent

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
/**
 * Supprime le joueur de la liste
 */
@Listener
public void onClientConnectionEvent(final ClientConnectionEvent.Disconnect event, @Getter("getTargetEntity") Player player_sponge) {
	EPlayer player = this.plugin.getEverAPI().getEServer().getEPlayer(event.getTargetEntity());
		
	// Jail
	Optional<SanctionJail> optSanction = player.getJail();
	if (optSanction.isPresent()) {
		Optional<Jail> jail = optSanction.get().getJail();
		if (jail.isPresent() && player.getBack().isPresent()) {
			player.setTransform(player.getBack().get());
		}
	}
	
	this.plugin.getSanctionService().removePlayer(event.getTargetEntity().getUniqueId());
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:19,代码来源:ESListener.java

示例3: onPlayerQuit

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerQuit(final ClientConnectionEvent.Disconnect event) {
    // Skip if Player isn't online. Banned, non-whitelisted, etc players trigger Disconnect too
    if (!Bedrock.getGame().getServer().getOnlinePlayers().contains(event.getTargetEntity())) {
        event.setMessageCancelled(true);
        return;
    }

    // AFK
    Bedrock.getAFKManager().clear(event.getTargetEntity());

    // Config
    Bedrock.getPlayerConfigManager().unload(event.getTargetEntity());

    // Jail
    Bedrock.getJailManager().clear(event.getTargetEntity());

    // Messaging
    Bedrock.getMessageManager().clear(event.getTargetEntity());
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:21,代码来源:DisconnectListener.java

示例4: onPlayerQuit

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onPlayerQuit(ClientConnectionEvent.Disconnect event) {
    Optional<Challenger> ch = CommonCore.getChallenger(event.getTargetEntity().getUniqueId());
    if (ch.isPresent()) {
        // store the player to disk so their inventory and location can be popped later
        ((InfernoRound) ch.get().getRound()).removeChallenger(ch.get(), true, true);

        CommonPlayerHelper.setOfflineFlag(event.getTargetEntity().getUniqueId());
    }

    for (Minigame mg : CommonCore.getMinigames().values()) {
        if (((InfernoMinigame) mg).getLobbyWizardManager().hasPlayer(event.getTargetEntity().getUniqueId())) {
            ((InfernoMinigame) mg).getLobbyWizardManager().removePlayer(event.getTargetEntity().getUniqueId());
            break;
        }
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:18,代码来源:PlayerConnectionListener.java

示例5: onPlayerQuit

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerQuit(ClientConnectionEvent.Disconnect event) {
	Player player = event.getTargetEntity();
	IActiveCharacter character = characterService.removeCachedWrapper(player.getUniqueId());
	if (!character.isStub()) {
		Location loc = player.getLocation();
		World ex = (World) loc.getExtent();
		character.getCharacterBase().setLastKnownPlayerName(event.getTargetEntity().getName());
		character.updateLastKnownLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockY(), ex.getName());
		characterService.putInSaveQueue(character.getCharacterBase());
		effectService.removeAllEffects(character);
		/*Always reset the persistent properties back to vanilla values in a case
            some dummy decides to remove my awesome plugin :C */
		Utils.resetPlayerToDefault(player);
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:17,代码来源:EntityLifecycleListener.java

示例6: onLogout

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onLogout(ClientConnectionEvent.Disconnect event) {
  try (Connection con = SQLHandle.getConnection()) {
    DSLContext create = DSL.using(con);

    UUID uuid = event.getTargetEntity().getUniqueId();
    long diff = System.currentTimeMillis() - sessionStartTime.remove(uuid);
    long diffSeconds = TimeUnit.MILLISECONDS.toSeconds(diff);

    create.update(PLAYERS).set(PLAYERS.SECONDS_PLAYED, PLAYERS.SECONDS_PLAYED.add(diffSeconds)).where(
        PLAYERS.UUID.equal(uuid.toString())
    ).execute();
  } catch (SQLException e) {
    e.printStackTrace();
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:DatabaseServiceImpl.java

示例7: onPlayerLeave

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerLeave(ClientConnectionEvent.Disconnect event) throws IOException {
	@NonNull
	Player player = event.getTargetEntity();
	UUID uuid = player.getUniqueId();

	savePlayer(player);

	synchronized (waitingPlayers) {
		if (waitingPlayers.containsKey(uuid)) {
			waitingPlayers.remove(uuid).cancel();
		}
	}
}
 
开发者ID:AuraDevelopmentTeam,项目名称:InvSync,代码行数:15,代码来源:PlayerEvents.java

示例8: onClientConnectionDisconnect

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onClientConnectionDisconnect(ClientConnectionEvent.Disconnect event) {
    ClanPlayerImpl clanPlayer = ClansImpl.getInstance().getClanPlayer(event.getTargetEntity().getUniqueId());
    if (clanPlayer != null) {
        clanPlayer.setLastOnline(new LastOnlineImpl());
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:8,代码来源:ClientConnectionListener.java

示例9: onClientDisconnect

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onClientDisconnect(ClientConnectionEvent.Disconnect e) {
    if (playerJoins.containsKey(e.getTargetEntity().getUniqueId())) {
        playerSession.add(getPlayerSession(e.getTargetEntity()));
        playerJoins.remove(e.getTargetEntity().getUniqueId());
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:8,代码来源:SpongeStats.java

示例10: onDisconnect

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onDisconnect(ClientConnectionEvent.Disconnect event, @Getter("getTargetEntity") Player player) {
    // Remove the player from the mapping, other reasons why the player would be removed
    // are unknown.
    for (final Iterator<Map.Entry<PlayerWrapper, Trail>> iterator = this.playerTrails.entrySet().iterator(); iterator.hasNext(); ) {
        final Map.Entry<PlayerWrapper, Trail> next = iterator.next();
        if (next.getKey().playerId.equals(player.getUniqueId())) {
            iterator.remove();
            break;
        }
    }

}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:14,代码来源:HappyTrails.java

示例11: part

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void part(ClientConnectionEvent.Disconnect event) {
	Locale lang = playerLang.get(event.getTargetEntity().getUniqueId());
	event.getTargetEntity().getProfile().getPropertyMap().removeAll("language");
	event.getTargetEntity().getProfile().addProperty(ProfileProperty.of("language", lang.toString()));
	playerLang.remove(event.getTargetEntity().getUniqueId());

	unloadLangIfUnused(lang);
}
 
开发者ID:DosMike,项目名称:LangSwitch,代码行数:10,代码来源:LangSwitch.java

示例12: onDisconnect

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onDisconnect(ClientConnectionEvent.Disconnect event) {
    DiscordBridge mod = DiscordBridge.getInstance();
    GlobalConfig config = mod.getConfig();

    Optional<Player> player = event.getCause().first(Player.class);
    if (player.isPresent()) {
        UUID playerId = player.get().getUniqueId();

        DiscordAPI client = mod.getHumanClients().get(playerId);
        if (client == null) client = mod.getBotClient();
        if (client != null) {
            for (ChannelConfig channelConfig : config.channels) {
                if (StringUtils.isNotBlank(channelConfig.discordId)
                        && channelConfig.discord != null
                        && StringUtils.isNotBlank(channelConfig.discord.leftTemplate)) {
                    Channel channel = client.getChannelById(channelConfig.discordId);
                    if (channel != null) {
                        String content = String.format(channelConfig.discord.leftTemplate,
                                TextUtil.escapeForDiscord(player.get().getName(), channelConfig.discord.leftTemplate, "%s"));
                        ChannelUtil.sendMessage(channel, content);
                    } else {
                        ErrorMessages.CHANNEL_NOT_FOUND.log(channelConfig.discordId);
                    }
                }
                mod.removeAndLogoutClient(playerId);
                //unauthenticatedPlayers.remove(playerId);
                mod.getLogger().info(player.get().getName() + " has disconnected!");
            }
        }
    }
}
 
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:33,代码来源:ClientConnectionListener.java

示例13: onDisconnect

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onDisconnect(ClientConnectionEvent.Disconnect evt, @Root Player player) {
    PlayerDisconnectsScriptEvent event = (PlayerDisconnectsScriptEvent) clone();
    event.internal = evt;
    event.player = new PlayerTag(player);
    event.message = new FormattedTextTag(evt.getMessage());
    event.run();
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:9,代码来源:PlayerDisconnectsScriptEvent.java

示例14: onPlayerLeave

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerLeave(ClientConnectionEvent.Disconnect event)
{
	if (event.getTargetEntity() instanceof Player)
	{
		Player player = (Player) event.getTargetEntity();
		DataHandler.removeFirstPoint(player.getUniqueId());
		DataHandler.removeSecondPoint(player.getUniqueId());
		Nation nation = DataHandler.getNationOfPlayer(player.getUniqueId());
		if (nation != null)
			nation.getMessageChannel().removeMember(player);
		DataHandler.getSpyChannel().removeMember(player);
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:15,代码来源:PlayerConnectionListener.java

示例15: onPlayerQuit

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerQuit(ClientConnectionEvent.Disconnect event) {
    if (WIZARDS.containsKey(event.getTargetEntity().getUniqueId())) {
        WIZARDS.remove(event.getTargetEntity().getUniqueId());
        WIZARD_INFO.remove(event.getTargetEntity().getUniqueId());
    }
}
 
开发者ID:caseif,项目名称:InfernoSpleef,代码行数:8,代码来源:PlayerListener.java


注:本文中的org.spongepowered.api.event.network.ClientConnectionEvent.Disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。