Solved Why this error on a repeating task?

Discussion in 'Plugin Help/Development/Requests' started by metincasper, Jan 7, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    metincasper

    Hi
    I get this error when i use the repeating task.
    Code:
    [20:02:18 WARN]: [OneShotOneKill] Task #229 for OneShotOneKill v1.0 generated an
    exception
    java.lang.NullPointerException
            at me.xXCalleManXx.osok.countdown$1.run(countdown.java:43) ~[?:?]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java
    :71) ~[craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHea
    rtbeat(CraftScheduler.java:346) [craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:6
    38) [craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    89) [craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [craftbukkit-1.7.2-R0.2.jar:git-Spigot-1571]
    >
    Here is my task:

    Code:
        public void counter() {
           
            p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
                     public void run() {
                         timer -= 1;
                        
                         if (timer <= 10) {
                             Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE.toString() + ChatColor.BOLD.toString() + timer + "" + ChatColor.GREEN + " sekunder til start");                        
                         }
                        
                         if (timer == 0) {
                             Bukkit.broadcastMessage(ChatColor.GREEN + "Gooo!!");
                             Bukkit.getScheduler().cancelAllTasks();
                             ttt.StartTeleportManager();
                             c.saveConfig();
                             timer = 11;
                         }
                     }
            }, 0, 20);
        }
    Line 43 in the countdown class is this:
    Code:
    ttt.StartTeleportManager();
    And here is what i try to call:
    Code:
        public final void StartTeleportManager() {
            for (Player pp : Bukkit.getOnlinePlayers()) {
                if (blueteam().hasPlayer(pp)) {
                    World w = p.getServer().getWorld(c.getConfig().getString("Teams.blue.locations.start-lobby.world"));
                    double x = c.getConfig().getDouble("Teams.blue.locations.start-lobby.x");
                    double y = c.getConfig().getDouble("Teams.blue.locations.start-lobby.y");
                    double z = c.getConfig().getDouble("Teams.blue.locations.start-lobby.z");
                    pp.teleport(new Location(w, x, y, z));
                    return;
                }else if(redteam().hasPlayer(pp)) {
                    World w = p.getServer().getWorld(c.getConfig().getString("Teams.red.locations.start-lobby.world"));
                    double x = c.getConfig().getDouble("Teams.red.locations.start-lobby.x");
                    double y = c.getConfig().getDouble("Teams.red.locations.start-lobby.y");
                    double z = c.getConfig().getDouble("Teams.red.locations.start-lobby.z");
                    pp.teleport(new Location(w, x, y, z));
                    return;
                }else{
                    pp.sendMessage(ChatColor.RED + "Der skete en fejl.");
                    return;
                }
            }
        }
    I'm not sure if the "StartTeleportManager" method has to be final.
     
  2. Offline

    PreFiXAUT

    @metincasper Sure your Variable ttt isn't just null/uninitalized?
    With this, you'ld cancel ALL Tasks (who would guessed) which would also block/damage every other Plugin which is using Bukkit-Tasks, so only cancel your own Task.
     
  3. Offline

    metincasper

    The Variable ttt is this:
    Code:
    teams ttt = teams.getInstance();
    How can i stop a single task then?

    Okay, i gat it to work, thanks for the help anyway :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  4. Offline

    mrCookieSlime Retired Staff

    Moved to Plugin Help/Developement/Requests.
     
Thread Status:
Not open for further replies.

Share This Page