Fixed Fatal Survivor

anvil_rework
sigonasr2 11 years ago
parent 0f0841386d
commit 83ae98dcad
  1. 42
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.java

@ -11318,16 +11318,35 @@ public void onEntityExpode(ExplosionPrimeEvent e) {
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
//Delay this for 5 ticks. See if Fatal Survivor kicked in in time. (Or you got healed).
final PlayerDeathEvent e2 = e;
e2.getEntity().setHealth(1);
Bukkit.broadcastMessage("Player Death: "+e2.getEntity().getHealth()+" HP, Last Damage: -"+e2.getEntity().getLastDamage()+" from "+e2.getEntity().getLastDamageCause());
final Main plugin = this.plugin;
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
@Override
public void run() {
Player p = e2.getEntity();
e2.setDeathMessage(e2.getDeathMessage().replace(p.getScoreboard().getTeam(p.getName()).getPrefix()+p.getName()+p.getScoreboard().getTeam(p.getName()).getSuffix(),p.getName()));
//Bukkit.broadcastMessage("Player Death: "+e.getEntity().getHealth()+" HP, Last Damage: -"+e.getEntity().getLastDamage()+" from "+e.getEntity().getLastDamageCause());
//If we have Fatal Survivor, use the force! Otherwise, uh, you're dead.
Player p = e.getEntity();
e.setDeathMessage(e.getDeathMessage().replace(p.getScoreboard().getTeam(p.getName()).getPrefix()+p.getName()+p.getScoreboard().getTeam(p.getName()).getSuffix(),p.getName()));
p.getScoreboard().getTeam(p.getName()).setSuffix("");
boolean survivor=false;
if (this.plugin.PlayerinJob(p, "Explorer")) {
if (this.plugin.getJobLv("Explorer", p)>=10) {
//Check to see if our "fatal s urvivor" effect is available.
for (int i=0;i<this.plugin.explorers.size();i++) {
if (this.plugin.explorers.get(i).event==0 && this.plugin.explorers.get(i).name.compareTo(p.getName())==0) {
survivor=true;
break;
}
}
PersistentExplorerList eve = new PersistentExplorerList(p.getName());
eve.event=1;
eve.data=p.getExp();
eve.data2=p.getLevel();
eve.expiretime=Main.SERVER_TICK_TIME+1200;
this.plugin.explorers.add(eve);
if (!survivor) {
FatalSurvivor(p);
}
}
}
if (survivor || !this.plugin.PlayerinJob(p, "Explorer")) {
//You are dead buddy.
for (int i=0;i<plugin.explorerlist.size();i++) {
if (Bukkit.getPlayer(plugin.explorerlist.get(i).player)!=null) {
Player p2 =Bukkit.getPlayer(plugin.explorerlist.get(i).player);
@ -11385,13 +11404,12 @@ public void onEntityExpode(ExplosionPrimeEvent e) {
finalcost*=0.25;
}
if (mymoney>=mincost) {
p.sendMessage("You died. It will cost you $"+df.format(finalcost)+" to revive2. To revive, type /revive me2.");
p.sendMessage("You died. It will cost you $"+df.format(finalcost)+" to revive. To revive, type /revive me.");
} else {
p.sendMessage("You died. You do not have enough money in your bank to revive2.");
p.sendMessage("You died. You do not have enough money in your bank to revive.");
p.sendMessage("Cost: $"+df.format(finalcost)+". If you want to revive, type "+ChatColor.AQUA+"/revive me"+ChatColor.WHITE+" when you have enough.");
}
}
},5);
}
@EventHandler

Loading…
Cancel
Save