Skip to content

Instantly share code, notes, and snippets.

@IamRob-
Last active January 4, 2016 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save IamRob-/8539877 to your computer and use it in GitHub Desktop.
Save IamRob-/8539877 to your computer and use it in GitHub Desktop.
public class PlayerDamageHistory {
private String attacker;
private Long time;
public PlayerDamageHistory(String attacker, Long time) {
this.attacker = attacker;
this.time = time;
}
public void setAttacker(String attacker) {
this.attacker = attacker;
}
public void setTime(Long time) {
this.time = time;
}
public String getAttacker() {
return this.attacker;
}
public Long getTime() {
return this.time;
}
}
//When player is hit
if (lastHit.containsKey(victim.getName())) {
PlayerDamageHistory history = lastHit.get(victim.getName());
history.setAttacker(attacker.getName());
history.setTime(System.currentTimeMillis());
} else {
lastHit.put(victim.getName(), new PlayerDamageHistory(attacker.getName(), System.currentTimeMillis()));
}
//When player gets knocked off
if (lastHit.get(player.getName()) != null) {
PlayerDamageHistory history = lastHit.get(player.getName());
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.");
}
} 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