Solved Hi i have error

Discussion in 'Spigot Help' started by Matheusvilas49, Jul 5, 2021.

  1. [16:20:49 WARN]: [RageSkyWars] Task #6 for RageSkyWars v1.0 generated an exception
    java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
    at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
    at java.base/java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
    at java.base/java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
    at SkyWars.Islands.IrIlhas(Islands.java:11) ~[?:?]
    at SkyWars.PreGameTimer$1.run(PreGameTimer.java:103) ~[?:?]
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at java.base/java.lang.Thread.run(Thread.java:831) [?:?]
     
  2. My code

    package SkyWars;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import Main.Main;
    import Utils.LocaisAPI;
    public class Islands {

    public static void IrIlhas() {
    Player p1 = Bukkit.getPlayer(Main.players.get(0));
    Player p2 = Bukkit.getPlayer(Main.players.get(1));
    Player p3 = Bukkit.getPlayer(Main.players.get(2));
    Player p4 = Bukkit.getPlayer(Main.players.get(3));

    LocaisAPI.irLocal(p1, "pos1");
    LocaisAPI.irLocal(p2, "pos2");
    LocaisAPI.irLocal(p3, "pos3");
    LocaisAPI.irLocal(p4, "pos4");
    //LocaisAPI.irLocal(p5, "pos5");
    //LocaisAPI.irLocal(p6, "pos6");
    //LocaisAPI.irLocal(p7, "pos7");
    //LocaisAPI.irLocal(p8, "pos8");

    }
    }
     
  3. Read your error java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
     
  4. It's trying to get an object from a position that doesn't exist. Think of a list with 5 elements, in case you want to get the sixth one, but how do you get something that doesn't exist? Plugin error.

    Regards,
    Eng. Caio Vinicius.
     
  5. I already added the player to the ArrayList, but it still gives an error