Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void teleportHome(CommandContext ctx) {
- Player player = (Player) ctx.getCommandSender().getCommandSender();
- Location homeLocation = null;
- System.out.println(player.getUniqueId());
- try {
- MongoCollection<HomeDocument> homeCollection = HomeDocument.getCollection(Lamafarm.getDatabase());
- for (HomeDocument document : homeCollection.find()) {
- System.out.println(document.getUniqueId());
- if (document.getUniqueId().equals(player.getUniqueId())) {
- homeLocation = new Location(Bukkit.getWorld(document.getWorldLocation()), document.getXLocation(),
- document.getYLocation(), document.getZLocation());
- homeLocation.setYaw(document.getYawLocation());
- homeLocation.setPitch(document.getPitchLocation());
- }
- }
- } catch (Exception e) {
- ctx.sendError("Es ist ein Fehler beim auslesen deines Homepunkts passiert");
- e.printStackTrace();
- return;
- }
- if (homeLocation == null) {
- ctx.sendError("Du hast noch keinen Homepunkt gesetzt");
- return;
- }
- player.teleport(homeLocation);
- ctx.sendSuccess("Du wurdest zu deinem Homepunkt teleportiert");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement