[GEN/INFO] DeathCounter v1.0.1 - Count your kills [1185]

Discussion in 'Inactive/Unsupported Plugins' started by krinsdeath, Jul 10, 2011.

  1. Death Counter v1.0.1
    Count player and monster kills and rank them accordingly​
    V1.0: 1.0.1 - 1.0
    v0.3: 0.3.2 - 0.3.1 - 0.3.0
    v0.2: 0.2.2 - 0.2.1 - 0.2.0
    v0.1: 0.1.4 - 0.1.3 - 0.1.2 - 0.1.1 - 0.1.0
    Important!
    v1.0 adds some new functionality; searching /dc @playername will search for the stats of that player, and print out a list of all of their currently recorded kills.​
    Thanks @ltguide!​
    Also, as a way of lessening I/O operations on larger servers, I disabled updating SQLite on-the-fly for users as they kill mobs. I believe this was the issue (your disks were getting IO locked), and it should help dramatically. The result, however, is that you'll have to wait 30 minutes for updated rankings while using SQLite. YAML remains unaffected, but should also have improved in stability (I also updated the saving methods for YAML as well).​

    Important!: Version 0.2.0 makes the configuration file considerably less complex. It is shown in the config.yml spoiler.
    Important!: If you're upgrading from 0.1.1 to 0.1.2, there are a lot of new keys in the config. It's recommended that you delete your config (or, if you're comfortable editing YML files, copy the new keys from this post in the example config.yml) to get the updated keys.

    Note: Plugin was originally requested by @3ric in this thread.

    Description:
    Ever wanted to keep track of how many pigs you've slaughtered? With this plugin, you can! Permissions is not needed.
    note: I've tried to keep this plugin as lightweight as possible, and SQLite attempts to keep updated player records in memory to prevent writing to and reading from the DB for every kill. If you encounter some issues, let me know. I'm not terribly well versed with SQLite!

    Basic Usage:
    Drop DeathCounter.jar into your plugins directory, and it'll create a folder (DeathCounter) with a configuration file (config.yml), and a user database (currently users.yml). In the future, I will add MySQL. By default, it stores users in YAML, which will be quite sufficient if your server is small (~100 players). SQLite is now supported, and should be used for servers with more than 100 players.

    The config contains some information on how it actually works, as well as a very simple localization setup. It currently only supports the messages in the config, but if it's requested I can set up multiple localizations and persist them by user (without permissions)
    config.yml (open)

    Code:
    # There is really no need for Permissions support, but I will gladly enable it if you need it for whatever reason
    # Some variables can be parsed for the console logger, and are contained within <>
    # <version>         - plugin version
    # <shortname>       - plugin name
    # <fullname>        - plugin name + version
    # <author>          - my name
    settings:
        # if permissions is set to true, players will need the flag 'deathcounter.admin' to access '/deathcount reset [player]'
        permissions: false
        # if economy is set to true, players will earn money for each kill based on the values in this config
        economy: false
        # the time (in minutes) between full saves of the user database
        save_interval: 30
        # the amount of lines to display when a user types '/deathcount leaders' or '/deathcount [mob name]' without a number
        leaderboard: 5
        # the prepended message on log entries
        log: '[<fullname>] '
        # log_verbosity:
        # 0     - Logging will be disabled for everything but errors
        # 1     - Standard log messages will be output (onEnable, onDisable, errors) (default)
        # 2     - More messages (user database saving and user creation)
        # 3     - Absolutely everything will be logged
        log_verbosity: 1
        storage:
            # Currently only YAML and SQLite will work
            # Will add MySQL at some later date
            type: 'YAML'
            info:
                # this entry is used only for YAML. you can specify your own users file name if you wish.
                # note: if you want to specify a directory, please create it before hand, and do not supply a leading slash
                filename: 'users.yml'
                # The following information only applies to MySQL
                database: 'users'
                server: 'localhost'
                port: 3306
                username: 'username'
                password: 'password'
    
    economy:
        pig: 0.0
        sheep: 0.0
        cow: 0.0
        squid: 1.0
        chicken: 0.0
        spider: 5.0
        skeleton: 2.0
        zombie: 2.0
        creeper: 7.0
        ghast: 5.0
        pigzombie: 5.0
        wolf: 3.0
        slime: 1.0
        player: 10.0
    
    messages:
        header: 'Leaders -Top <num>- (<field>)'
        first_rank: '#<rank> - <name> (<kills>)'
        second_rank: '#<rank> - <name> (<kills>)'
        third_rank: '#<rank> - <name> (<kills>)'
        other_rank: '#<rank> - <name> (<kills>)'
        own_rank: '--- #<rank> - <name> (<kills>) ---'
    

    Permissions (open)

    This plugin uses the following permissions:
    • deathcounter.admin - Gives access to /deathcount reset [player]
    • deathcounter.users - Gives access to /deathcount leaders AND /deathcounter [mobname] - Defaults to true
    This plugin also defines the following nodes for convenience:
    • deathcounter.* - Gives access to everything. - Sets deathcounter.admin, deathcounter.users

    Screenshots (open)

    [​IMG]

    Commands:
    • /deathcount leaders [num] - Will display a message containing the top kill leaders up to [num], as well as your location in the leaderboard
    • /deathcount [mobname] [num] - Same as leaders, will display the top [num] kill leaders for the specified monster, as well as your location in the leaderboards.
    • admins: /deathcount reset [player] - Will delete a player from the database.
    Features:
    • Track player and monster kills
    • Leaderboards for total kills and individual monsters
    • SQLite and Flatfile database support
    • Permissions support! (optional)
    • iConomy support! (optional)
    TODO:
    • MySQL
    Versions:
    Version 1.0.1:
    • Removed deprecated EntityDamageByProjectileEvent
    Version 1.0:
    • Switched from Register to AllPay v3.0
    • Now supports iConomy 4/5/6, RealEconomy, MultiCurrency, BOSEconomy 6/7, Essentials Eco
    • Factored in pull request from ltguide to include @playername functionality for searches.
    • Moved plugin to load: startup to ensure economy hooking.
    • Additional bug and glitch fixes.
    Version 0.3.2:
    • Refactored com.nijikokun.register to net.krinsoft.register to prevent conflicts
    Version 0.3.1:
    • Switched from iConomy to Register; all major economies are now supported, including BOSE 6 & 7, iConomy 4 & 5, Essentials Economy, and Multi-currency
      • Register is included in the source code, and as such does not require any outside libraries. The plugin will attempt to hook the first economy plugin it finds.
    • Minor bugfix and code cleanup
    • Moved to maven
    Changelog(old) (open)

    Version 0.3.0:
    • Removed all dependencies on Permissions, the plugin uses Superperms now.
    • Permissions 2.x and 3.x (and possibly GM and PEX) will still work
    • /deathcount now has 2 aliases, /dc and /deathcounter, which (when used without parameters) will display the top 5 leaders. As such, /deathcount leaders is no longer necessary, but still works.
    0.2.2:
    • Added iConomy support
    • Lessened I/O operations for large servers, which I believe were getting IO locked
    0.2.1:
    • Fixed spiders not being tracked.
    • General code cleanup
    0.2.0:
    • Finished SQLite support
    • Added Permissions (optional). Flag is 'deathcounter.admin' (permissions is off by default)
    • Reorganized the entire project from scratch. It's more module-like, so I can add new features much more easily.
    0.1.4:
    • Added SQLite support
    0.1.3:
    • Added a hardcoded limit to the number of loops displayed by /deathcount leaders. It will not exceed 10 loops.
    • minor code cleanup
    • Added a configurable location for the users.yml (in fact, the name of the file can even be changed) in config.yml. Should allow for symlinking or any number of useful features
    0.1.2:
    • Added /deathcount reset for admins.
    • Added quiet_plugin field in config.yml - setting this to true will disable "You killed a [target]!" messages.
    • Cleaned up code.
    • More localization flags
    0.1.1:
    • Fixed a few bugs
    • Added support for EntityDamageByProjectileEvent
    • Players should now be tracked properly
    • Added quiet_save field in config.yml - setting this to true will disable log messages stating that the users.yml has been updated.
    0.1.0:
    • Initial release

    Special thanks to:

    3ric for his support
     
  2. Offline

    3ric

    Thanks again for this :)

    When will it be completed?

    Edit: When someone else tries /deathcount leaders [num] it shows the entire list.
     
  3. What do you mean?
     
  4. Offline

    mineversus

    I've been waiting for a long time this plugin.
    Nice plugin ! Thank you man !
    No probleme for 1.7.2 !

    I have 3 suggestions :
    Add a function to ignore op's stats.
    Create Admin command, for example for reset a player.
    Add rewards when a player kill 500 cow for example. ( Connection with Iconomy or give something).
     
  5. Offline

    spunkiie

    REQ: Please make possible to DISABLE (or customize) "You killer a player" message!
     
  6. 0.1.2 is released. I added a few new things, including /deathcount reset [player] for admins, Permissions support (but it is unneeded), and a key in the config called quiet_plugin that will disable the "You killed a [target]!" messages.

    Feedback appreciated.
     
  7. Offline

    spunkiie

    @krinsdeath
    I'm running 0.1.2 on my 400+ server. The plugin seems to be working for some players, but for other the counter is stalled.

    I did a quick test: killed two players, but was still showing '0' kills in the ranking. Had a similar issue with 'hunger' plugin, that, FYI used flat files as well.

    Hope it helps.
     
  8. By "400+" what exactly do you mean?

    Also, how much RAM is allocated to the server? And what save_interval did you specify in the config (did you leave it at 30, or specify some other value?)

    You may get better success by lowering the save interval to some low value (1? 5?), since that will force a save of the file at those times.

    Other than that, if you mean you're running a server of 400+ people I can't really guarantee the plugin's stability/success. It may be that you'll have to wait for me to finish SQLite or MySQL for stability. :x
     
  9. Offline

    mineversus

    [SEVERE] Could not pass event ENTITY_DEATH to DeathCounter

    2011-07-11 13:38:35 [INFO] [DeathCounter v0.1.0] willzoo saved to users.yml
    2011-07-11 13:38:43 [INFO] [DeathCounter v0.1.0] willzoo saved to users.yml
    2011-07-11 13:38:57 [INFO] [DeathCounter v0.1.0] Nemos44 saved to users.yml
    2011-07-11 13:39:02 [INFO] [DeathCounter v0.1.0] Nemos44 saved to users.yml
    2011-07-11 13:39:06 [INFO] [DeathCounter v0.1.0] Nemos44 saved to users.yml
    2011-07-11 13:39:10 [INFO] [DeathCounter v0.1.0] Nemos44 saved to users.yml
    2011-07-11 13:39:18 [INFO] [DeathCounter v0.1.0] Nemos44 saved to users.yml
    Problem with save ? Interval 30sec
     
  10. Offline

    3ric

    When one of my admins used
    /deathcounter leaders 5
    it spammed his window with the entire list.
     
  11. Offline

    spunkiie

    Yeap, our server has 400+ players almost all the time. We have more than 8GiB of free RAM, so RAM is not a problem.

    Will try lowering save_interval.

    Thank you :)
    BTW: Can't wait for SQLITE support
     
  12. @3ric - I was unable to replicate your glitch, but I added a loop counter that will not allow more than 10 leaders to be displayed at once. This should prevent something like that from happening. It's in 0.1.3, and is up now.

    @mineversus - The kill counter attempts to save the user to memory every time a kill is made, and then reports it in the log. If you want to disable that reporting (and the reporting of almost any other message), just set quiet_plugin to true in the config.yml.

    @spunkiie - A possible solution is going to be a configurable user directory where users.yml will be saved. While this is (in itself) not a solution, you could symlink the directory into shared memory (/dev/shm for linux) or a RAMDISK on Windows.. obviously you'd have to write a backup script (either a crontab or some scheduled task), but theoretically this would drop file IO to very little and increase throughput by a lot.
     
  13. Offline

    spunkiie

    @krisndeath
    Hmm, will try that too.

    FYI:
    Installed the plugin about 15 hours ago, here's what I have now
    users.yml has 408KB and 29.843 entries :D

    I've just noticed now. My server console is getting alot of:

    2011-07-11 16:27:25 [SEVERE] Could not pass event PLAYER_LOGIN to DeathCounter
    java.lang.ClassCastException

    also:

    :Could not pass event PLAYER_QUIT to DeathCounter

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  14. Is that the entire error? I can't really tell what's going wrong from that.
     
  15. Offline

    spunkiie

    Yeap, weird but this is the only thing in server.log
     
  16. Update: I've almost got SQLite sorted out. A few more things to go before it is ready for release, but not too long!

    I've actually got most of the functionality finished, I just need to make sure there's no NullPointers that I missed. Should be ready sometime on 07/12.
     
  17. Offline

    compgurusteve

    sorry for thread jacking. post deleted.
     
  18. Offline

    spunkiie

    @krinsdeath

    Can't wait. Had to disable the plugin on my server... but ppl are begging for him :D
     
  19. 0.1.4 is now out! I have a few things to iron out, but the functionality should be there. I can't really test it locally with the sample size you all have, so I may miss things.

    As always, feedback and error reports! (please be specific and verbose)
     
  20. Offline

    compgurusteve

    This error appears when a player connects to the server:

    Could not pass event PLAYER_LOGIN to DeathCounter
    java.lang.NullPointerException
    at net.krinsoft.deathcounter.DeathPlayer.load(DeathPlayer.java:32)
    at net.krinsoft.deathcounter.DeathPlayer.<init>(DeathPlayer.java:19)
    at net.krinsoft.deathcounter.DataManager.insert(DataManager.java:127)
    at net.krinsoft.deathcounter.PListener.onPlayerLogin(PListener.java:82)
    at org.bukkit.plugin.java.JavaPluginLoader$12.execute(JavaPluginLoader.java:321)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:321)
    at net.minecraft.server.ServerConfigurationManager.a(ServerConfigurationManager.java:184)
    at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:82)
    at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:33)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:91)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)

    Latest RB and latest plugin version.
     
  21. Haha. Thanks. Dumb mistake! Re-uploaded the jar. Should be fixed.

    Alright! Version 0.2.0 is done! It finishes up SQLite support, fixes the ability for admins to delete users from the DB with SQLite, and generally makes it more stable and lightweight.

    As always, bug reports should be verbose and include server.logs, plugin version and craftbukkit build (not just "latest," try to be specific :X)

    Thanks a bunch for your support!

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

    spunkiie

    Updating now

    #953

    btw: the CommandHelper in LOG happens because we are using an /alias to run /deathcount leaders

    2011-07-13 04:00:46 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'deathcount' in plugin DeathCounter v0.2.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:298)
    at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:711)
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:676)
    at org.bukkit.craftbukkit.entity.CraftPlayer.chat(CraftPlayer.java:144)
    at com.laytonsmith.aliasengine.AliasCore$1.done(AliasCore.java:92)
    at com.laytonsmith.aliasengine.Script.run(Script.java:101)
    at com.laytonsmith.aliasengine.AliasCore.alias(AliasCore.java:83)
    at com.sk89q.commandhelper.CommandHelperListener.runAlias(CommandHelperListener.java:88)
    at com.sk89q.commandhelper.CommandHelperListener.onPlayerCommandPreprocess(CommandHelperListener.java:132)
    at org.bukkit.plugin.java.JavaPluginLoader$5.execute(JavaPluginLoader.java:272)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:321)
    at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:704)
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:676)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:669)
    at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:84)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.NullPointerException
    at net.krinsoft.deathcounter.types.Leaderboards.playMessage(Leaderboards.java:117)
    at net.krinsoft.deathcounter.types.Leaderboards.fetchSqlite(Leaderboards.java:91)
    at net.krinsoft.deathcounter.listeners.CommandListener.onCommand(CommandListener.java:42)
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
    ... 23 more

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  23. Because of the nature of SQLite, I had to change the configuration file. I think that's caused by some field being null now.

    the "messages" section of the config file, in particular, may have changed format. It is much simpler now. It should look something like this:

    Code:
    messages:
        header: 'Leaders -Top <num>- (<field>)'
        first_rank: '#<rank> - <name> (<kills>)'
        second_rank: '#<rank> - <name> (<kills>)'
        third_rank: '#<rank> - <name> (<kills>)'
        other_rank: '#<rank> - <name> (<kills>)'
        own_rank: '--- #<rank> - <name> (<kills>) ---'
    
    also, can you let me know what you typed in?

    @spunkiie - Ah. I found the problem. Redownload the jar. Sorry! I only have me on my local tests, so I can't test with many users. The problem was that instead of "other_rank" in my message parser, I had "fourth_rank". Not sure why.

    for reference?

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

    spunkiie

    @krinsdeath

    Downloaded 0.2.0 again, now I'm getting this error:

    2011-07-13 12:56:05 [SEVERE] java.sql.SQLException: no such column: total
    2011-07-13 12:56:05 [SEVERE] at org.sqlite.NativeDB.throwex(NativeDB.java:210)
    2011-07-13 12:56:05 [SEVERE] at org.sqlite.NativeDB._exec(Native Method)
    2011-07-13 12:56:05 [SEVERE] at org.sqlite.Stmt.executeUpdate(Stmt.java:152)
    2011-07-13 12:56:05 [SEVERE] at net.krinsoft.deathcounter.types.DeathPlayer.updateSqlite(DeathPlayer.java:444)
    2011-07-13 12:56:05 [SEVERE] at net.krinsoft.deathcounter.types.DeathPlayer.update(DeathPlayer.java:351)
    2011-07-13 12:56:05 [SEVERE] at net.krinsoft.deathcounter.types.DeathPlayer.add(DeathPlayer.java:115)
    2011-07-13 12:56:05 [SEVERE] at net.krinsoft.deathcounter.listeners.EntityEventListener.onEntityDeath(EntityEventListener.java:43)
    2011-07-13 12:56:05 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader$56.execute(JavaPluginLoader.java:635)
    2011-07-13 12:56:05 [SEVERE] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    2011-07-13 12:56:05 [SEVERE] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:321)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.EntityLiving.q(EntityLiving.java:467)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.EntityLiving.die(EntityLiving.java:447)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.EntityLiving.damageEntity(EntityLiving.java:391)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.EntityHuman.d(EntityHuman.java:561)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:856)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.Packet7UseEntity.a(SourceFile:33)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:84)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    2011-07-13 12:56:05 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)

    Thank you
     
  25. @spunkiie - that was another sort of "my bad" error. SQLite doesn't track the totals (it adds all the fields together when the data is needed). Just a simple "I forgot the return" :(

    I feel really bad that these issues are coming about and I don't notice them. Anyway, jar is fixed. Redownload again. ;_;
     
  26. Offline

    3ric

    Can all players use /deathcount [mob] or /deathcount leaders ?
     
  27. they should be able to, as long as they exist in the configuration (to prevent null pointers). Do you want to disable that?

    It'd be relatively simple (permissions check or isOp()).
     
  28. Offline

    spunkiie

    Downloadin' again :D

    @krinsdeath

    0.2.0 / #953 / SQLite

    No more console erros :)
    But something seens weird. Look at my output:

    :Top 5 Kills- (leaders)
    :#1 - KanOkumura (0)
    :#2 - Plank (17)
    :#3 - Zodiee (0)
    :#4 - Vitor677 (0)
    :#5 - joaojacober (0)

    I mean, player with ZERO kills above player with '17' ? hmm. Also the counter seens 'stalled' (just like when I was using flatfile storage)

    BTW: After redownloading I *deleted* the old deathcount directory and let the plugin recreate it again.

    Hope it helps

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  29. I can't really think of any way to optimize it further, aside from hardcoding a limit to the number of people that can be tracked by the plugin at once (somewhere in the realm of 250), which is probably not what you're looking for.

    As for the leaders being displayed in the wrong order, that's weird. The SQLite query shouldn't allow that to happen. o-o

    However! I did find a section where I hardcoded that it always should display "total kills" (regardless if you type in a monster's name), and as such the jar has been updated. As I said before, I only have a sample size of 1 to test the plugin with, so when you find these errors (as they pertain to multiple people), it helps out immensely.

    Thanks for all of your help!
     
  30. Offline

    spunkiie

    Downloading'
     

Share This Page