PVP "logger"

Discussion in 'Archived: Plugin Requests' started by failtolawl, Jun 9, 2013.

  1. Offline

    failtolawl

    Plugin category: EXAMPLE

    Suggested name: no idea

    What I want: I want a plugin that logs whenever somebody begins to attack somebody, in order see who hits first during combat.

    Ideas for commands: No commands needed for this plugin.

    When I'd like it by: ASAP
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    failtolawl

  4. Offline

    AndyMcB1

    It's not very extensive. Could you expand on the idea a bit more.
    How would you read the data, would it put it in the console? You've said you don't need commands.
     
  5. Offline

    failtolawl

    It would be the same as if somebody killed somebody, in would show up in the server log, as "player struck player". It's fine if it shows all of the combat in it too, that might be better than just the one person hitting first.
     
  6. Offline

    failtolawl

  7. Offline

    brinaq

    Sounds like a good and useful idea. I would like this plugin as well.
     
  8. Offline

    james137137

    sounds interesting. I might see what I can pull up
     
  9. Offline

    failtolawl

    I appreciate it.
     
  10. Offline

    james137137

    it will be done in about 1 hour I got to have a shower. (stay on and keep checking this post) :D

    almost done just testing it now. and debugging if have to

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

    failtolawl

    Very cool! looking forward to it!
     
  12. Offline

    james137137

    done: https://www.dropbox.com/s/7h44fqrulbuqnb1/PVPCombatLogger.jar

    Let me know what you think.

    Code:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package com.james137137.PVPCombatLogger;
     
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Arrow;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    /**
    *
    * @author James
    */
    public class PVPCombatLogger extends JavaPlugin {
     
        static Logger log = Bukkit.getLogger();
     
        public void onEnable() {
            String version = Bukkit.getServer().getPluginManager().getPlugin(this.getName()).getDescription().getVersion();
            log.log(Level.INFO, this.getName() + " : Version {0} enabled", version);
            getServer().getPluginManager().registerEvents(new PVPCombatLoggerListener(), this);
        }
     
        /**
        * @param args the command line arguments
        */
        @Override
        public void onDisable() {
            log.log(Level.INFO, "{0}: disabled", this.getName());
        }
     
        private static class PVPCombatLoggerListener implements Listener {
     
            public PVPCombatLoggerListener() {
            }
     
            @EventHandler
            public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
                if (event.getEntity()instanceof Player && event.getDamage() > 0)
                {
                    Player player = (Player) event.getEntity();
                    String PlayerName = player.getName();
                    int damage = event.getDamage();
                    if (event.getDamager().getType().equals(EntityType.PLAYER)) {
     
                        Player damager = ((Player) event.getDamager());
                        String damagerName = damager.getName();
                        log.log(Level.INFO, "[PVPCombatLogger]: {0} Attacked {1} causing a damage of: {2}", new Object[]{damagerName, PlayerName, damage});
                    }
                    if (event.getDamager().getType().equals(EntityType.ARROW)) {
                        Arrow thisArrow = (Arrow) event.getDamager();
                        if (thisArrow.getShooter() instanceof Player) {
                            Player damager = (Player) thisArrow.getShooter();
                            String damagerName = damager.getName();
                            log.log(Level.INFO, "[PVPCombatLogger]: {0} shot {1} causing a damage of: {2}", new Object[]{damagerName, PlayerName, damage});
                        }
     
                    }
                }
             
                 
             
     
            }
        }
    }
    
    quite simple only took about 1 hour (the arrows were the hardest bit)

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

    failtolawl

    Hey thanks a ton, I don't have anybody on my server ATM so I cannot test it yet, but I installed it, I thank you greatly for your time!

    Ok I got somebody to test it with me, absolutely amazing work. Even if it was simple, this helps me a bunch!

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

    james137137

    no problem.
     
  15. Offline

    xepisolonxx

    i created entitydamageevent added them to arraylist then i creted a delayed task to remove them from list and if they quit and there in the list it kills them and announces the combat logged.
     

Share This Page