Solved Teleport new player to a location on join?

Discussion in 'Plugin Development' started by Treeline1, Jan 23, 2015.

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

    Treeline1

    At the moment my world spawn point isnt my actual map spawnpoint where I want people to spawn.
    At the moment when people die they goto my set spawn point, although when I new player joins they spawn at the original spawn point, so I want to make it when they first log in, they spawn at the place I want them to spawn. This is what i have:
    Code:
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            player.sendMessage(ChatColor.DARK_GREEN + "Hi " + player.getName() + ". Welcome to our server!");
            event.setJoinMessage(null);  
            if(player.hasPlayedBefore() == true){
                if (player.getInventory().contains(Material.CHEST)) {
                    return;
                }else{
                    player.getInventory().addItem(new ItemStack(Material.CHEST, 1));
    
                }
            }
            if(player.hasPlayedBefore() == false){
                if (player.getInventory().contains(Material.CHEST)) {
                    player.teleport(new Location(Bukkit.getServer().getWorld("world"), -491.5, 97, -433.5));
                    return;
                }else{
                    player.getInventory().addItem(new ItemStack(Material.CHEST, 1));
    
    
                }
            }
        }
    Unfortuantly that doesnt work for some reason. Can someone tell me why? Thanks
     
  2. Offline

    teej107

    Did you register your event? Put in debug code.
     
    Skionz likes this.
  3. Offline

    Treeline1

    Fixed. Never mind.
    Realized I was saying that if the player had a chest in their inventory then teleport them up there. But since they first spawned in of course they didnt. Thanks
     
Thread Status:
Not open for further replies.

Share This Page