Random item when someone joins

Discussion in 'Spigot Plugin Development' started by brandonlea, May 5, 2017.

  1. Hello i need some help on using PlayerJoinEvent when someone joins then give them an item but it can be anything do you think you can help me thanks
     
  2. Make a list with the items you want. And when the player joins, pick a random item from the list and give it to the player.
     
    • Agree Agree x 1
  3. Choco

    Moderator

    Even better, save yourself some space and create an array of ItemStacks instead. Also slightly more pretty to view.
    Code (Java):
    private static final ItemStack[] ITEMS = {
        new ItemStack(Material.POTATO_ITEM),
        new ItemStack(Material.APPLE)
    };
    Selecting a random index is the exact same as a list, but if it's a fixed size, an array may just be superior
     
    • Agree Agree x 1
  4. Okay thanks and where can i learn advance Java
     
    • Funny Funny x 1