Cooldown log?

Discussion in 'Plugin Development' started by XxZHALO13Xx, Dec 27, 2014.

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

    XxZHALO13Xx

    How would i make a combat log thing that if a player is hit.. they die. but if they aren't damaged by a player for 15 seconds they can log. I'm getting really confused on this.. heres what i have

    Code:
    public class CombatLog implements Listener{
    
    
        private Map<String, Long> lastUsage = new HashMap<String, Long>();
        private final int cdTime = 15;
        private long lastUsed = 0;
        @EventHandler
        public void onHit(EntityDamageByEntityEvent e){
            Entity hitter = e.getDamager();
            Entity hit = e.getEntity();
    
            if(hitter instanceof Player && hit instanceof Player){
                Player p = (Player) hit;
                Player attacker = (Player) hitter;
                if(lastUsage.containsKey(p.getName())){
                    lastUsed = lastUsage.get(p.getName());
                }
    
                int cdMillis = cdTime * 1000;
                if(System.currentTimeMillis() - lastUsed >= cdMillis){
                    lastUsage.put(p.getName(), System.currentTimeMillis());
                }
            }
        }
    
        @EventHandler
        public void PlayerQuit(PlayerQuitEvent e){
            Player p = e.getPlayer();
            long lastUsed = 0;
            if(lastUsage.containsKey(p.getName())){
                lastUsed = lastUsage.get(p.getName());
    
    
            }
        }
    }
    
    ik ur not supposed to spoon feed but could u pls just help me here? i'm confused and im not feeling the best as i can type with one hand rn.. That's not ur problem but im just saying it would be appreciated if u could give me a straight up answer. thanks y'all Happy New Years too
     
  2. Offline

    mythbusterma

    @XxZHALO13Xx

    Erm, what's the issue here? You can remove them from that Map when they die.
     
  3. Offline

    XxZHALO13Xx

  4. Offline

    Mysticate

    About what?
     
  5. Offline

    XxZHALO13Xx

    @Mysticate how this would work. like after 15 seconds i want them to get a message that says you may now log out. but would i need a bukkit scheduler or cooldown
     
  6. Offline

    SuperOriginal

    If you want to send them a message when they can log out, use a scheduler.
     
  7. Offline

    teej107

    Cooldown. But players can log out anytime. There is no way to prevent that. Just sayin'
     
Thread Status:
Not open for further replies.

Share This Page