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


Java ClientConnectionEvent类代码示例

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


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

示例1: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent event)
{

    if(event.getCause().root() instanceof Player)
    {
        Player player = (Player) event.getCause().root();

        if(PowerService.checkIfPlayerExists(player.getUniqueId()))
        {
            PowerService.increasePower(player.getUniqueId());
            return;
        }
        else
        {
            //Create player file and set power.
            PowerService.addPlayer(player.getUniqueId());
            PlayerService.setPlayerChunkPosition(player.getUniqueId(), player.getLocation().getChunkPosition());
            return;
        }

    }
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:24,代码来源:PlayerJoinListener.java

示例2: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join 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];
	dataStore.getPlayerRegions(player.getUniqueId()).forEach(region -> {
		if (region.getType() == LoadedRegion.ChunkType.PERSONAL)
			region.forceChunks();
		index[0]++;
	});

	logger.info(String.format("Loaded %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,代码行数:20,代码来源:PlayerConnectionListener.java

示例3: 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

示例4: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event, @Root Player player) {
    if (!player.hasPermission("iplog.bypasslogging")) {
        final Storage storage = IPLog.getPlugin().getStorage();

        final InetAddress ip = player.getConnection().getAddress().getAddress();
        final UUID uuid = player.getUniqueId();
        final LocalDateTime time = LocalDateTime.now();

        if (storage.isPresent(ip, uuid)) {
            storage.updateConnection(ip, uuid, time);
        } else {
            storage.addConnection(ip, uuid, time);
        }
    }
}
 
开发者ID:ichorpowered,项目名称:iplog,代码行数:17,代码来源:JoinListener.java

示例5: joined

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener(order=Order.FIRST)
public void joined(ClientConnectionEvent.Join event) {
	Player player = event.getTargetEntity();
	
	Collection<ProfileProperty> props = player.getProfile().getPropertyMap().get("language");
	Locale checkload = null;
	for (ProfileProperty prop : props)
		if (prop.getName().equalsIgnoreCase("language")) { 
			playerLang.put(player.getProfile().getUniqueId(), checkload=Locale.forLanguageTag(prop.getValue().replace('_', '-')));
			break;
		}
	
	//use geo location in the future? player.getLocale seems to stick to en_US
	if (checkload==null)
		playerLang.put(player.getProfile().getUniqueId(), checkload=player.getLocale());
	
	loadLang(checkload);
}
 
开发者ID:DosMike,项目名称:LangSwitch,代码行数:19,代码来源:LangSwitch.java

示例6: onJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onJoin(ClientConnectionEvent.Join e){
	Player p = e.getTargetEntity();

	if (!UChat.get().getConfig().root().general.persist_channels){
		UChat.get().getDefChannel().addMember(p);
	}

	if (UChat.get().getUCJDA() != null){
		UChat.get().getUCJDA().sendRawToDiscord(UChat.get().getLang().get("discord.join").replace("{player}", p.getName()));
		if (UChat.get().getConfig().root().discord.update_status){
			UChat.get().getUCJDA().updateGame(UChat.get().getLang().get("discord.game").replace("{online}", String.valueOf(Sponge.getServer().getOnlinePlayers().size())));
		}
	}
	if (UChat.get().getConfig().root().general.spy_enabled_onjoin && p.hasPermission("uchat.cmd.spy") && !UChat.isSpy.contains(p.getName())){
		UChat.isSpy.add(p.getName());
		UChat.get().getLang().sendMessage(p, "cmd.spy.enabled");
	}
}
 
开发者ID:FabioZumbi12,项目名称:UltimateChat,代码行数:20,代码来源:UCListener.java

示例7: onClientAuthMonitor

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener(order = Order.LAST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuthMonitor(ClientConnectionEvent.Auth e) {
    /* Listen to see if the event was cancelled after we initially handled the connection
       If the connection was cancelled here, we need to do something to clean up the data that was loaded. */

    // Check to see if this connection was denied at LOW.
    if (this.deniedAsyncLogin.remove(e.getProfile().getUniqueId())) {

        // This is a problem, as they were denied at low priority, but are now being allowed.
        if (e.isCancelled()) {
            this.plugin.getLog().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId());
            e.setCancelled(true);
        }
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:17,代码来源:SpongeConnectionListener.java

示例8: onClientLogin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
       At this point, the users data should be present and loaded.
       Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */

    final GameProfile player = e.getProfile();

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName());
    }

    final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));

    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(player.getUniqueId());

        this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:27,代码来源:SpongeConnectionListener.java

示例9: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onPlayerJoin(final ClientConnectionEvent.Join event) {
    Player player = event.getTargetEntity();

    // Create/load config
    Bedrock.getPlayerConfigManager().loadPlayer(player);

    // Is brand new?
    if (player.get(Keys.FIRST_DATE_PLAYED).get().equals(player.get(Keys.LAST_DATE_PLAYED).get())) {
        // Force spawn position because vanilla has a "fuzz" radius around spawn
        Location<World> spawn = player.getWorld().getLocation(player.getWorld().getProperties().getSpawnPosition());

        player.setLocation(spawn);

        MessageChannel.TO_ALL.send(Text.of(TextColors.GOLD, "Welcome ", TextColors.LIGHT_PURPLE,
            player.getName(),TextColors.GOLD, " to DHMC!"));
    }
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:19,代码来源:JoinListener.java

示例10: 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

示例11: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
	Player player = event.getTargetEntity();
	
	NamelessPlugin.LOGIN_TIME.put(player.getUniqueId(), System.currentTimeMillis());

	NamelessPlugin.getGame().getScheduler().createAsyncExecutor(NamelessPlugin.getInstance()).execute(() -> {
		NamelessPlayer namelessPlayer = new NamelessPlayer(player.getUniqueId(), NamelessPlugin.baseApiURL);
		if (namelessPlayer.exists()) {
			if (namelessPlayer.isValidated()) {
				// Only show notifications if the player has validated their account
				userGetNotifications(player);
			} else {
				// If the player has not validated their account they get informed.
				player.sendMessage(Message.ACCOUNT_NOT_VALIDATED.getMessage());
			}
			
			userGroupSync(player);
		}
	});
}
 
开发者ID:NamelessMC,项目名称:Nameless-Plugin,代码行数:22,代码来源:PlayerLogin.java

示例12: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event){
	Player player = event.getTargetEntity();

    if(!plugin.getAPIUrl().isEmpty()){
	    try {
			userFileCheck(player);
			userNameCheck(player);
		} catch (IOException e) {
			e.printStackTrace();
		}
	    userGetNotification(player);
	    userGroupSync(player);
	
   }
}
 
开发者ID:NamelessMC,项目名称:Nameless-Plugin,代码行数:17,代码来源:PlayerEventListener.java

示例13: 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

示例14: onPlayerJoin

import org.spongepowered.api.event.network.ClientConnectionEvent; //导入依赖的package包/类
@Listener(order=Order.FIRST)
public void onPlayerJoin(final ClientConnectionEvent.Join event) {		
	EPlayer player = this.plugin.getEServer().getEPlayer(event.getTargetEntity());
	
	// Corrige bug
	player.sendTitle(Title.CLEAR);
	player.getTabList().setHeaderAndFooter(null, null);
	
	this.plugin.getManagerService().getEScoreBoard().addPlayer(player);

	// Newbie
	if (player.getFirstDatePlayed() == player.getLastDatePlayed()) {
		player.setSpawnNewbie(true);
		player.setTransform(player.getSpawn());
	}
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EAListener.java

示例15: 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


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