public boolean teleportToCoordinates( Player player, World world, double x, double y, double z, float yaw, float pitch, boolean costMoney) { if (new TeleportOptions().allowEntry(player, new Location(world, x, y, z, yaw, pitch))) { if (player.teleport(new Location(world, x, y, z, yaw, pitch))) { money.useTeleportWithdraw(player, costMoney); player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "You have been teleported to X:" + x + " Y:" + y + " Z:" + z + " in \"" + world.getName() + "\""))); } else { player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "&cFailed to teleport!"))); return false; } } else { player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "&cAccess to teleport area denied"))); ; return false; } return true; }
public boolean teleportToWarp(Player player, String teleportName, boolean costMoney) { FileConfiguration locationSave = null; File locationFile = new File(CitizensTP.plugin.getDataFolder(), "locations/" + teleportName + ".yml"); locationSave = YamlConfiguration.loadConfiguration(locationFile); World world = Bukkit.getWorld(locationSave.getString("CitizensTP.Location.World")); Double x = locationSave.getDouble("CitizensTP.Location.X"); Double y = locationSave.getDouble("CitizensTP.Location.Y"); Double z = locationSave.getDouble("CitizensTP.Location.Z"); Float yaw = (float) locationSave.getDouble("CitizensTP.Location.Yaw"); Float pitch = (float) locationSave.getDouble("CitizensTP.Location.Pitch"); if (new TeleportOptions().allowEntry(player, new Location(world, x, y, z, yaw, pitch))) { if (player.teleport(new Location(world, x, y, z, yaw, pitch))) { money.useTeleportWithdraw(player, costMoney); player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "You have been teleported to: " + teleportName))); } else { player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "&cFailed to teleport!"))); return false; } } else { player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "&cAccess to teleport area denied"))); ; return false; } return true; }
public boolean saveTeleport( Player player, String locationName, String icon, Location location, boolean costMoney) { File locationsFile = new File(CitizensTP.plugin.getDataFolder(), "locations/" + locationName + ".yml"); if (!locationsFile.exists()) { try { locationsFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "&cError saving teleport"))); return false; } } else { player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "Location already exists"))); return false; } FileConfiguration locationSave = null; File locationFile = new File(CitizensTP.plugin.getDataFolder(), "locations/" + locationName + ".yml"); locationSave = YamlConfiguration.loadConfiguration(locationFile); locationSave.set("CitizensTP.Time", System.currentTimeMillis()); locationSave.set("CitizensTP.Player.Name", player.getName()); locationSave.set("CitizensTP.Player.UUID", player.getUniqueId() + ""); locationSave.set("CitizensTP.Location.Name", locationName); locationSave.set("CitizensTP.Location.Icon", ItemInventoryGUI.setIcon); locationSave.set("CitizensTP.Location.World", location.getWorld().getName()); locationSave.set("CitizensTP.Location.X", location.getX()); locationSave.set("CitizensTP.Location.Y", location.getY()); locationSave.set("CitizensTP.Location.Z", location.getZ()); locationSave.set("CitizensTP.Location.Yaw", location.getYaw()); locationSave.set("CitizensTP.Location.Pitch", location.getPitch()); try { locationSave.save(locationFile); } catch (IOException error) { error.printStackTrace(); player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "&cError saving location"))); return false; } money.saveTeleportWithdraw(player, costMoney); player.sendMessage( ChatColor.translateAlternateColorCodes( '&', (CitizensTP.plugin.getConfig().getString("CitizensTP.customization.pluginName") + "Teleport location has been saved!"))); ItemInventoryGUI.setIcon = null; return true; }