Spigot Villager Spawn?
Hey,
Ich wollte fragen ob ihr wisst warum der Villager nicht Spawnt. In der Console gibt es keinen Error und die Location Funktioniert auch, habe ich im Navigator getestet.
File file = new File("plugins//LobbySystem//Locations.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
String name = "Spawn";
double x = cfg.getDouble(name + ".X");
double y = cfg.getDouble(name + ".Y");
double z = cfg.getDouble(name + ".Z");
double yaw = cfg.getDouble(name + ".Yaw");
double pitch = cfg.getDouble(name + ".Pitch");
String w = cfg.getString(name + ".WeltName");
Location loc = new Location(Bukkit.getWorld(w), x, y, z);
loc.setYaw((float) yaw);
loc.setPitch((float) pitch);
Villager v = (Villager) loc.getWorld().spawnEntity(loc, EntityType.VILLAGER);
v.setCustomName("James");
v.setCustomNameVisible(true);
2 Antworten
Villager v = (Villager) loc.getWorld().spawnEntity(loc, EntityType.VILLAGER);
v.setCustomName("James");
v.setCustomNameVisible(true);
Die Zeilen sehen richtig aus, also muss es was mit der Location zu tun haben.
Guck nochmal genau nach, Groß und Kleinschreibung bei der config ist auch wichtig.
PS: schreibe das v vom Villager aus also:
Villager villager = (Villager) loc.getWorld().spawnEntity(loc, EntityType.VILLAGER);
villager.setCustomName("James");
villager.setCustomNameVisible(true);
Das hilft dir bei dir Übersicht beim Programmieren.
Danke. Es hat auch Funktioniert. Hätte ich nicht das EntitySpawnEvent gecancelled :D Oh man ey xD
Nutzer, der sehr aktiv auf gutefrage ist
Hallo,
Bukkit.getWorld()
Das hat bei mir Probleme verursacht. Versuche es mit:
Bukkit.getServer().getWorld()
Liebe Grüße :)
Woher ich das weiß:eigene Erfahrung
Das geht auch nicht