How to do this?

Discussion in 'Spigot Plugin Development' started by HarleySwtfus, Jun 5, 2017.

  1. So, I'm creating a basic plugin, and here is the code for the part I'm stuck on:

    if (cmd.getName().equalsIgnoreCase("start")) {
    if (waiting.size() >= 2) {
    for (Player p1 : waiting) {
    return true;
    } else {
    Bukkit.broadcastMessage("There are not enough players to start, 2 needed!");
    return true;

    What I'm trying to do is, when the game is started using the /start command, I want every Player in the "waiting" arraylist to teleport to the arena (p.teleport(arena);) and receive the kit (p.receiveKit(p1);).

    Thanks, I'm very new to coding, so I just need a little help! :)
  2. Use code tags
    Dont expect us to give you code
    Be more specific
    Are there errors? Does the code run?
    Learn java and bukkit api
    Learn to google

    I dont want to be rude but this looks to much like a script kid going wild on forums
    #2 Remceau, Jun 5, 2017
    Last edited: Jun 5, 2017
  3. To begin with, don't use a list, use a Set (indexing seems to be pointless in your case, but I can be wrong).

    And why do you even need a list? If it only should contain two players, just keep to variables.

    Code (Text):
    // initialize these at some point
    Player p1 = null;
    Player p2 = null;

    if (p1 == null || p2 == null) {
      // don't start game because we don't have the two players