當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。