-
-
Save dumptruckman/8541076 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlayerDamageHistory { | |
public static PlayerDamageHistory createDamageHistory(String attacker) { | |
return new PlayerDamageHistory(attacker); | |
} | |
private final String attacker; | |
private final long time; | |
private PlayerDamageHistory(String attacker) { | |
this.attacker = attacker; | |
this.time = System.currentTimeMillis(); | |
} | |
public String getAttacker() { | |
return this.attacker; | |
} | |
public Long getTime() { | |
return this.time; | |
} | |
} | |
//When player is hit | |
lastHit.put(victim.getName(), PlayerDamageHistory.createDamageHistory(attacker.getName())); | |
//When player gets knocked off | |
PlayerDamageHistory history = lastHit.get(player.getName()); | |
if (history != null) { | |
if ((System.currentTimeMillis() - history.getTime()) < 15000){ | |
Player attacker = Bukkit.getPlayerExact(history.getAttacker()); | |
a.sendMessage(ChatColor.GREEN + player.getName() + ChatColor.GOLD + " was hit off the earth by " + ChatColor.GREEN + attacker.getName() + "."); | |
FishSlap run = ((FishSlap)a.getController()); | |
if (run != null) { | |
run.addPoint(attacker, a); | |
} | |
} else { | |
a.sendMessage(ChatColor.GREEN + player.getName() + ChatColor.GOLD + " fell off the earth."); | |
lastHit.remove(player.getName()); | |
} | |
} else { | |
a.sendMessage(ChatColor.GREEN + player.getName() + ChatColor.GOLD + " fell off the earth."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment