Show online players for every world

Discussion in 'Archived: Plugin Requests' started by Geekhellmc, Oct 24, 2013.

  1. Offline

    Geekhellmc

    Hi so I know bungee cord but didnt like it due to be too complicated. So I have multiworld core and portals. I would like that every world the players can see the players online in the same world.
     
  2. Offline

    calebbfmv

    Hmmm, simple enough.
     
  3. Offline

    Goblom

    Geekhellmc BungeeCord does players per server, not players per world.

    For anyone who feels like a plugin out of this.... Here is the code to do it. (Its to much word for a simple method)

    Code:java
    1. public String getPlayersInWorld(World world) {
    2. String message = "[World Players] " + "[" + world.getName() + "] ";
    3. int playerAmount = world.getPlayers().size();
    4. int playersAdded = 0;
    5. for (Player player : world.getPlayers()) {
    6. if (playersAdded == 0) {
    7. message = message + player.getName() + "";
    8. playersAdded = playersAdded + 1; //playersAdded++; ?
    9. } else {
    10. message = message + ", " + player.getName();
    11. playersAdded = playersAdded + 1; //playersAdded++; ?
    12. }
    13. if (playersAdded == playerAmount) message = message + ".";
    14. }
    15. return message;
    16. }
    calebbfmv (tagged cause i know your already working on it)


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  4. Offline

    calebbfmv

    Goblom
    Thanks, but I wasn't going to unless no one else did.
     
  5. Offline

    Goblom

    calebbfmv Well, now you dont have to write the hardest part ;)
     
  6. Offline

    calebbfmv

    Goblom
    That was the easy part :p
     
  7. Online

    timtower Administrator Administrator Moderator

    What is the hard part then? :confused:
     
  8. Offline

    BillyGalbreath

    I would imagine the hard part would be attaching that list to the tab list. I've never worked with the tab list, so I wouldnt know :p
     
    calebbfmv and timtower like this.
  9. Offline

    Geekhellmc

    I know that bungee cord is to link mutiple server together but what i meant is that their is a plugin that everyworld shows online players in this world when they press the Tab button
     
  10. Offline

    Goblom

    calebbfmv Use protocol lib... I did not realize that Geekhellmc only wanted to show players in the tab-list per world... my code will do is print out players to the chat.
     
  11. Offline

    calebbfmv

    Goblom
    Way ahead of you man, thanks.
     
  12. Offline

    Geekhellmc

    Well :I can you pls?
     
  13. Offline

    BillyGalbreath

    I found a way to do the tab thing.

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
    4. Player player = event.getPlayer();
    5. EntityPlayer ePlayer = ((CraftPlayer)player).getHandle();
    6. for (Player p : Bukkit.getOnlinePlayers()) {
    7. if (!p.getWorld().getName().equalsIgnoreCase(player.getWorld().getName())) {
    8. ePlayer.playerConnection.sendPacket(new Packet201PlayerInfo(p.getName(), false, 99999));
    9. }
    10. }
    11. }
    12.  
    13. @EventHandler
    14. public void onPlayerJoin(PlayerJoinEvent event) {
    15. Player player = event.getPlayer();
    16. EntityPlayer ePlayer = ((CraftPlayer)player).getHandle();
    17. for (Player p : Bukkit.getOnlinePlayers()) {
    18. if (!p.getWorld().getName().equalsIgnoreCase(player.getWorld().getName())) {
    19. ePlayer.playerConnection.sendPacket(new Packet201PlayerInfo(p.getName(), false, 99999));
    20. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getName(), false, 99999));
    21. }
    22. }
    23. }
    24.  


    Source: https://github.com/Howaner/Splitted...er/SplittedWorlds/listener/WorldListener.java

    It was written 8 months ago, but I don't see why it shouldn't still work.

    Edit: Edited so many times to fix syntax indentation...
     

Share This Page