1.16.5 NPE when ban expires using the BanList

Discussion in 'Spigot Plugin Development' started by Nemo_64, Jul 1, 2021.

  1. I'm using the BanList to ban players. When the ban expires and I try to join I get this error on the client Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: Index: 25, Size: 5 the first time I join, the second time I just join without errors. On the console appears this error
    Code (Java):
    java.lang.NullPointerException: null
            at net.minecraft.server.v1_16_R3.PlayerList.attemptLogin(PlayerList.java:584) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.LoginListener.c(LoginListener.java:153) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.LoginListener.tick(LoginListener.java:71) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.NetworkManager.a(NetworkManager.java:229) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.ServerConnection.c(ServerConnection.java:143) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1246) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:394) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1127) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:966) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_291]
    That's the whole error. I'm using the lastest version of spigot 1.16.5 built with builtools. I use the BanList like this
    Code (Java):
        public boolean ban(String reason, long unban, String source) {
            if (unban <= System.currentTimeMillis())
                return false;
            OfflinePlayer of = getOfflinePlayer();
            if (of.getName() == null)
                return false;
            Bukkit.getBanList(BanList.Type.NAME).addBan(of.getName(), reason, new Date(unban), source);
            return true;
        }

        public OfflinePlayer getOfflinePlayer() {
            return Bukkit.getOfflinePlayer(getPlayer());
        }
    getPlayer() just returns an UUID
     
    #1 Nemo_64, Jul 1, 2021
    Last edited: Jul 2, 2021
  2. Hey!
    In your first sentence you said that it throws an "Internal Exception" and in the exception you have posted after that its a NullPointer.
    Maybe it isn't the whole exception or its the wrong one.
     
  3. The first exception is the one that appears on the client, the second one the one that appears on console. That's the whole error. Sorry if I didn't explain myself
     
  4. I've been trying changing things on my code to see if something changed but nothing so I tryed to create a command that would ban the sender for 15 seconds
    Code (Java):
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = (Player) sender;
            Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(), "Testing banlist",
                    new Date(System.currentTimeMillis() + 15000), "Test");
            player.kickPlayer("Testing");
            return false;
        }
    And I had the same result, the error appears. Then I realised that the doc says
    So I changed to
    Code (Java):
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = (Player) sender;
            Bukkit.getBanList(BanList.Type.NAME).addBan(player.getUniqueId().toString(), "Testing banlist",
                    new Date(System.currentTimeMillis() + 15000), "Test");
            player.kickPlayer("Testing");
            return false;
        }
    But same result, I get the error. Is there something I'm missing or is this a minecraft/spigot bug? I highly doubt it being a bug considering that 1.16.5 has been arround for some time.
    I could really use some help here, thanks!