Beispiel #1
0
  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;
  }
Beispiel #2
0
  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;
  }