Java Code Examples for org.bukkit.event.player.PlayerJoinEvent

The following are top voted examples for showing how to use org.bukkit.event.player.PlayerJoinEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: SkywarsSeries   File: PlayerJoin.java   Source Code and License 6 votes vote down vote up
@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());
    }
}
 
Example 2
Project: Uranium   File: DefaultUpdateCallback.java   Source Code and License 6 votes vote down vote up
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);
        }
        */
    }
}
 
Example 3
Project: Locked   File: LifeSystem.java   Source Code and License 6 votes vote down vote up
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();
            }

        }

        ;
    });
}
 
Example 4
Project: mopm   File: ConnectionListener.java   Source Code and License 6 votes vote down vote up
@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()));
    }
}
 
Example 5
Project: AsgardAscension   File: PlayerListener.java   Source Code and License 6 votes vote down vote up
@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();
	}
}
 
Example 6
Project: NavyCraft2-Lite   File: MoveCraft_PlayerListener.java   Source Code and License 6 votes vote down vote up
@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);
	}

}
 
Example 7
Project: FlexMC   File: PlayerManager.java   Source Code and License 6 votes vote down vote up
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 );
    }

}
 
Example 8
Project: PA   File: PlayerEvents.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 9
Project: gamecraft   File: TestPlayerManager.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 10
Project: SamaGamesCore   File: CooldownModule.java   Source Code and License 5 votes vote down vote up
@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);
    }
}
 
Example 11
Project: Karma   File: JoinLeaveListeners.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e){
    if (!e.getPlayer().hasPlayedBefore()){
        karmaUserManager.addNewKarmaUser(e.getPlayer());
    } else {
        karmaUserManager.addKarmaUser(e.getPlayer());
    }
}
 
Example 12
Project: HCFCore   File: ScoreboardHandler.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 13
Project: FastSpawn   File: JoinQuitServer.java   Source Code and License 5 votes vote down vote up
@EventHandler
   //Join
   public void onJoin(PlayerJoinEvent e) {
	Player player = e.getPlayer();
	if(Teams.getPlayerInWhereArea().containsKey(player)){
		Teams.QuitTeam(player);
	}
}
 
Example 14
Project: HCFCore   File: HungerFixListener.java   Source Code and License 5 votes vote down vote up
@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;
/*    */   }
 
Example 15
Project: CaveCloudAddon   File: PlayerJoinListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e){
    /*
    CAVECLOUD API
     */
    CaveCloud.gameAPI
            .setPlayers(Bukkit.getOnlinePlayers().size())
            .update();
}
 
Example 16
Project: GlowNPC   File: GlowNPCPlugin.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 17
Project: helper   File: PacketScoreboard.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 18
Project: HCFCore   File: ScoreboardHandler.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 19
Project: VoxelGamesLibv2   File: GameListener.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 20
Project: EscapeLag   File: EmptyRestart.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void cancelRestart(PlayerJoinEvent evt){
    if(ConfigOptimize.emptyRestart) {
        Bukkit.getScheduler().cancelTask(restartTaskId);
        restartTaskId = -1;
    }
}
 
Example 21
Project: ChatAssets   File: LogHandler.java   Source Code and License 5 votes vote down vote up
@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);
	}
}
 
Example 22
Project: EscapeLag   File: MonitorEnabler.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void JoinEnableMonitor(PlayerJoinEvent event){
	if(hasEnabled == false){
		if(ConfigFunction.Monitorenable){
			MonitorUtils.enable();
		}
		hasEnabled = true;
	}
}
 
Example 23
Project: Minecordbot   File: UserQuitJoinListener.java   Source Code and License 5 votes vote down vote up
@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());
            }
        }
    }
}
 
Example 24
Project: PetBlocks   File: PetDataListener.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
            }
        }
    });
}
 
Example 25
Project: Minecordbot   File: UserQuitJoinListener.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 26
Project: Minecordbot   File: SuperVanishListener.java   Source Code and License 5 votes vote down vote up
@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);
    }
}
 
Example 27
Project: OpenRPG   File: TriggerJoinEvent.java   Source Code and License 5 votes vote down vote up
@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());
}
 
Example 28
Project: SamaGamesAPI   File: SkyFactory.java   Source Code and License 5 votes vote down vote up
@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));
}
 
Example 29
Project: HCFCore   File: ModeratorMode.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoinMod(PlayerJoinEvent event) {
  Player player = event.getPlayer();
  if (player.hasPermission("rank.staff")) {
    enterMod(player);
  }
}
 
Example 30
Project: ZorahPractice   File: Kraken.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    new BukkitRunnable() {
        @Override
        public void run() {
            checkPlayer(player);
        }
    }.runTaskLaterAsynchronously(PracticePlugin.getInstance(), 4L);
}
 
Example 31
Project: MooProject   File: ServerListener.java   Source Code and License 5 votes vote down vote up
/**
 * When the player joins the server
 * <p>
 * SERVER JOIN
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent event) {
    if(!Moo.getInstance().isConnected()) return;
    event.setJoinMessage(null);
    Player player = event.getPlayer();

    PlayerData data = new PlayerData();
    data.setUuid(player.getUniqueId());
    data.setLastName(player.getName());
    data.setLastIp(player.getAddress().getHostString());

    // changes state
    Permissible oldPermissible = PermissionInjector.getPermissible(player);
    CustomPermissible customPermissible = new CustomPermissible(player, data.getUuid(), oldPermissible);
    PermissionInjector.inject(player, customPermissible);

    MooQueries.getInstance().changePlayerState(data, PacketPlayerState.State.JOIN_SERVER, response -> {
    });

    // UPDATE SERVER INFO
    Lightning.getInstance().updateServerInfo();

    // SET JOIN MESSAGE
    String playerName = MooQueries.getInstance().getGroup(player.getUniqueId()).getColor() + player.getName();
    Bukkit.getServer().broadcastMessage(LanguageManager.get("join-message-pattern", playerName));
}
 
Example 32
Project: HeadGetter   File: HeadListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e) {
	
	if(m.u.enabledingame) {
		if(m.u.update == true) {
		e.getPlayer().sendMessage("�6[�2Updater�6] �3Look at the console, there is an update for HeadGetter!");
		}else{
			e.getPlayer().sendMessage("�6[�2Updater�6] �3There isn't update for HeadGetter!");
		}
	}
	
}
 
Example 33
Project: MT_Core   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
private void onPlayerJoinEvent(PlayerJoinEvent e) {
	main.getPlayerManager().addMortuusPlayer(e.getPlayer());

	if (!main.getScoreboards().isHostile(e.getPlayer()))
		main.getScoreboards().addPlayer(e.getPlayer(), "NEUTRAL");
}
 
Example 34
Project: LoggerAPI   File: LoggerManager.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    if (!this.loggerEntities.containsKey(player.getName())) {
        return;
    }

    LoggerEntity logger = this.getLogger(player.getName());
    logger.remove(null, LoggerRemoveReason.REJOIN);

    this.loggerEntities.remove(player.getName());
}
 
Example 35
Project: ProjectAres   File: PGMListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void kickAbandonedPlayers(final PlayerJoinEvent event) {
    // Spawn module should add player to a match at a lower priority.
    // If that hasn't happened for some reason, kick the player.
    if(mm.getPlayer(event.getPlayer()) == null) {
        event.getPlayer().kickPlayer(net.md_5.bungee.api.ChatColor.RED + Translations.get().t("incorrectWorld.kickMessage", event.getPlayer()));
        logger.severe("Kicking " + event.getPlayer().getName() + " because they failed to join a match");
    }
}
 
Example 36
Project: SamaGamesCore   File: TabsColorsListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(final PlayerJoinEvent event)
{
    final Player p = event.getPlayer();
    manager.playerJoin(p); // Passer ça en sync si crash //
    Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
        PermissionEntity user = api.getPermissionsManager().getPlayer(p.getUniqueId());
        final String displayn = replaceColors(user.getTag() + "" + user.getPrefix()) + p.getName();
        p.setDisplayName(displayn);
    });
}
 
Example 37
Project: NeverLag   File: ClientModDisabler.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
	if (cm.clientModDisabler) {
		Player p = e.getPlayer();
		if (p.isOp() || p.hasPermission("neverlag.nosendmagiccode"))
			return;
		for (String code : cm.modMagicCode) {
			p.sendMessage(ChatColor.translateAlternateColorCodes('&', code));
		}
	}
}
 
Example 38
Project: ProjectAres   File: JoinMessageAnnouncer.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent event) {
    event.setJoinMessage(null);
    final User user = userStore.getUser(event.getPlayer());
    final SessionChange change = pendingJoins.getIfPresent(user);
    if(change != null) {
        pendingJoins.invalidate(user);
        announce(change);
    }
}
 
Example 39
Project: SurvivalPlus   File: BedFatigue.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
	Player player = event.getPlayer();
    showAllSleeping(player);
	if(!player.hasPlayedBefore())
	{
		fatigue.getScore(player).setScore(0);
	}
}
 
Example 40
Project: SurvivalPlus   File: Consume.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler
public void onFirstJoin(PlayerJoinEvent event)
{
	Player player = event.getPlayer();
	if(!player.hasPlayedBefore())
	{
		thirst.getScore(player).setScore(30);
	}
}
 
Example 41
Project: SurvivalPlus   File: ScoreboardStats.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e)
{
	Player player = e.getPlayer();
	if(!player.hasPlayedBefore())
	{
		boardHunger.getScore(player).setScore(0);
		boardThirst.getScore(player).setScore(0);
		boardFatigue.getScore(player).setScore(1);
		boardNutrients.getScore(player).setScore(1);
	}
	SetupScorebard(player);
}
 
Example 42
Project: HCFCore   File: FactionListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
    if (playerFaction != null) {
        playerFaction.printDetails(player);
        playerFaction.broadcast(prefix + ChatColor.GRAY + "Your faction member " + ChatColor.GOLD  + playerFaction.getMember(player).getRole().getAstrix() + player.getName() + ChatColor.GRAY + " has " + ChatColor.GREEN + "connected.");
    
    }
}
 
Example 43
Project: OpenUHC   File: QueueModule.java   Source Code and License 5 votes vote down vote up
/**
 * Calls a {@link PlayerInitEvent} for any player that joins after the game starts and hasn't been initialized yet.
 *
 * @param event The event
 */
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
  Player player = event.getPlayer();
  UUID uuid = player.getUniqueId();
  //TODO: Only run if the player is playing in the game (not spectating)
  if (OpenUHC.getCurrentGame().getState().equals(GameState.PLAYING) && !initialized.contains(uuid)) {
    initialized.add(uuid);
    Bukkit.getPluginManager().callEvent(new PlayerInitEvent(player, true));
  }
}
 
Example 44
Project: FactionsXL   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    FPlayer fPlayer = new FPlayer(player);
    fPlayers.addPlayer(fPlayer);

    Region region = fPlayer.getLastRegion();
    MessageUtil.sendActionBarMessage(player, ParsingUtil.getRegionName(player, region));

    if (fConfig.isScoreboardEnabledByDefault()) {
        FScoreboard.init(fPlayer);
        FScoreboard.get(fPlayer).setDefaultSidebar(new FDefaultSidebar(), fConfig.getScoreboardUpdateInterval());
        FScoreboard.get(fPlayer).setSidebarVisibility(fPlayer.isScoreboardEnabled());
    }
}
 
Example 45
Project: DragonEggDrop   File: RespawnListeners.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
	// Version notification
	Player player = event.getPlayer();
	if (player.isOp() && plugin.isNewVersionAvailable()) {
		this.plugin.sendMessage(player, ChatColor.GRAY + "A new version is available for download (Version " + this.plugin.getNewVersion() + "). " + RESOURCE_PAGE);
	}
	
	World world = player.getWorld();
	if (world.getEnvironment() != Environment.THE_END) return;
	
	EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);
	
	// Reset end crystal states just in case something went awry
	if (!worldWrapper.isRespawnInProgress()) {
		world.getEntitiesByClass(EnderCrystal.class).forEach(e -> {
			e.setInvulnerable(false);
			e.setBeamTarget(null);
		});
	}
	
	// Dragon respawn logic
	if (!plugin.getConfig().getBoolean("respawn-on-join", false)) return;
	if (!world.getPlayers().isEmpty() || manager.getWorldWrapper(world).isRespawnInProgress()
			|| world.getEntitiesByClass(EnderDragon.class).size() == 0) 
		return;
	
	manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
}
 
Example 46
Project: kaosEssentials   File: Core.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority=EventPriority.LOWEST)
public void otherJoinEventStuff(PlayerJoinEvent e){
	Player p = e.getPlayer();
	p.sendMessage(tag + ChatColor.GRAY + "=================================");
	p.sendMessage(tag + ChatColor.BLUE + "Welcome to kaospvp!");
	p.sendMessage(tag + ChatColor.BLUE + "Do " + ChatColor.RED + "/help" + ChatColor.BLUE + " to get started");
	p.sendMessage(tag + ChatColor.BLUE + "And make sure to read the " + ChatColor.RED + "/rules");
	p.sendMessage(tag + ChatColor.GRAY + "=================================");
}
 
Example 47
Project: Stats4   File: PlayerStatistic.java   Source Code and License 5 votes vote down vote up
@EventHandler
private void onPlayerJoin(PlayerJoinEvent event) {
    DatabaseQueryWorker.getInstance().submit(() -> {
        try {
            PlayerStatisticDAO.onPlayerJoin(
                    event.getPlayer()
            );
        } catch (SQLException e) {
            e.printStackTrace();
        }
    });
}
 
Example 48
Project: Transport-Pipes   File: UpdateUtils.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoin(final PlayerJoinEvent e) {
	if (e.getPlayer().hasPermission(TransportPipes.instance.getConfig().getString("permissions.update", "tp.update")) && TransportPipes.instance.generalConf.isCheckUpdates()) {
		Bukkit.getScheduler().runTaskLater(TransportPipes.instance, new Runnable() {

			@Override
			public void run() {
				checkForUpdates(e.getPlayer());
			}
		}, 60L);
	}
}
 
Example 49
Project: Ace   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@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();}

}
 
Example 50
Project: mczone   File: Events.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
	Player p = event.getPlayer();
	joinTimes.put(event.getPlayer().getName(), new Date());
	event.setJoinMessage(null);
	p.setHealth(20);
	p.setFoodLevel(20);
	p.getInventory().clear();
	
	Location l = event.getPlayer().getWorld().getSpawnLocation();
	l.setX(14.5);
	l.setY(10.5);
	l.setZ(-795.5);
	l.setPitch(0.5F);
	l.setYaw(90 * RandomUtil.between(1, 4));
	
	
	
	p.teleport(l);
	p.setGameMode(GameMode.SURVIVAL);
	p.getInventory().addItem(Lobby.book);
	p.getInventory().addItem(Lobby.compass);
	Lobby.addPotionEffect(event.getPlayer(), new PotionEffect(PotionEffectType.SPEED, 2147483647, 2));
	
	if (Gamer.get(p.getName()).getRank().getLevel() >= RankType.ADMIN.getLevel())
		event.getPlayer().addAttachment(Lobby.getInstance(), "bukkit.command.gamemode", true);
}
 
Example 51
Project: mczone   File: ConnectEvents.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
	event.setJoinMessage(null);
	final Gamer g = Gamer.get(event.getPlayer());
	g.teleport(Ghost.getLobby().getSpawn());
	g.removePotionEffects();
	if (g.getVariable("edit") == null)
		g.getPlayer().setGameMode(GameMode.SURVIVAL);
	g.getPlayer().setHealth(20);
	g.getPlayer().setFoodLevel(20);
	
	g.run("load-kits");
}
 
Example 52
Project: mczone   File: ConnectEvents.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
	Gamer g = Gamer.get(event.getPlayer());
	if (g.getRank().isCancelled()) {
		Date cancel = g.getRank().getExpireDate();
		Chat.player(g, "&7Your &8" + g.getRank().getType().getTitle()	+ " &7will expire on &8" + Infraction.human.format(cancel));
	}
}
 
Example 53
Project: ArmorPlus   File: MainEvent.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e){
    Player p = e.getPlayer();
    p.sendMessage("§6[!] §f이 서버는 하늘빛QP의 ArmorPlus 플러그인을 사용 중입니다.");
    p.sendMessage("§6[!] §fhttp://blog.kgaons.kr");
    if(Main.players.get(p.getUniqueId().toString()) == null){
        Main.log.info("[ArmorPlus]" + p.getName() + " 님의 데이터가 생성되었습니다.");
        Main.players.set(p.getUniqueId().toString() + ".투구","");
        Main.players.set(p.getUniqueId().toString() + ".갑옷","");
        Main.players.set(p.getUniqueId().toString() + ".바지","");
        Main.players.set(p.getUniqueId().toString() + ".신발","");
        Main.players.set(p.getUniqueId().toString() + ".반지","");
        Main.saveconfig();
    }
}
 
Example 54
Project: McPlayUHC   File: PlayerJoinListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void PlayerJoinListener(PlayerJoinEvent e) {

	e.setJoinMessage(SettingsManager.joinMsg.replace("%s", e.getPlayer().getName()).replace("%o", String
			.valueOf(Bukkit.getOnlinePlayers().size()).replace("%n", String.valueOf(SettingsManager.needplayers))));
	
	e.getPlayer().setGameMode(GameMode.ADVENTURE);
	
	if (Bukkit.getOnlinePlayers().size() == SettingsManager.needplayers) {
		GameManager.StartGame();
	}
}
 
Example 55
Project: HCFCore   File: FactionListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
    if (playerFaction != null) {
        playerFaction.printDetails(player);
        playerFaction.broadcast(prefix + ChatColor.GRAY + "Your faction member " + ChatColor.GOLD  + playerFaction.getMember(player).getRole().getAstrix() + player.getName() + ChatColor.GRAY + " has " + ChatColor.GREEN + "connected.");
    
    }
}
 
Example 56
Project: WebSandboxMC   File: PlayersListener.java   Source Code and License 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    playersBridge.notifyAdd(player.getEntityId(), player.getDisplayName(), player.getLocation());
}
 
Example 57
Project: ChatChannels   File: PlayerJoin.java   Source Code and License 4 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
    Player player = event.getPlayer();

    // If a player has newly logged in, automatically focus to the default channel and force them to view the default channels
    if (ChatChannels.get().getViewingChannels(player).size() == 0)
    {
        ChatChannels.get().getDefaultViewingChannels().forEach(channel ->
                channel.display(
                        player,
                        !(ChatChannels.get().getConfig().getBoolean("chat-settings.squelch-viewing-message-on-join"))
                )
        );
    }

    if (ChatChannels.get().getFocusedChannel(player) == null)
    {
        ChatChannels.get().getDefaultChannel().focus(
                player,
                !(ChatChannels.get().getConfig().getBoolean("chat-settings.squelch-focus-message-on-join"))
        );
    }

    // Check to see if a new update has been cached
    if (player.hasPermission("chatchannels.update.notify"))
    {
        System.out.println("[ChatChannels] Checking for plugin update...");
        Object[] update = ChatChannels.get().getUpdateHandler().getLatestUpdate();

        System.out.println("[ChatChannels] Update result = " + Arrays.toString(update));

        if (update != null)
        {
            String newVersion = (String) update[0];
            String newChanges = (String) update[1];

            System.out.println("[ChatChannels] New version number: " + newVersion);
            System.out.println("[ChatChannels] New version information: " + newChanges);

            final String TAG = ChatColor.RED + "[ChatChannels] ";

            Stream.of(
                    TAG + ChatColor.GOLD + "a " + ChatColor.BOLD + "new update " + ChatColor.GOLD + "has been released.",
                    TAG + ChatColor.DARK_AQUA + "New Version " + ChatColor.WHITE + newVersion,
                    TAG + ChatColor.DARK_AQUA + "Your Version " + ChatColor.WHITE + ChatChannels.get().getDescription().getVersion(),
                    TAG + ChatColor.DARK_AQUA + "Plugin Update(s) " + ChatColor.WHITE + newChanges
            ).forEach(player::sendMessage);
        }
    }
}
 
Example 58
Project: MT_Communication   File: PlayerListener.java   Source Code and License 4 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e) {
  if (main.getPlayerManager().getPlayer(e.getPlayer()) == null) {
    main.getPlayerManager().addPlayer(e.getPlayer());
  }
}
 
Example 59
Project: ChatAssets   File: LogHandler.java   Source Code and License 4 votes vote down vote up
public static void broadcastJoinMessage(String permission, PlayerJoinEvent event) {
	event.setJoinMessage(null);
	for (String x : joinmessage) {
		Bukkit.broadcast(Main.colorcode(x), permission);
	}
}
 
Example 60
Project: Warzone   File: VisibilityModule.java   Source Code and License 4 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Bukkit.getScheduler().runTaskLater(TGM.get(), () -> refreshPlayer(event.getPlayer()), 20L);
}