Hallöchen,
ich bin dabei einen RPG-Server aufzubauen, und habe mir einen Befehl gemacht um Ingame NPC's zu spawnen. Diese werden mit den Koordinaten in die Config eingetragen, nach einem Serverrestart sind diese allerdings wieder weg, ist auch irgendwo logisch.
Wie lasse ich die NPC's in der Config nun am besten nach Serverstart spawnen? Kann man das mit einer for-schleife irgendwie bewältigen?
Hier mal eben der Code um den NPC zu spawnen;
if(args[0].equalsIgnoreCase("add") && args[1] != "") {
String botName = args[1];
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
float yaw = p.getLocation().getYaw();
float pitch = p.getLocation().getPitch();
plugin.getConfig().set("bots." + botName + ".x", x);
plugin.getConfig().set("bots." + botName + ".y", y);
plugin.getConfig().set("bots." + botName + ".z", z);
plugin.getConfig().set("bots." + botName + ".yaw", yaw);
plugin.getConfig().set("bots." + botName + ".pitch", pitch);
plugin.saveConfig();
NPC npc = new NPC(args[1], p.getLocation());
npc.spawn();
npc.rmvFromTablist();
p.sendMessage("§aDu hast den Bot §6" + botName + " §aerfolgreich erstellt!");
}
Wie kann ich nun die Koordinaten am besten auslesen und dann die NPC's wieder spawnen?
Vielen Dank im vorraus.
ich bin dabei einen RPG-Server aufzubauen, und habe mir einen Befehl gemacht um Ingame NPC's zu spawnen. Diese werden mit den Koordinaten in die Config eingetragen, nach einem Serverrestart sind diese allerdings wieder weg, ist auch irgendwo logisch.
Wie lasse ich die NPC's in der Config nun am besten nach Serverstart spawnen? Kann man das mit einer for-schleife irgendwie bewältigen?
Hier mal eben der Code um den NPC zu spawnen;
if(args[0].equalsIgnoreCase("add") && args[1] != "") {
String botName = args[1];
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
float yaw = p.getLocation().getYaw();
float pitch = p.getLocation().getPitch();
plugin.getConfig().set("bots." + botName + ".x", x);
plugin.getConfig().set("bots." + botName + ".y", y);
plugin.getConfig().set("bots." + botName + ".z", z);
plugin.getConfig().set("bots." + botName + ".yaw", yaw);
plugin.getConfig().set("bots." + botName + ".pitch", pitch);
plugin.saveConfig();
NPC npc = new NPC(args[1], p.getLocation());
npc.spawn();
npc.rmvFromTablist();
p.sendMessage("§aDu hast den Bot §6" + botName + " §aerfolgreich erstellt!");
}
Wie kann ich nun die Koordinaten am besten auslesen und dann die NPC's wieder spawnen?
Vielen Dank im vorraus.
Zuletzt bearbeitet: