Code (Text): https://hastebin.com/miwupitori.md Code (Text): package gg.kisurimc.kitpvp.sumo.event; import java.util.ArrayList; import java.util.List; import gg.kisurimc.kitpvp.Run; import gg.kisurimc.kitpvp.sumo.SumoUtils; import gg.kisurimc.kitpvp.sumo.state.SumoState; import gg.kisurimc.kitpvp.utils.FileUtils; import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; public class SumoStartEvent { private static int count = Run.getInstance().getInstance().getConfig().getInt("lobby-seconds"); private static int taskid; public static ArrayList<Player> host = new ArrayList(); public static List<String> messages = SumoUtils.config.getStringList("event-announce"); public static void StartEvent() { taskid = Bukkit.getScheduler().runTaskTimer(JavaPlugin.getPlugin(Run.class), new BukkitRunnable() { public void run() { for (Player all : Bukkit.getServer().getOnlinePlayers()) { int sec = Run.getInstance().getConfig().getInt("lobby-seconds"); if (SumoStartEvent.count == sec) { try { SumoStartEvent.gameAnnounceMessageFromConfig(all, SumoStartEvent.count, SumoUtils.ply.size(),String.valueOf(SumoStartEvent.host.get(0).getName())); } catch (Exception ex) { ex.printStackTrace(); } SumoState.setState(SumoState.Lobby); try { World w = Bukkit.getWorld(FileUtils.cfg.getString("game.spawn2.world")); w.setPVP(true); } catch (Exception localException1) {} } if ((sec > 60) && (SumoStartEvent.count == 60)) { SumoStartEvent.gameAnnounceMessageFromConfig(all, SumoStartEvent.count, SumoUtils.ply.size(), String.valueOf(SumoStartEvent.host.get(0).getName())); } if ((sec > 30) && (SumoStartEvent.count == 30)) { SumoStartEvent.gameAnnounceMessageFromConfig(all, SumoStartEvent.count, SumoUtils.ply.size(), String.valueOf(SumoStartEvent.host.get(0).getName())); } if (SumoStartEvent.count == 10) { SumoStartEvent.gameAnnounceMessageFromConfig(all, SumoStartEvent.count, SumoUtils.ply.size(), String.valueOf(SumoStartEvent.host.get(0).getName())); } if (SumoStartEvent.count == 5) { SumoStartEvent.gameAnnounceMessageFromConfig(all, SumoStartEvent.count, SumoUtils.ply.size(), String.valueOf(SumoStartEvent.host.get(0).getName())); } } SumoStartEvent.startgame1(); if (SumoStartEvent.count == 0) { for (Player plm : SumoUtils.ply) { Bukkit.getScheduler().cancelTask(SumoStartEvent.taskid); Bukkit.getScheduler().cancelTask(SumoStartEvent.count); plm.teleport(FileUtils.getPreGame()); SumoStartEvent.startgame1(); SumoState.setState(SumoState.InGame); } } } } , 1L, 20L).getTaskId(); } public static ArrayList<Player> players = new ArrayList(); private static ArrayList<Player> gameplayers = new ArrayList(); public static void startgame1() { new BukkitRunnable() { public void run() { for (Player players : SumoUtils.ply) { SumoStartEvent.gameplayers.add(players); } int size = SumoStartEvent.gameplayers.size() - 1; Player p = SumoUtils.ply.get(size); SumoStartEvent.players.add(p); FileUtils.getFirstSpawn(p); size = SumoStartEvent.gameplayers.size() - 2; p = SumoUtils.ply.get(size); SumoStartEvent.players.add(p); FileUtils.getSecondSpawn(p); SumoStartEvent.gameplayers.clear(); } }.runTaskLater(JavaPlugin.getPlugin(Run.class), 100L); } private static void gameAnnounceMessageFromConfig(Player all, int count, int players, String Host) { for (int i = 0; i < messages.size(); i++) { String msg = (String)messages.get(i); // String message = ChatColor.translateAlternateColorCodes('&', msg // .replace("%count%", String.valueOf(count)) // .replace("%players%", String.valueOf(players)) // .replace("%host%", Host) // .replace("%maxplayers%", String.valueOf(SumoJoinEvent.maxplayers))); all.sendMessage("test"); } } } line 37 is Code (Text): SumoStartEvent.gameAnnounceMessageFromConfig(all, SumoStartEvent.count, SumoUtils.ply.size(),String.valueOf(SumoStartEvent.host.get(0).getName()));
At line 37, it seems like you're tying to get line number 0 (which is line 1) but the list is empty. Error: Index: 0, Size: 0 What causes it: SumoStartEvent.host.get(0).getName()
You are accessing an element in an array that doesn’t exist, the arraylist you are trying to access on line 37 is empty Code (Text): SumoStartEvent.host.get(0)
public static ArrayList<Player> host = new ArrayList(); Should i do like if the run the command add them to the array?
What does the host array suppose to contain? Can there only be one host - if so an array probably isn’t a good idea to use It sounds like yeah when they run the command to start the event then yea add them to the array. It’s abit messy if two events are started at the same time (or an event is started while one is running) , you will have problems Yea @yPedx nothing in the code given adds anything to the array
I fixed this than i ran into dis Code (Text): [13:59:10 WARN]: [KitPvP] Task #4 for KitPvP v1.0 generated an exception java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.ArrayList.elementData(Unknown Source) ~[?:1.8.0_161] at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_161] at gg.kisurimc.kitpvp.sumo.event.SumoStartEvent$2.run(SumoStartEvent.java:78) ~[?:?] at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot.jar:git-PaperSpigot-ea452ce] at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot.jar:git-PaperSpigot-ea452ce] at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:700) [spigot.jar:git-PaperSpigot-ea452ce] at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:307) [spigot.jar:git-PaperSpigot-ea452ce] at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:642) [spigot.jar:git-PaperSpigot-ea452ce] at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:548) [spigot.jar:git-PaperSpigot-ea452ce] at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-PaperSpigot-ea452ce] 78 = Code (Text): Player p = SumoUtils.ply.get(size);
Same issue, trying to access an index in the array that doesn’t exist. If you put debug messages In (just print out to console) the value of the variable “size” you may be able to figure it out yourself
Please show your SumoUtils class. I believe size is bigger than the SumoUtils.ply array. Edit: Oof, you just ninja'd me D: