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( ~[?:?]
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex( ~[?:?]
    at java.base/jdk.internal.util.Preconditions.checkIndex( ~[?:?]
    at java.base/java.util.Objects.checkIndex( ~[?:?]
    at java.base/java.util.ArrayList.get( ~[?:?]
    at SkyWars.Islands.IrIlhas( ~[?:?]
    at SkyWars.PreGameTimer$ ~[?:?]
    at ~[spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat( [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B( [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B( [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A( [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at [spigot_server.jar:git-Spigot-db6de12-18fbb24]
    at java.base/ [?:?]
  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.

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