How do I make players retire after 3 deaths? Minecraft java coding?

fl
5

How can I program a player to be banned after 3 deaths?

Spigot 1.8 is the version

al

Evtl for each player in the config at each death hochschreiben so z.b

Deaths:
MadMarvin: 0
Player2: 1

And at a death, you make an inquiry with an event, how many deaths he already has, and if there are three you ban him!

But it can also be that it works:

player.getDeaths

But i don't know

Li

Just create a map with the UUID as Key and an Integer as Value. Then in the 'PlayerDeathEvent' you put this player into the map, if it is already in it you just increase its int. Then you check if it has already died three times → if so ban. You can also save these values in a config during Server Restart.

fl

Danke

fl

I've tried this but in the yml the deaths do not get higher:

package listener;

import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;
import Listener.Join;
public class Respawn implements Listener {
String team = "";
@EventHandler
public void onPlayerRespawn (PlayerRespawnEvents) {
Player p = e.getPlayer ();

String playername = p.getName ();
File file = new File ("plugins // Elements // Deaths //" + playername + ". Yml");
YamlConfiguration Deaths = YamlConfiguration.loadConfiguration (file);

int y = 0;
y = y + 1;
if (y == 1) {

Deaths.set ( ". Deaths" + p.getName () + ". Death", 1);

try {
Deaths.save (file);

} catch (IOException e1) {
// TODO Auto-generated catch block

}

}

if (y == 2) {

Deaths.set ( ". Deaths" + p.getName () + ". Death", 2);
try {
Deaths.save (file);
} catch (IOException e1) {
// TODO Auto-generated catch block
}
}

if (y == 3) {

Deaths.set ( ". Deaths" + p.getName () + ". Death", 3);
try {
Deaths.save (file);
y = 0;
} catch (IOException e1) {
// TODO Auto-generated catch block
}
}
if (Deaths.getInt ("Deaths." + p.getName () + ". Death:") == 3) {
p.sendMessage ( "Hi");
}

if (! File.exists ()) {
try {
file.createNewFile ();
} catch (IOException a) {
// TODO Auto-generated catch block
p.sendMessage ("§4The specified path was not found!"); }

}

if (Deaths.getInt ("Deaths." + p.getName () + ". Death:") == 3) {
p.kickPlayer ("§4You're out!");
}

e.getPlayer (). SendMessage ("§Emache / e to get your effects back.");
if (Main.Main.Air.contains (e.getPlayer (). GetName ({
team = "air";
e.setRespawnLocation (Join.locair);
}
if (Main.Main.Fire.contains (e.getPlayer (). GetName ({
team = "fire";
e.setRespawnLocation (Join.locfire);
}
if (Main.Main.Earth.contains (e.getPlayer (). GetName ({
team = "earth";
e.setRespawnLocation (Join.locearth);
}
if (Main.Main.water.contains (e.getPlayer (). GetName ({
e.setRespawnLocation (Join.locwater);
team = "water";
}
return;
} public void checkFolder () {
File file = new File ("plugins // Elements // Deaths");
if (! File.exists ()) {
file.mkdir ();
}
}}

al

It's best not to do it with playername uuid! If the player changes his name. And you have to first ask if there's already an entry in the config with his uuid if so then look for his death from the config, if not put his uuid with a death. And ask if he already exists, if he has more than three deaths