Trying to make a stats system

Discussion in 'Plugin Development' started by born2kill_, Aug 8, 2014.

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

    born2kill_

    I am trying to create a stats system, but I cannot figure out how.
    My main stats class: http://pastebin.com/qt9LR1Hp
    My command class: http://pastebin.com/GCf0XG2d
    When I try to execute my '/stats' command, die, or win an lms, there are a bunch of errors in console. Here is a screenshot (because I don't know how to copy and paste things from the console xD):
    Show Spoiler

    [​IMG]

    Also, after getting a kill, and whatnot, it does not set a value for the player that got a kill, instead, it just shows the errors in console.
    Help would be appreciated.
    -born2kill
     
  2. Offline

    fireblast709

  3. Offline

    born2kill_

  4. Offline

    ClassyInvader69

    born2kill_ I need your CommandKill class to help you.
     
  5. Offline

    born2kill_

    My CommandKill class just implements CommandExecutor, and all it does is sets the players health to 0 if you specify no arguments, if you do specify another argument, it kills the player that is specified.
    The CommandKill class is irrelevant because the error is also thrown when a zombie kills me, or another player.
    But here you go anyway: http://pastebin.com/kAgFpuZ9
     
  6. Offline

    stormneo7

    I can already tell that you didn't register your class 'cause each class is missing their self variable.

    Register your stuff using after creating your variables.
    Bukkit.getServer().getPluginManager().registerEvents(new class, this);
    getCommand("commandName").setExecutor(new class);
     
  7. Offline

    fireblast709

    born2kill_ oh the player didn't die because of another Player, thus killer is null
     
  8. Offline

    born2kill_

    What do you mean? I have registered my class, look in my main class: http://pastebin.com/riVU3e4y

    Ohh, so if a player comes on and kills me, it will work.
    Testing, thanks =D

    So the kills and deaths does increase, but when I execute the command it still throws an error?

    Hm, well it seems to work now after the tweaking of the PlayerDeathEvent code, here's what I have now if anyones interested:
    Code:
    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent e) {
    Player p = e.getEntity();
    if(p.getKiller() == null) {
    setDeaths(p, getDeaths(p) + 1);
    return;
    }
    Player killer = e.getEntity().getKiller();
    setKills(killer, getKills(killer) + 1);
    setDeaths(p, getDeaths(p) + 1);
    }
    
    There is a problem, to get the KDR, you need two values, the kills and deaths, if the person does not kill anyone, a kill value isn't set, if a person doesn't die, a value isn't set. So how can I check if a path exists and if not just set it to 0?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  9. Offline

    stormneo7

    born2kill_
    Check if sender is a player first in your command. Console cannot /kill
    Also, if it gives an error, how about you give us the error that it gives? It'll help a lot.
     
  10. Offline

    born2kill_

    Well how about you read my latest replies? 'Hm, well it seems to work now after the tweaking of the PlayerDeathEvent code, here's what I have now if anyones interested:'.
     
Thread Status:
Not open for further replies.

Share This Page