Error when dissalowing 1.8+ players to join

Discussion in 'Spigot Plugin Development' started by Lookups, Jul 11, 2018.

  1. Hello, i'm trying to make a plugin that dissalows players to join if they are on a 1.8+ client,
    however i'm getting an error (EVENTEXCEPTION) & (NPE - NULLPOINTEREXCEPTION):

    Code (Text):
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[TapSpigot.jar:git-PaperSpigot-ea452ce]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[TapSpigot.jar:git-PaperSpigot-ea452ce]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:494) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.PlayerList.attemptLogin(PlayerList.java:455) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.LoginListener.c(LoginListener.java:98) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.LoginListener.a(LoginListener.java:44) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:192) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:794) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:307) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:642) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:548) [TapSpigot.jar:git-PaperSpigot-ea452ce]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [TapSpigot.jar:git-PaperSpigot-ea452ce]
    Caused by: java.lang.NullPointerException
            at nv6.invisraid.listeners.JoinEvent.onLogin(JoinEvent.java:19) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[TapSpigot.jar:git-PaperSpigot-ea452ce]
            ... 13 more
    Code of Line 19 & The whole loginclass


    Code (Text):

       
        @EventHandler
        public void onLogin(PlayerLoginEvent event) {
          CraftPlayer player = (CraftPlayer) event.getPlayer();
          if (((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47) {
            event.disallow(Result.KICK_BANNED, "§cSorry, your client version is not supported by our server.\n§cPlease consider using Minecraft 1.7.\n§7This is due to issues with the 1.8+ clients.");
          } else {
              if (((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() < 47) {
                  player.sendMessage("§cThis server is using the plugin called §9InvisRaid §7b1.1 §cmade by NV6");
              }

          }
        }

    }
     
    Help would be appriciated!
     
    • Funny Funny x 3
  2. If you're running on a 1.7 server, then why would 1.8 players be able to join in the first place? If you only want 1.7 players remove whatever plugin allows them to connect. Simple?
     
    • Agree Agree x 1
  3. gzx

    gzx

    Try using PlayerJoinEvent instead of PlayerLoginEvent. It's possible that the networkManager is not initialized until after the players logs in.
     
  4. Mh, i'm using a 1.7.10 spigot, I don't have plugins that allow 1.8 players to join.
     
  5. gzx

    gzx

    Then 1.8 players won't be able to join your server. You don't need to make a plugin to block those clients.