onjoinevent send player to location

Discussion in 'Plugin Development' started by shawshark, Nov 7, 2013.

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

    shawshark

    Iv tried so many ways but I can't seem to get it to work could somebody be able to help me.
    In the config something like
    Code:
    spawn1: 100x, 100y, 100z
    spawn2: 253x, 206y, 0z
    and so on to spawn4
    On the onjoinevent it will send a player to the first spawn then the next to spawn2 and so on to spawn4.
     
  2. Offline

    Milkywayz

    Without the source code and a full description of what is not working, there is not much anyone can do.
     
  3. Offline

    shawshark


    I am trying to make a user spawn a a location from a config, each new user that joins will use a different location from the config.
     
  4. Offline

    drtshock

    You just try pasting your current code so we can help you. My first suggestion would be to delay it a few ticks.
     
  5. Offline

    shawshark

    Code:java
    1. public void joinevent(PlayerJoinEvent e) {
    2.  
    3.  
    4. Location loc = Bukkit.getServer().getWorld("world").getSpawnLocation();
    5. loc.setYaw(-90.0F);
    6. e.getPlayer().teleport(loc);
    7.  
    8. e.getPlayer().getInventory().clear();
    9. e.getPlayer().getInventory().setHelmet(null);
    10. e.getPlayer().getInventory().setChestplate(null);
    11. e.getPlayer().getInventory().setLeggings(null);
    12. e.getPlayer().getInventory().setBoots(null);
    13.  
    14.  
    15.  
    16. getServer().dispatchCommand(getServer().getConsoleSender(),
    17. "dispatchserver hub skywarsstatus joinable " + getServer().getOnlinePlayers().length +
    18. " " + getConfig().getString("servername"));
    19.  
    20.  
    21. if(getServer().getOnlinePlayers().length==4) {
    22.  
    23.  
    24. getServer().broadcastMessage(ChatColor.RED + "[" + ChatColor.GRAY + "SkyWars" + ChatColor.RED + "] " +
    25. ChatColor.GRAY + " Skywars game starting with 4 players in the arena starting in 3 seconds!");
    26.  
    27.  
    28. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    29.  
    30. @Override
    31. public void run() {
    32. getServer().broadcastMessage(ChatColor.RED + "[" + ChatColor.GRAY + "SkyWars" + ChatColor.RED + "] " +
    33. ChatColor.GRAY + "Skywars game has started!");
    34. startgame();
    35.  
    36. }
    37. }, 60L);
    38.  
    39.  
    40.  
    41.  
    42. getServer().dispatchCommand(getServer().getConsoleSender(),
    43. "dispatchserver skywarsstatus ingame " + getServer().getOnlinePlayers().length +
    44. " " + getConfig().getString("servername"));
    45. e.setJoinMessage(null);
    46. }
    47.  
    48. }

    This is what I currently have
    That will take to spawn but when it hits 4 players I want it to send them.
     
  6. Offline

    drtshock

    Try delaying the teleport a few ticks.
     
  7. Offline

    shawshark


    After that what would I use to send each player to a spawn location. Note there would only be 4 spawn location.
     
  8. Offline

    drtshock

    Whatever you were already using. Just run a delayed task.
     
Thread Status:
Not open for further replies.

Share This Page