TheRedCraft Posted May 26, 2017 Posted May 26, 2017 Hallo wie kann ich eigentlich spielr in andere welten telepotieren ich habe das bisher: private static HashMap<Location> loc; public static World world; WorldCreator w = WorldCreator.name("NP"); world = Bukkit.createWorld(w); ich brauche es nur um das Game-Profile zu updaten also soll man nur kurtz in die welt np und dann wieder zurück telepotiert werden (also dahin wo man war) deshalb habe ich auch eine hasmap gemach die die location speichern soll aber wie kann ich deinen spieler telepotieren und die location speichern:
Joey Posted May 26, 2017 Posted May 26, 2017 Erstell doch einfach eine Location, da musst du ja die Welt + Koordinaten angeben. PS: Ne HashMap benötigt 2 Werte, ein Key und ne Value HashMap<String, Location> hashmap = new HashMap<String,Location>();
Yuki Posted May 27, 2017 Posted May 27, 2017 Hi, player.teleport(new Location(Bukkit.getWorld("WeltName"), X, Y, Z)); sollte denke funktionieren solange die Welt "WeltName" existiert. -Yuki
TheRedCraft Posted May 27, 2017 Author Posted May 27, 2017 ok aber wie kann ich die alte location + welt speichern?
Joey Posted May 27, 2017 Posted May 27, 2017 Du holst dir die Location, mit p.getLocation(). Die fügst du dann als value in die HashMap (Key ist dann der Spielername). Wenn du die Location dann wieder brauchst holst du dir die Location per Spielernamen wieder aus der Hashmap. Das könntest du dafür gebrauchen: hashmap.put(key, value) hashmap.get(key) hashmap.remove(key) Dabei können Key und value jedes Objekt sein, du hast aber in deiner Hashmap ja als Key nen String und als Value ne Location definiert, daher musst besagte auch nehemen. //Handy
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now