Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. private void teleportHome(CommandContext ctx) {
  2. Player player = (Player) ctx.getCommandSender().getCommandSender();
  3. Location homeLocation = null;
  4.  
  5. System.out.println(player.getUniqueId());
  6.  
  7. try {
  8. MongoCollection<HomeDocument> homeCollection = HomeDocument.getCollection(Lamafarm.getDatabase());
  9.  
  10. for (HomeDocument document : homeCollection.find()) {
  11. System.out.println(document.getUniqueId());
  12.  
  13. if (document.getUniqueId().equals(player.getUniqueId())) {
  14. homeLocation = new Location(Bukkit.getWorld(document.getWorldLocation()), document.getXLocation(),
  15. document.getYLocation(), document.getZLocation());
  16. homeLocation.setYaw(document.getYawLocation());
  17. homeLocation.setPitch(document.getPitchLocation());
  18. }
  19. }
  20. } catch (Exception e) {
  21. ctx.sendError("Es ist ein Fehler beim auslesen deines Homepunkts passiert");
  22. e.printStackTrace();
  23. return;
  24. }
  25.  
  26. if (homeLocation == null) {
  27. ctx.sendError("Du hast noch keinen Homepunkt gesetzt");
  28. return;
  29. }
  30.  
  31. player.teleport(homeLocation);
  32. ctx.sendSuccess("Du wurdest zu deinem Homepunkt teleportiert");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement