I cannot teleport in this world

Discussion in 'Plugin Development' started by monkafynix, Dec 28, 2019.

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

    monkafynix

    Code:
        case STICK:
                        for(Player playerttt: Bukkit.getOnlinePlayers()) {
                            playerttt.closeInventory();
                            Location ttt = Bukkit.getWorld("ttt_world").getSpawnLocation();
                            if(ttt == null)return;                                          
                            player.teleport(ttt);                              
                            playerttt.closeInventory();
                          
                          
                        }                  
                      
                        break;
                        
    I don't wanna post the whole code cause of code yoinking and it's not relevant

    There is this Error as well:
    Code:
     Could not pass event InventoryClickEvent to yeet v1.8.7
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:2133) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:33) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.MinecraftServer.aX(MinecraftServer.java:910) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:903) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeAll(SourceFile:103) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:886) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:820) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
    Caused by: java.lang.NullPointerException
            at de.monkafynix.playthrough.utils.UtilListener.handleNavigatorClick(UtilListener.java:159) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_231]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            ... 17 more
     
  2. Offline

    Strahan

    Is ttt_world valid? You null check the spawn location, but not the getWorld. As you didn't tell us what line 159 is, it's just guesswork.
     
  3. Offline

    monkafynix

    line 159 is the creation of the Location and as well with check if the world is null the error is happening
     
  4. Offline

    KarimAKL

    @monkafynix You are checking if the location is null, that'll never be null as long as it's initialized.
    Bukkit.getWorld("ttt_world") is returning null, then throwing a NullPointerException when you try to get the spawn location from it.
     
  5. Offline

    monkafynix

    Yeah but how can i register the world? I mean else i cannot teleport in the world right?
     
  6. Offline

    KarimAKL

    @monkafynix Get the world, check if it's null, if it isn't null, get the spawn location and teleport to it.
    Do make sure that a world named "ttt_world" exists in your server folder.
     
  7. Offline

    monkafynix

    It isn't working either idk why ,
    the error dissapered
     
  8. Offline

    travja

    Unless you are using Multiverse or a similar plugin and you don't have "ttt_world" as the default world in the server.properties file, ttt_world won't be loaded and you'll therefore get a NullPointerException trying to teleport the player there. You can make your own custom World Loader or sorts, but there's no sense reinventing the wheel when it already exists.

    If you can confirm that the world exists and is loaded in the server and it still isn't teleporting you, I'd add some debug (ie, sending the player messages at different points in your code) so that you can see how far your code is making it along before it breaks. Then we can see the issue and go from there.
     
Thread Status:
Not open for further replies.

Share This Page