Last active
January 4, 2016 00:09
-
-
Save IamRob-/8539877 to your computer and use it in GitHub Desktop.
This file contains 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 { | |
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