Solved need help

Discussion in 'Plugin Development' started by s3od2000, Aug 27, 2014.

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

    s3od2000

    if i have 3 players on the server what i want to know how to set the 3 players names on these blocks
    [​IMG]

    how do i do that?
     
  2. Offline

    kunhunjon

    You would get the players somehow, whatever your preferred method, and then make an item stack and edit the metadata so the item name is set to the name of the player. This bad boy exists for a reason bud http://jd.bukkit.org/beta/apidocs/
     
  3. Offline

    s3od2000



    you have not understand me i want to set all there player auto on this blocks i can name it easy but i want to get the players online on put it on the block not all player name in 1 block
     
  4. Offline

    PePsiGam3r

    kunhunjon is right, I will explain it by my way, maybe you'll understand!
    Use PlayerJoinEvent then check if Bukkit.getOnlinePlayers().length is three, then do whatever you want like adding blocks to the PlayerInventory, to get a player from online players use Bukkit.getOnlinePlayers() array.
    Example:
    Code:java
    1. @EventHandler
    2. public void onPlayerJOIN(PlayerJoinEvent e) {
    3. if (Bukkit.getOnlinePlayers().length == 3) {
    4. ItemStack is = new ItemStack(Material.WOOD);
    5. ItemMeta im = is.getItemMeta();
    6. String first = Bukkit.getOnlinePlayers()[0].getName();
    7. String second = Bukkit.getOnlinePlayers()[1].getName();
    8. String third = Bukkit.getOnlinePlayers()[2].getName();
    9. im.setDisplayName(ChatColor.GREEN + first);
    10. is.setItemMeta(im);
    11. e.getPlayer().getInventory().addItem(is);
    12. im.setDisplayName(ChatColor.GOLD + second);
    13. is.setItemMeta(im);
    14. e.getPlayer().getInventory().addItem(is);
    15. im.setDisplayName(ChatColor.RED + third);
    16. is.setItemMeta(im);
    17. e.getPlayer().getInventory().addItem(is);
    18. }
    19. }

    Hope this helpful.
     
    s3od2000 likes this.
  5. Offline

    s3od2000



    that help me a lot thank you for explaining me more
     
Thread Status:
Not open for further replies.

Share This Page