Löschen:
public void onJoin(PlayerJoinEvent e) {
Player p= e.getPlayer();
String playername= p.getName();
File Vill = new File("plugins//Lol//Vill//"+playername+".yml");
YamlConfiguration vil= YamlConfiguration.loadConfiguration(Vill);
Entity villager = (Entity) Bukkit.getWorld("world").getEntitiesByClass(Villager.class);
String lalo =vil.getString(p.getName());
String UUidvill= villager.getUniqueId().toString();
if(UUidvill == lalo) {
p.sendMessage("loool");
villager.setCustomName("aaaa");
villager.remove();
Vill.delete();
}}
Speichern:
public void onQuit(PlayerQuitEvent e) {
Player p= e.getPlayer();
String playername= p.getName();
File Vill = new File("plugins//Lol//Vill//"+playername+".yml");
Villager person =(Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
person.setCustomName(p.getName());
YamlConfiguration vil= YamlConfiguration.loadConfiguration(Vill);
person.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 500000, 200));
if(!Vill.exists()) {
try {
Vill.createNewFile();
} catch (IOException jh) {
// TODO Auto-generated catch block
p.sendMessage("§4Der angegebene Pfad wurde nicht gefunde!"); }
vil.createSection("Offline:");
vil.set(p.getName(), person.getUniqueId().toString());
try {
vil.save(Vill);
} catch (IOException jh) {
// TODO Auto-generated catch block
p.sendMessage("§4Pfad wurde nicht gefunden");
}
}
}
public void checkOrdner() {
File Offline = new File("plugins//Lol//Offline");
File Vill = new File("plugins//Lol//Vill");
if(!Offline.exists()) {
Offline.mkdir();
}
if(!Vill.exists()) {
Vill.mkdir();
}
}