本文整理匯總了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);
}
示例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());
}
示例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());
}
示例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;
}
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
}
}
示例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);
}
示例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!");
}
}
}
}
示例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();
}
示例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);
}
}
示例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());
}
}