java类org.bukkit.event.player.PlayerJoinEvent的实例源码

PlayerJoin.java 文件源码 项目:SkywarsSeries 阅读 26 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    event.setJoinMessage(null);

    if (!Skywars.getInstance().isSingleServerMode()) {
        player.setGameMode(GameMode.ADVENTURE);
        player.getInventory().clear();
        player.setMaxHealth(20);
        player.setHealth(player.getMaxHealth());
        player.setFoodLevel(25);

        player.teleport(Skywars.getInstance().getLobbyPoint());
    }
}
DefaultUpdateCallback.java 文件源码 项目:Uranium 阅读 22 收藏 0 点赞 0 评论 0
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    if (hasPermission(player)) {
        /*
        if (Uranium.isLegacy()) {
            player.sendMessage(ChatColor.YELLOW + "We're running on legacy version on Uranium, please update your version");
        }            
        if (!Uranium.isOfficial()) {
            player.sendMessage(ChatColor.YELLOW + "We're running on non-official version on Uranium, please update your version");
        }            
        if (mHasUpdate) {
            sendUpdate(player);
        }
        */
    }
}
LifeSystem.java 文件源码 项目:Locked 阅读 23 收藏 0 点赞 0 评论 0
public void onPlayerJoin(PlayerJoinEvent event) {
    // When a player joins, add their correct values to the `playerVals` hashmap
    plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { // Run the database functions async
        public void run() {
            Player p = event.getPlayer();
            UUID id = p.getUniqueId();
            String uuid = id.toString();
            PreparedStatement stmt = null;
            try {
                stmt = plugin.getDb().getConnection().prepareStatement("SELECT tse FROM life_system WHERE uuid = " + uuid + " LIMIT 1");
                ResultSet set = stmt.executeQuery(); // Get the player with the UUID `uuid`'s life levels from the database
                set.next(); // Get the first matching row
                playerVals.put(id, set.getString("tse")); // Add the player's values to `playerVals`
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }

        ;
    });
}
ConnectionListener.java 文件源码 项目:mopm 阅读 23 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    if (onJoinActions.containsKey(event.getPlayer().getUniqueId())) {
        ProxyBlacklist blacklist = finders.get(event.getPlayer().getUniqueId());
        plugin.getLogger().info("Player " + event.getPlayer().getName() + " connected with an open proxy at " + event.getPlayer().getAddress().getAddress().getHostAddress() + " as detected by " + blacklist.getName());
        if (event.getPlayer().hasPermission("mopm.bypass")) {
            plugin.getLogger().info("Player " + event.getPlayer().getName() + " bypassed open proxy detection by permission");
        }
        for (Predicate<Player> p : onJoinActions.get(event.getPlayer().getUniqueId())) {
            if (p.test(event.getPlayer())) {
                return;
            }
        }
        plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), blacklist.getDefaultCommand()
                .replace("%player%", event.getPlayer().getName())
                .replace("%bl%", blacklist.getName()));
    }
}
PlayerListener.java 文件源码 项目:AsgardAscension 阅读 22 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    plugin.getPlayerManager().loadData(event.getPlayer());
    if(event.getPlayer().hasPermission("asgardascension.staff")) {
        event.getPlayer().setPlayerListName(ChatColor.YELLOW + event.getPlayer().getDisplayName());
    }
    // Restoring location, level and experience in case server crashed
    plugin.getPlayerFile().createConfig(event.getPlayer());
    if(plugin.getPlayerFile().isInChallenge()) {
        Player player = event.getPlayer();
        player.teleport(plugin.getPlayerFile().getChallengeLocation());
        player.setLevel(plugin.getPlayerFile().getChallengeLevel());
        player.setExp(plugin.getPlayerFile().getChallengeExperience());
        plugin.getEconomy().depositPlayer(player, plugin.getPlayerFile().getChallengePrice());
        plugin.getPlayerFile().removeChallenge();
        plugin.getPlayerFile().saveConfig();
    }
}
MoveCraft_PlayerListener.java 文件源码 项目:NavyCraft2-Lite 阅读 42 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    if (Craft.reboardNames.containsKey(player.getName())) {
        if ((Craft.reboardNames.get(player.getName()) != null)
                && Craft.reboardNames.get(player.getName()).crewNames.contains(player.getName())) {
            Craft c = Craft.reboardNames.get(player.getName());
            Location loc = new Location(c.world, c.minX + (c.sizeX / 2), c.maxY, c.minZ + (c.sizeZ / 2));
            player.teleport(loc);

        }
        Craft.reboardNames.remove(player.getName());

    }

    syp = (Shipyard)plugin.getServer().getPluginManager().getPlugin("NavyCraft-Shipyard");
    if( syp != null )
    {
        syp.playerJoin(player);
    }

}
PlayerManager.java 文件源码 项目:FlexMC 阅读 20 收藏 0 点赞 0 评论 0
public void handlePlayerJoin( FlexPlayer player ) {
    this.players.put( player.getUuid(), player );
    List<MessageS2EPlayerList.PlayerItem> items = new ArrayList<>();
    for ( FlexPlayer target : this.getOnlinePlayers() ) {
        if( !target.equals( player ) ) {
            target.getConnectionHandler().sendMessage( new MessageS2EPlayerList( MessageS2EPlayerList.Action.ADD_PLAYER,
                    Collections.singletonList( new MessageS2EPlayerList.PlayerItem().setUuid( player.getUuid() ).setName( player.getName() ).setGameMode( player.getGameMode() ).setPing( player.getLatency() ) ) ) );
        }
        items.add( new MessageS2EPlayerList.PlayerItem().setName( target.getName() ).setUuid( target.getUuid() ).setGameMode( target.getGameMode() ).setPing( target.getLatency() ) );
    }
    player.getConnectionHandler().sendMessage( new MessageS2EPlayerList( MessageS2EPlayerList.Action.ADD_PLAYER, items ) );
    System.out.println( player.getName() + " (" + player.getUuid().toString() + ") logged in from " + player.getIpAddress() );
    player.spawnPlayer();
    player.getWorld().addEntity( player, true );

    String joinMessage = EventFactory.call( new PlayerJoinEvent( player, "§e" + player.getName() + " joined the game." ) ).getJoinMessage();
    if( joinMessage != null && !joinMessage.isEmpty() ) {
        Bukkit.broadcastMessage( joinMessage );
    }

}
PlayerEvents.java 文件源码 项目:PA 阅读 29 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent e) {
    RagePlayer u = RageGames.getPlayer(e.getPlayer());
    e.setJoinMessage(null);

    u.getPlayer().setFlySpeed(0.2f);
    u.getPlayer().setWalkSpeed(0.2f);

    if (plugin.getGm().isInLobby()) {
        u.getPlayer().getInventory().clear();
        plugin.getGm().addPlayerToGame(u);
        plugin.getServer().getOnlinePlayers().forEach(p -> u.getPlayer().showPlayer(p));
        plugin.getServer().getOnlinePlayers().forEach(p -> p.showPlayer(u.getPlayer()));
        u.setLobby();
        Utils.broadcastMsg("&7Ha entrado al juego &e" + u.getName() + " &3(&b" + plugin.getGm().getPlaying().size() + "&d/&b" + plugin.getAm().getMaxPlayers() + "&3)");
        plugin.getGm().checkStart();

        plugin.getServer().getScheduler().runTaskLater(plugin, () -> u.sendToLobby(), 20);
    } else {
        new SpectatorTask(plugin, u).runTaskTimer(plugin, 0, 20);
    }
}
PlayerListener.java 文件源码 项目:Ace 阅读 27 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
    Player player = event.getPlayer();
    //Put player into database
    try {
        PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("SELECT * FROM users WHERE uuid = '"+player.getUniqueId().toString()+"' LIMIT 1");
        ResultSet set = stmt.executeQuery();
        if (!set.next()) {
            stmt.close();
            stmt = plugin.getDb().getConnection().prepareStatement("INSERT INTO users (uuid, name) VALUES ('"+player.getUniqueId().toString()+"', '"+player.getName()+"')");
            stmt.execute();
            stmt.close();
        }
        set.close();

    } catch (SQLException e) {
        e.printStackTrace();
    }
    pm.setup(player);
    try {
        String prfx = RankManager.getRankPrefix(player);
        player.setPlayerListName(ChatColor.translateAlternateColorCodes('&',prfx+" "+RankManager.getRankNameColor(player))+player.getName());
    }catch(Exception err) {err.printStackTrace();}

}
TestPlayerManager.java 文件源码 项目:gamecraft 阅读 24 收藏 0 点赞 0 评论 0
private Player registerPlayer() {
    Player player = mock(Player.class);
    when(player.getUniqueId()).thenReturn(UUID.randomUUID());

    PlayerJoinEvent event = mock(PlayerJoinEvent.class);
    when(event.getPlayer()).thenReturn(player);

    this.manager.registerPlayer(event);

    return player;
}
CooldownModule.java 文件源码 项目:SamaGamesCore 阅读 22 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
    Player player = event.getPlayer();

    if (api.getGameManager().isLegacyPvP())
    {
        AttributeInstance genericAttackSpeedAttribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);

        if (genericAttackSpeedAttribute != null)
            genericAttackSpeedAttribute.setBaseValue(1024.0D);
    }
}
JoinLeaveListeners.java 文件源码 项目:Karma 阅读 24 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e){
    if (!e.getPlayer().hasPlayedBefore()){
        karmaUserManager.addNewKarmaUser(e.getPlayer());
    } else {
        karmaUserManager.addKarmaUser(e.getPlayer());
    }
}
ScoreboardHandler.java 文件源码 项目:HCFCore 阅读 24 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled=true, priority=EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event)
{
  Player player = event.getPlayer();
  UUID uuid = player.getUniqueId();
  for (PlayerBoard board : this.playerBoards.values()) {
    board.addUpdate(player);
  }
  PlayerBoard board2 = new PlayerBoard(this.plugin, player);
  Object c = Arrays.asList(Bukkit.getOnlinePlayers());
  board2.addUpdates((Collection)c);
  setPlayerBoard(uuid, board2);
}
JoinQuitServer.java 文件源码 项目:FastSpawn 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler
   //Join
   public void onJoin(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    if(Teams.getPlayerInWhereArea().containsKey(player)){
        Teams.QuitTeam(player);
    }
}
HungerFixListener.java 文件源码 项目:HCFCore 阅读 21 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled=true, priority= EventPriority.MONITOR)
/*    */   public void onPlayerJoin(PlayerJoinEvent event)
/*    */   {
/* 77 */     EntityPlayer entityPlayer = ((CraftPlayer)event.getPlayer()).getHandle();
/* 78 */     entityPlayer.knockbackReductionX = 0.6F;
/* 79 */     entityPlayer.knockbackReductionY = 0.55F;
/* 80 */     entityPlayer.knockbackReductionZ = 0.6F;
/*    */   }
PlayerJoinListener.java 文件源码 项目:CaveCloudAddon 阅读 22 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(PlayerJoinEvent e){
    /*
    CAVECLOUD API
     */
    CaveCloud.gameAPI
            .setPlayers(Bukkit.getOnlinePlayers().size())
            .update();
}
GlowNPCPlugin.java 文件源码 项目:GlowNPC 阅读 23 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
    getServer().getScheduler().runTaskLater(this, () -> {
        Player p = e.getPlayer();
        if (!p.isOnline())
            return;
        GlowPlayer player = (GlowPlayer) p;
        GlowSession ses = player.getSession();
        player.getWorld().getEntitiesByClass(GlowNPC.class)
                .forEach(npc -> ses.send(npc.getRemoveFromListMessage()));
    }, 15);
}
PacketScoreboard.java 文件源码 项目:helper 阅读 22 收藏 0 点赞 0 评论 0
public PacketScoreboard(@Nullable ExtendedJavaPlugin plugin) {
    this.protocolManager = ProtocolLibrary.getProtocolManager();

    if (plugin != null) {
        Events.subscribe(PlayerJoinEvent.class).handler(this::handlePlayerJoin).bindWith(plugin);
        Events.subscribe(PlayerQuitEvent.class).handler(this::handlePlayerQuit).bindWith(plugin);
    } else {
        Events.subscribe(PlayerJoinEvent.class).handler(this::handlePlayerJoin);
        Events.subscribe(PlayerQuitEvent.class).handler(this::handlePlayerQuit);
    }
}
ScoreboardHandler.java 文件源码 项目:HCFCore 阅读 23 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled=true, priority=EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event)
{
  Player player = event.getPlayer();
  UUID uuid = player.getUniqueId();
  for (PlayerBoard board : this.playerBoards.values()) {
    board.addUpdate(player);
  }
  PlayerBoard board2 = new PlayerBoard(this.plugin, player);
  Object c = Arrays.asList(Bukkit.getOnlinePlayers());
  board2.addUpdates((Collection)c);
  setPlayerBoard(uuid, board2);
}
GameListener.java 文件源码 项目:VoxelGamesLibv2 阅读 30 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(@Nonnull PlayerJoinEvent event) {
    Bukkit.getScheduler().runTaskLater(voxelGamesLib, () -> {
        if (gameHandler.getDefaultGame() != null) {
            gameHandler.getDefaultGame().join(userHandler.getUser(event.getPlayer().getUniqueId()).orElseThrow(() ->
                    new UserException("Unknown user " + event.getPlayer().getDisplayName() + "(" + event.getPlayer().getUniqueId() + ")")));
        }
    }, 10);
}
EmptyRestart.java 文件源码 项目:EscapeLag 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void cancelRestart(PlayerJoinEvent evt){
    if(ConfigOptimize.emptyRestart) {
        Bukkit.getScheduler().cancelTask(restartTaskId);
        restartTaskId = -1;
    }
}
LogHandler.java 文件源码 项目:ChatAssets 阅读 29 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    PlaceHolderSetup(player);
    if (enableJoinMessage) {
        broadcastJoinMessage("chatassets.loghandler.joinmessage.receive", event);
    }
    if (player.hasPermission("chatassets.loghandler.motd.receive") && enableMotd) {
        sendMotd(player);
    }
}
MonitorEnabler.java 文件源码 项目:EscapeLag 阅读 22 收藏 0 点赞 0 评论 0
@EventHandler
public void JoinEnableMonitor(PlayerJoinEvent event){
    if(hasEnabled == false){
        if(ConfigFunction.Monitorenable){
            MonitorUtils.enable();
        }
        hasEnabled = true;
    }
}
UserQuitJoinListener.java 文件源码 项目:Minecordbot 阅读 24 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent e) {
    if (safeToProceed(e)) {
        mcb.getBot().getUpdatableMap().get("list").update();
        SuperVanishHook svHook = HookContainer.getSuperVanishHook();
        String msg = ChatColor.stripColor(e.getJoinMessage());
        boolean isJoinBroadCast = configsManager.getBroadcastConfig().getBoolean("See_Player_Join");
        boolean seeJoin = configsManager.getModChannelConfig().getBoolean("See_Player_Join");
        if (seeJoin) {
            String m = msg;
            if (svHook != null) {
                boolean seeSV = configsManager.getModChannelConfig().getBoolean("See_SV");
                if (VanishAPI.isInvisible(e.getPlayer()) || e.getJoinMessage().equals("Fake") && seeSV)
                    m = "(Vanish) " + m;
            }
            messenger.sendMessageEmbedToAllModChannel(new EmbedBuilder().setColor(JOIN_COLOR)
                    .setTitle(m, null).build());
        }
        if (isJoinBroadCast) {
            if (e.getJoinMessage().equals("Fake")) {
                messenger.sendMessageEmbedToAllBoundChannel(new EmbedBuilder().setColor(JOIN_COLOR)
                        .setTitle(msg, null).build());
                e.setJoinMessage("");
            } else if (check(e)) {
                messenger.sendMessageEmbedToAllBoundChannel(new EmbedBuilder().setColor(JOIN_COLOR)
                        .setTitle(msg, null).build());
            }
        }
    }
}
PetDataListener.java 文件源码 项目:PetBlocks 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Gets called when a player joins a server. Overrides existing pets if enabled in the config.yml and
 * spawns the petblock of the player when his pet was enabled when he left the server the last time.
 *
 * @param event event
 */
@EventHandler
public void playerJoinEvent(final PlayerJoinEvent event) {
    this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
        final PetMeta petMeta;
        if (Config.getInstance().isJoin_enabled()) {
            if (!this.manager.getPetMetaController().getFromPlayer(event.getPlayer()).isPresent() || Config.getInstance().isJoin_overwriteExistingPet()) {
                if (event.getPlayer().getWorld() != null) {
                    final PetMeta meta = this.manager.getPetMetaController().create(event.getPlayer());
                    Config.getInstance().fixJoinDefaultPet(meta);
                    this.manager.getPetMetaController().store(meta);
                }
            }
        }

        if ((petMeta = PetBlocksApi.getDefaultPetMetaController().getByPlayer(event.getPlayer())) != null) {
            if (petMeta.isEnabled()) {
                this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
                    if (event.getPlayer().getWorld() != null) {
                        final PetBlock petBlock = PetBlocksApi.getDefaultPetBlockController().create(event.getPlayer(), petMeta);
                        PetBlocksApi.getDefaultPetBlockController().store(petBlock);
                    }
                }, 2L);
            }
        }
    });
}
UserQuitJoinListener.java 文件源码 项目:Minecordbot 阅读 34 收藏 0 点赞 0 评论 0
private boolean safeToProceed(PlayerEvent event) {
    boolean safe = true;
    if (event instanceof PlayerJoinEvent) {
        if (((PlayerJoinEvent) event).getJoinMessage() == null && ((PlayerJoinEvent) event).getJoinMessage().isEmpty()) {
            safe = false;
            Logger.warn("The previous PlayerJoinEvent message was missing!");
        }
    } else if (event instanceof PlayerQuitEvent) {
        if (((PlayerQuitEvent) event).getQuitMessage() == null && ((PlayerQuitEvent) event).getQuitMessage().isEmpty()) {
            safe = false;
            Logger.warn("The previous PlayerQuitEvent message was missing!");
        }
    }
    return safe;
}
SuperVanishListener.java 文件源码 项目:Minecordbot 阅读 21 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerShow(PlayerShowEvent event) {
    if (VanishAPI.getConfiguration().getBoolean("Configuration.Messages.VanishReappearMessages.BroadcastMessageOnReappear")) {
        PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(event.getPlayer(), "Fake");
        Bukkit.getServer().getPluginManager().callEvent(playerJoinEvent);
    }
}
TriggerJoinEvent.java 文件源码 项目:OpenRPG 阅读 77 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    event.setJoinMessage(null);

    Bukkit.getPluginManager().callEvent(new JoinEvent(PlayerManager.getInstance().register(event.getPlayer())));
    event.getPlayer().setGameMode(GameMode.ADVENTURE);
    Main.getInstance().registerAddress(event.getPlayer());
}
SkyFactory.java 文件源码 项目:SamaGamesAPI 阅读 21 收藏 0 点赞 0 评论 0
@EventHandler
private void onJoin(PlayerJoinEvent event) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException, ClassNotFoundException
{
    Player p = event.getPlayer();

    if (this.worldEnvironments.containsKey(p.getWorld().getName()))
        Reflection.sendPacket(p, getPacket(p));
}
ModeratorMode.java 文件源码 项目:HCFCore 阅读 21 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoinMod(PlayerJoinEvent event) {
  Player player = event.getPlayer();
  if (player.hasPermission("rank.staff")) {
    enterMod(player);
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号