PenguinPeople
Active Member
A system that makes you spawn with 5 seconds of being unable to be hit or hit anyone else to prevent the ever so common spawn killing.
public class DeathExample impliments Listener {
public static List<Player> tempDeadPlayers = new ArrayList<Player>();
Plugin plugin;
public DeathExample(Plugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onDeath(PlayerDeathEvent e) {
Player p = e.getPlayer();
if (tempDeadPlayers.contains(p)) return;
tempDeadPlayers.add(p);
System.out.println("wooo boiii " + p.getDisplayName() + " ded");
//OTHER DEATH CODE
plugin.getServer().getScheduler().callSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
tempDeadPlayers.remove(p);
}
}, 1L);
}
}
The double deaths occur when you are killed with a yoshi stomp mid air. Wouldn't spawning with a 5 second invulnerability prevent this from happening.Yes, this would be nice. Before I suggested adding event.getPlayer().setHealth(20); so it would still insta respawn but Zain said it would cause double deaths (which, granted, it does every so often), but you could add a delay event such as:
I mean in the code itself, for some reason setting a player's hp to full when they're dead can cause it. That's a different issue that isn't yoshi.The double deaths occur when you are killed with a yoshi stomp mid air. Wouldn't spawning with a 5 second invulnerability prevent this from happening.
That was fixed long ago m8The double deaths occur when you are killed with a yoshi stomp mid air. Wouldn't spawning with a 5 second invulnerability prevent this from happening.
Your tryharding amazes me, you have beaten Trenly Congratulations!Yes, this would be nice. Before I suggested adding event.getPlayer().setHealth(20); so it would still insta respawn but Zain said it would cause double deaths (which, granted, it does every so often), but you could add a delay event such as:
Code:public class DeathExample impliments Listener { public static List<Player> tempDeadPlayers = new ArrayList<Player>(); Plugin plugin; public DeathExample(Plugin plugin) { this.plugin = plugin; } @EventHandler public void onDeath(PlayerDeathEvent e) { Player p = e.getPlayer(); if (tempDeadPlayers.contains(p)) return; tempDeadPlayers.add(p); System.out.println("wooo boiii " + p.getDisplayName() + " ded"); //OTHER DEATH CODE plugin.getServer().getScheduler().callSyncDelayedTask(plugin, new Runnable() { @Override public void run() { tempDeadPlayers.remove(p); } }, 1L); } }
note: that is just pseudo code, you'd probably need to do some more stuff (and would have to register the events and initialize the class, and a bunch of other things the plugin might use such as maybe using a death scoreboard count rather than a dummy value) and don't completely have the delayed task thing memorized. I'm just pretty sure that's it; but this should work in theory.
Define long ago because it definitely happened last week...That was fixed long ago m8
Record it and make a bug report thenDefine long ago because it definitely happened last week...
It's already fixed m8, don't worry!I'm @ school & bored, what else am I supposed to do? xD
really it's just that this bug bothers me a lot and I don't want it anymore.