Solved Not teleporting players upon server join

Discussion in 'Plugin Development' started by kayc01, Feb 18, 2016.

Thread Status:
Not open for further replies.
  1. This is confusing me as why i do not get teleported as instructed in my onJoin method.
    However its strange, one person did but my alt account did not as well as others.

    When a player join's it needs to teleport them to a warp i have in my data file. However it just seems to make them go to spawn like /spawn.


    Code:
    @EventHandler
        public void onJoin (PlayerJoinEvent e) {
           
            final Player p = e.getPlayer();
    
           
            if (!(p.getName().equalsIgnoreCase("ABkayCkay") || p.getName().equalsIgnoreCase("w3ath3rfr3ak") || p.getName().equalsIgnoreCase("MikeSN") || p.getName().equalsIgnoreCase("killzymadness") || p.getName().equalsIgnoreCase("PokeKhan") || p.getName().equalsIgnoreCase("Hacko_Jacko") || p.getName().equalsIgnoreCase("mrchan") || p.getName().equalsIgnoreCase("BlueMu"))) {
    
                inArena2.add(p);
               
                p.setFoodLevel(20);
                p.setHealth(20);
               
                p.getInventory().clear();
                p.getInventory().setArmorContents(null);
           
                p.sendMessage(ChatColor.GREEN + "You have sucesfully joined the arena, teleporting to waiting area.");
            
             if (inArena2.size() == 25) {
                 Bukkit.broadcastMessage(ChatColor.GOLD + "There are now " + inArena2.size() + " players in the arena waiting for the game to start.");
             }
             else if (inArena2.size() == 50) {
                 Bukkit.broadcastMessage(ChatColor.GOLD + "There are now " + inArena2.size() + " players in the arena waiting for the game to start.");
             }
             else if (inArena2.size() == 75) {
                 Bukkit.broadcastMessage(ChatColor.GOLD + "There are now " + inArena2.size() + " players in the arena waiting for the game to start.");
             }
             else if (inArena2.size() == 100) {
                 Bukkit.broadcastMessage(ChatColor.GOLD + "There are now " + inArena2.size() + " players in the arena waiting for the game to start.");
             }
             else if (inArena2.size() == 125) {
                 Bukkit.broadcastMessage(ChatColor.GOLD + "There are now " + inArena2.size() + " players in the arena waiting for the game to start.");
             }
            
             for (Player staff : Bukkit.getOnlinePlayers()) {
                
                 if (staff.hasPermission("arena.admin")) {
                     staff.sendMessage(ChatColor.BLUE + "A challenger has joined the arena (" + p.getName() + "), there are now " + inArena2.size() + " People in the arena.");
                    
                   }
              }
            
    
                                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps.waitarea.world"));
                                double x = settings.getData().getDouble("warps.waitarea.x");
                                double y = settings.getData().getDouble("warps.waitarea.y");
                                double z = settings.getData().getDouble("warps.waitarea.z");
                                p.teleport(new Location(w, x, y, z));
                               
                                Location loc = new Location(w, x, y, z);
                               
                                p.setBedSpawnLocation(loc, true);
    
            }
        }
    Anyone know why?
    In EssentialsSpawn config i set the spawn handling to Lowest and to use home/bed spawning instead of spawn after death. These don't seem to solve it.

    Thanks!
     
  2. Offline

    Lightspeed

    Priorities
    Try adding this to your listener and if it still doesen't work add some debugging(Printing strings to the console to see which one it stops at) to find where the code stops.
     
  3. Setting the priority did not help as to fixing it, but it may of been a good factor.
    I needed to set in EssentialsSpawn to make player first join point to "none" instead of "noobie".

    Solved for now. Thanks!
    If you could check out my other recent post just to double check my code that it is doing what i think it is, it was just a guess really. Would help a lot. Thanks again.
     
Thread Status:
Not open for further replies.

Share This Page