PlayerJoinEvent not triggering

Discussion in 'Spigot Plugin Development' started by CyberSoul, Jun 30, 2016.

Thread Status:
Not open for further replies.
  1. I recently posted a thread on here with a very similar issue. The major difference between the two is that in my previous issue all of my Events were not getting triggered. Now my JoinEvent isn't triggering and joinging the server brings up console errors.
    Here is the PlayerJoinEvent:
    Code (Text):
        @EventHandler
        public void onJoin(PlayerJoinEvent e) {
         
            Player player = e.getPlayer();
         
            player.teleport((Location) plugin.getConfig().get("spawn"));
         
            if (!player.hasPlayedBefore()) {
                e.setJoinMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Welcome, " + player.getName() + " to " + ChatColor.DARK_GREEN + "Griscraft!");
                return;
            }
         
            e.setJoinMessage(null);
         
            player.sendMessage(ChatColor.GOLD + "Welcome to " + ChatColor.DARK_GREEN + "Griscraft");
         
        }
    Here are the console errors (Note, I saw WorldGuard was having the same console errors appear for it as well):
    Code (Text):
    [23:09:55 ERROR]: Could not pass event PlayerJoinEvent to HubPlugin v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-5391d73-287ef78]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-5391d73-287ef78]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-5391d73-287ef78]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.PlayerList.onPlayerJoin(PlayerList.java:333) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.PlayerList.a(PlayerList.java:159) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.LoginListener.b(LoginListener.java:144) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.LoginListener.E_(LoginListener.java:54) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:233) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.ServerConnection.c(ServerConnection.java:140) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:832) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:672) [spigot.jar:git-Spigot-5391d73-287ef78]
            at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:571) [spigot.jar:git-Spigot-5391d73-287ef78]
            at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]
    Caused by: java.lang.NullPointerException
            at org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer.teleport(CraftPlayer.java:475) ~[spigot.jar:git-Spigot-5391d73-287ef78]
            at org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity.teleport(CraftEntity.java:226) ~[spigot.jar:git-Spigot-5391d73-287ef78]
            at me.cybersoul.hubplugin.PlayerListener.onJoin(PlayerListener.java:32) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
            at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-5391d73-287ef78]
            ... 14 more
    Nevermind... For some reason the spawn location was not set in the config file. I fixed it
     
  2. You probably can't teleport a player when they first join. Try putting it inside a scheduler for like 5 ticks later.

    Either that or the location in the config is null. When setting the location did you do config.set("spawn", locationObject);?
     
    • Funny Funny x 1
Thread Status:
Not open for further replies.