Array becoming null

Discussion in 'Spigot Plugin Development' started by InfiniteIV, May 4, 2015.

  1. Code (Text):
        public static void startGame(){
            Location[] tS = {
            new Location( Bukkit.getWorld("Teweran"),119.5,91.5,-1189.5),
            new Location( Bukkit.getWorld("Teweran"),118.5,91.5,-1184.5),
            new Location( Bukkit.getWorld("Teweran"),116.5,91.5,-1179.5),
            new Location( Bukkit.getWorld("Teweran"),113.5,91.5,-1175.5),
            new Location( Bukkit.getWorld("Teweran"),109.5,91.5,-1172.5),
            new Location( Bukkit.getWorld("Teweran"),104.5,91.5,-1170.5),
            new Location( Bukkit.getWorld("Teweran"),99.5,91.5,-1169.5),
            new Location( Bukkit.getWorld("Teweran"),94.5,91.5,-1170.5),
            new Location( Bukkit.getWorld("Teweran"),89.5,91.5,-1172.5),
            new Location( Bukkit.getWorld("Teweran"),85.5,91.5,-1175.5),
            new Location( Bukkit.getWorld("Teweran"),82.5,91.5,-1179.5),
            new Location( Bukkit.getWorld("Teweran"),80.5,91.5,-1184.5),
            new Location( Bukkit.getWorld("Teweran"),79.5,91.5,-1189.5),
            new Location( Bukkit.getWorld("Teweran"),80.5,91.5,-1194.5),
            new Location( Bukkit.getWorld("Teweran"),82.5,91.5,-1199.5),
            new Location( Bukkit.getWorld("Teweran"),85.5,91.5,-1203.5),
            new Location( Bukkit.getWorld("Teweran"),89.5,91.5,-1206.5),
            new Location( Bukkit.getWorld("Teweran"),94.5,91.5,-1208.5),
            new Location( Bukkit.getWorld("Teweran"),99.5,91.5,-1209.5),
            new Location( Bukkit.getWorld("Teweran"),104.5,91.5,-1208.5),
            new Location( Bukkit.getWorld("Teweran"),109.5,91.5,-1206.5),
            new Location( Bukkit.getWorld("Teweran"),113.5,91.5,-1203.5),
            new Location( Bukkit.getWorld("Teweran"),116.5,91.5,-1199.5),
            new Location( Bukkit.getWorld("Teweran"),118.5,91.5,-1194.5)
            Arena ar  = Voting.getFinalAnswer();
            int i = 0;
            arena  = ar;
            for(Player p: Bukkit.getOnlinePlayers()){
                    i= 0;
    The array was returning null when it belonged to the map {This is the only map for now} so I decided to try to debug it and found that it wasn't the arena that was turning it to null, it just was null itself. The exception happens at p.teleport(tS);
    Code (Text):
    [09:48:54 WARN]: [SRSG] Task #6 for SRSG v1.0.4 generated an exception
            at org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer.teleport( ~[spigot.jar:git-Spigot-2ec6f06-7722428]
            at org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity.teleport( ~[spigot.jar:git-Spigot-2ec6f06-7722428]
            at net.mcsro.SG.utils.GameManager.startGame( ~[?:?]
            at ~[?:?]
            at ~[spigot.jar:git-Spigot-2ec6f06-7722428]
            at org.bukkit.craftbukkit.v1_8_R2.scheduler.CraftScheduler.mainThreadHeartbeat( [spigot.jar:git-Spigot-2ec6f06-7722428]
            at net.minecraft.server.v1_8_R2.MinecraftServer.A( [spigot.jar:git-Spigot-2ec6f06-7722428]
            at net.minecraft.server.v1_8_R2.DedicatedServer.A( [spigot.jar:git-Spigot-2ec6f06-7722428]
            at net.minecraft.server.v1_8_R2.MinecraftServer.z( [spigot.jar:git-Spigot-2ec6f06-7722428]
            at [spigot.jar:git-Spigot-2ec6f06-7722428]
            at [?:1.7.0_75]
    GameManager 34 is p.teleport
    and Countdown 17 is GameManager.startGame();
    #1 InfiniteIV, May 4, 2015
    Last edited: May 4, 2015
  2. Try checking if Bukkit.getWorld("Teweran") returns null also as it may be possible that the world does not exist or is not recognized by the server.
  3. Yeah, Teweran is null, just checked. I have no idea why it is though, I've added the world to SP to add the spawns and that worked fine but when I add the folder to the server it doesn't work.
  4. I think it's because spigot does not support multiple worlds. Try loading you server with Multiverse. It's a plugin that adds support for multiple worlds.
  5. or try loading worlds by using bukkit.yml:
  6. gigosaurus


    Of course spigot supports multiple worlds - how else would Multiverse (a bukkit/spigot plugin) create them? :p

    Code (Java):
    should do the trick.
    #6 gigosaurus, May 4, 2015
    Last edited: May 4, 2015
  7. I've used that but it still is null. I've tried loading the world into a server with Multiverse aswell but everytime I tried importing the world, it would fail.

    EDIT: I just tried it onto another world, it worked so after I imported it, I removed the old world folder in the SG server's files and moved it there, the map is still null.
  8. Sorry, I thought Multiverse played around with the stuff :p

    I think a lot of debugging is due.
  9. gigosaurus


    Or just load the world like how I said... It even eliminates the need for MultiVerse (unless you have some other purpose for it).
  10. I just installed multiverse on the server, it took me to Teweran but my lugin still says it is null.
    @gigosaurus wouldn't that create the world instead?
    EDIT: I just tried yours gigo, it still didn't work, Teweran is null.
    #10 InfiniteIV, May 4, 2015
    Last edited: May 4, 2015
  11. gigosaurus


    It creates the world inside Bukkit from the already existing world files (or creates the world files if they don't already exist).
    Just make sure you have the world in the correct directory.
    #11 gigosaurus, May 4, 2015
    Last edited: May 4, 2015
  12. After the Bukkit.createWorld Tweweran was not null but when I called I tried to teleport the players to the locations it was null.
  13. set it as an default world?
  14. gigosaurus


    Are you creating the location array after you've created the world? If not then that's your problem.
  15. The default world is the lobby world, that's an arena.
    Just fixed it, that was the problem, I defined the arenas at the start of the on enable and created Teweran at the end, thanks!