First time join check problem

Discussion in 'Plugin Development' started by blackvoid, Mar 29, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    blackvoid

    Is there a better way to check if someone joins for the first time than this?
    Cause this doesnt work all the time and i dont want to make it check a too big area, since players might be building there.
    Code:
        public void onPlayerJoin(PlayerEvent event) {
            Player player = event.getPlayer();
            if(DynamicEffectSpawnArea.Spawn_On){
                //DynamicEffectSpawnArea.log.log(Level.INFO, "[DESpawnArea] " + player.getDisplayName() + " respawned!");
                //if(player.getLocation() == player.getLocation().getWorld().getSpawnLocation()){
                if(DynamicEffectSpawnArea.CalculateDistance(player.getLocation(),player.getLocation().getWorld().getSpawnLocation()) < 10){
                    player.teleportTo(DynamicEffectSpawnArea.Spawn_Location);
                }
            }
        }
     
  2. Offline

    Sammy

    Joins the first time on the server ?
    You can make a file with all your players, if he's on the list he gets spawn in an other place.
     
  3. Offline

    blackvoid

    The thing is that that will just fill unneeded space, since this should only handle respawns and first time joiners. There needs to be another way.
     
  4. Offline

    Plague

    If you want first time join AND respawn, there's PLAYER_RESPAWN
     
  5. Offline

    blackvoid

    Im using PLAYER_RESPAWN but its only running when you resan and not on first join
     
  6. Offline

    Plague

    That's strange I always thought that you get into the world by spawning... Are you absolutely sure? I mean I never tested that but always thought so.
     
  7. Offline

    blackvoid

    Its used so when the player dies he teleports to the spawn Ive set, but doesnt do it on first join.
     
  8. Offline

    Sammy

    ohh now I understand what you want, if what you say is true, just teleport the player onJoin
    Code:
        public void onPlayerJoin(PlayerEvent event) {
            event.getPlayer().teleport(location );
             }
    I think it should work
     
  9. Offline

    Edward Hand

    If you only want first join you can check whether their player.dat exists:
    Code:
    File playerDat = new File("world/players/"+ thePlayer.getName() + ".dat");
    if(!playerDat.exists())
    {
       //player is new!
    }
    NOTE: This must be used in PLAYER_LOGIN and not PLAYER_JOIN
    When a user joins for the first time their player.dat is created between the two events (so by player_join it will be too late)
     
  10. Offline

    blackvoid

    Thank you works perfectly!
     
  11. Offline

    544nick101

    if you use mcmyadmin go to preferences then player notices and welcome messages it tells you first time players and tell you how many player have loged in its handy :p
     
  12. Offline

    Moe041991

    i have it like this:

    Code:
    	public void onPlayerLogin(PlayerLoginEvent event){
    		System.out.println("Event did trigger");
    		Player player = event.getPlayer();
    		File playerDat = new File("world/players/"+ player.getName() + ".dat");
    		if(!playerDat.exists())
    		{
    		player.sendMessage("Welcome to this Server");
    		}else{
    
    			System.out.println("SCHEISSE");
     	}
    It does not trigger for some reason. any idea?
    btw the Syso are just for testing purpose to see if it triggered.
     
  13. Offline

    stelar7

    did you register it?

    PluginManager pm = getServer().getPluginManager();
    pm.registerEvent(something);
     
  14. Offline

    Moe041991

    nope. Thanks :)

    I still got some trouble.
    Whenever i login it sends me the message, but sind I didnt join up until then, i cant receive the message.
    Any idea how to solve this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
Thread Status:
Not open for further replies.

Share This Page