Skip to content

Instantly share code, notes, and snippets.

@dumptruckman
Forked from IamRob-/gist:8539877
Last active January 4, 2016 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dumptruckman/8541076 to your computer and use it in GitHub Desktop.
Save dumptruckman/8541076 to your computer and use it in GitHub Desktop.
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