Problem with plugin

Discussion in 'Plugin Development' started by elo1233, Aug 16, 2021.

  1. Offline

    elo1233

    Hi, I'm doing a plugin that saves the player's kills to the config and I get such an error:

    Console:
    Code:
    [19:18:32 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'zabojstwa' in plugin BombaCraft v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[servert.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[servert.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [servert.jar:git-Spigot-db6de12-18fbb24]
            at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
            at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [servert.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [servert.jar:git-Spigot-db6de12-18fbb24]
            at java.base/java.lang.Thread.run(Thread.java:829) [?:?]
    Caused by: java.lang.NullPointerException
            at pl.jedzius.commands.Zabojstwa.onCommand(Zabojstwa.java:29) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[servert.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
    Zabojstwa.java
    Code:
    Main plugin;
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = (Player) sender;
    Map<String, Integer> kills = new HashMap<String, Integer>();
    for(OfflinePlayer p : Bukkit.getOfflinePlayers()) {
    UUID uuid = p.getUniqueId();
    kills.put(p.getName(), plugin.getConfig().getInt(uuid + ".Kills"));
    }
    AtomicInteger counter = new AtomicInteger();
    kills.entrySet()
    .stream()
    .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
    .limit(10)
    .forEach(e -> {String num = counter.incrementAndGet() + ". ";
    player.sendMessage(ColorUtil.fixColor("&7" + num + "&e" + e.getKey() + "&7: &e" + e.getValue()));
    });
    return false;
    }
    What to do to fix this error?
    Thanks in advance for your help
     
    Last edited by a moderator: Aug 16, 2021
  2. Offline

    Tim_M

    Can you put line 29 of zabojstwa.java in your post?
     

Share This Page