Пример #1
0
  public static void setFlying(PerkPlayer player, boolean flying) {

    if (m_perksDB == null) return;

    String query;

    // if they are to be set flying insert them into the table
    if (flying) {
      query =
          "INSERT INTO `perks_flying` (name) VALUES (" + "'" + player.getPlayer().getName() + "');";
      // if not remove them from it
    } else {
      query = "DELETE FROM `perks_flying` WHERE " + "name='" + player.getPlayer().getName() + "';";
    }

    m_perksDB.query(query, true);
  }
Пример #2
0
  public static void addVanishPlayer(PerkPlayer player) {

    String query =
        "INSERT INTO `perks_vanish` "
            + "(`player`) VALUES ("
            + "'"
            + player.getPlayer().getName()
            + "');";
    m_perksDB.query(query, true);
  }
Пример #3
0
  public static boolean isVanished(PerkPlayer player) {

    if (!player.hasPermission("perks.vanish", false)) return false;

    String query =
        "SELECT * FROM `perks_vanish` WHERE player='" + player.getPlayer().getName() + "'";
    ResultSet result = m_perksDB.queryResult(query);

    if (result == null) return false;

    boolean vanished;
    try {
      vanished = result.next();
    } catch (SQLException e) {
      vanished = false;
    }

    m_perksDB.freeResult(result);
    return vanished;
  }
Пример #4
0
  public static boolean isFlying(PerkPlayer player) {

    if (m_perksDB == null) return false;

    if (!player.hasPermission("perks.fly", false)) return false;

    String query =
        "SELECT * FROM `perks_flying` WHERE name ='" + player.getPlayer().getName() + "'";
    ResultSet result = m_perksDB.queryResult(query);

    if (result == null) return false;

    boolean flying;
    try {
      flying = result.next();
    } catch (SQLException e) {
      flying = false;
    }

    m_perksDB.freeResult(result);
    return flying;
  }
Пример #5
0
  public static boolean onCommand(
      PerkPlayer player, Command cmd, String commandLabel, PerkArgSet args) {

    if (cmd.getName().equalsIgnoreCase("tpr")
        || cmd.getName().equalsIgnoreCase("tphr")
        || cmd.getName().equalsIgnoreCase("tpd")
        || cmd.getName().equalsIgnoreCase("tpa")) {
      PerkPlayer toPlayer = null;

      if (args.size() == 1) {
        String playerName = args.getString(0);
        toPlayer = PerkUtils.getPlayer(PerkUtils.server().getPlayer(playerName));

        if (toPlayer == null || toPlayer.isVanished()) {
          PerkUtils.OutputToPlayer(player, playerName + " isn't online.");
          return true;
        }
      }

      if (cmd.getName().equalsIgnoreCase("tpr")) {

        if (args.size() != 1) {
          PerkUtils.OutputToPlayer(player, cmd.getUsage());
          return true;
        }

        if (!player.hasPermission("perks.teleport.tpr", true)) {
          return true;
        }

        toPlayer.sendTpRequest(player);

        return true;
      }

      if (cmd.getName().equalsIgnoreCase("tphr")) {

        if (args.size() != 1) {
          PerkUtils.OutputToPlayer(player, cmd.getUsage());
          return true;
        }

        if (!player.hasPermission("perks.teleport.tphr", true)) {
          return true;
        }

        toPlayer.sendTpHereRequest(player);

        return true;
      }

      // accepting and declining shouldn't have a permission as everyone needs to do it

      if (cmd.getName().equalsIgnoreCase("tpa")) {

        player.acceptTpRequest(toPlayer);

        return true;
      }

      if (cmd.getName().equalsIgnoreCase("tpd")) {

        player.declineTpRequest(toPlayer);

        return true;
      }
    }

    if (cmd.getName().equalsIgnoreCase("tp")) {

      if (!player.hasPermission("perks.teleport.tp", true)) return true;

      if (args.size() != 1) {
        PerkUtils.OutputToPlayer(player, cmd.getUsage());
        return true;
      }

      Location loc = null;

      // Handle coordinates
      if (args.getString(0).matches("^[\\-0-9\\.]+,[\\-0-9\\.]+,[\\-0-9\\.]+(?:.+)?$")) {

        String[] arg = args.getString(0).split(":");
        String[] parts = args.getString(0).split(",");
        double x = 0, y = 0, z = 0;

        try {
          x = Double.parseDouble(parts[0]);
          y = Double.parseDouble(parts[1]);
          z = Double.parseDouble(parts[2]);
        } catch (NumberFormatException e) {
          PerkUtils.OutputToPlayer(player, "");
        }

        if (arg.length > 1) {
          loc = new Location(PerkUtils.server().getWorld(arg[1]), x, y, z);
        } else {
          loc = new Location(player.getPlayer().getWorld(), x, y, z);
        }

        player.teleport(loc);

        PerkUtils.OutputToPlayer(player, "You have been teleported");

        return true;
      }

      PerkPlayer target = PerkUtils.getPlayer(args.getString(0));
      if (target == null) {
        PerkUtils.OutputToPlayer(player, "That player is not online");
        return true;
      }

      loc = target.getPlayer().getLocation();

      player.teleport(loc);

      PerkUtils.OutputToPlayer(player, "You have been teleported");

      return true;
    }

    if (cmd.getName().equalsIgnoreCase("tphere")
        || cmd.getName().equalsIgnoreCase("s")
        || cmd.getName().equalsIgnoreCase("bring")) {

      if (!player.hasPermission("perks.teleport.tphere", true)) return true;

      if (args.size() != 1) {
        PerkUtils.OutputToPlayer(player, cmd.getUsage());
        return true;
      }

      PerkPlayer target = PerkUtils.getPlayer(args.getString(0));

      if (target == null) {
        PerkUtils.OutputToPlayer(player, "That player is not online");
        return true;
      }

      player.teleportHere(target);

      PerkUtils.OutputToPlayer(
          player, target.getPlayer().getName() + " has been teleported to you.");

      return true;
    }

    if (cmd.getName().equalsIgnoreCase("put")) {

      if (!player.hasPermission("perks.teleport.put", true)) return true;

      if (args.size() != 1) {
        PerkUtils.OutputToPlayer(player, cmd.getUsage());
        return true;
      }

      PerkPlayer target = PerkUtils.getPlayer(args.getString(0));

      if (target == null) {
        PerkUtils.OutputToPlayer(player, "That player is not online");
        return true;
      }

      target.getPlayer().teleport(player.getPlayer().getTargetBlock(null, 300).getLocation());
      return true;
    }

    return false;
  }
Пример #6
0
  public static boolean onCommand(
      PerkPlayer player, Command cmd, String commandLabel, PerkArgSet args) {

    if (commandLabel.equalsIgnoreCase("slap")) {

      if (!player.hasPermission("perks.fun.slap", true)) return true;

      PerkPlayer target;
      if (args.size() == 0) {
        target = player;
      } else {
        target = PerkUtils.getPlayer(args.getString(0));
        if (target == null) {
          PerkUtils.OutputToPlayer(player, args.getString(0) + " is not online");
          return true;
        }
      }

      boolean silent = false;
      if (args.hasFlag('s')) {
        silent = true;
      }

      double power = 1.0;
      String powerString = "";
      if (args.hasFlag('v')) {
        power = 5.0;
        powerString = " very hard";
      } else if (args.hasFlag('h')) {
        power = 2.5;
        powerString = " hard";
      }

      target
          .getPlayer()
          .setVelocity(
              new Vector(
                  (random.nextDouble() + 0.01) * power - (power * 0.5),
                  (random.nextDouble() + 0.01) * power,
                  (random.nextDouble() + 0.01) * power - (power * 0.5)));

      if (!silent) {
        PerkUtils.OutputToAllExcluding(
            player.getPlayer().getName()
                + " has slapped "
                + target.getPlayer().getName()
                + powerString,
            player.getPlayer());
      }

      if (target != player) {
        PerkUtils.OutputToPlayer(
            target, "You have been slapped" + powerString + " by " + player.getPlayer().getName());
      }

      PerkUtils.OutputToPlayer(
          player,
          "You have slapped "
              + (target != player ? target.getPlayer().getName() : "Yourself")
              + powerString);
      return true;
    }

    if (commandLabel.equalsIgnoreCase("rocket")) {

      if (!player.hasPermission("perks.fun.rocket", true)) return true;

      PerkPlayer target;
      if (args.size() == 0) {
        target = player;
      } else {
        target = PerkUtils.getPlayer(args.getString(0));
        if (target == null) {
          PerkUtils.OutputToPlayer(player, args.getString(0) + " is not online");
          return true;
        }
      }

      boolean silent = false;
      if (args.hasFlag('s')) {
        silent = true;
      }

      double power = 6.0;
      target.getPlayer().setVelocity(new Vector(0, power, 0));

      if (!silent) {
        PerkUtils.OutputToAllExcluding(
            player.getPlayer().getName() + " has rocketed " + target.getPlayer().getName(),
            player.getPlayer());
      }

      if (target != player) {
        PerkUtils.OutputToPlayer(
            target, "You have been rocketed by " + player.getPlayer().getName());
      }

      PerkUtils.OutputToPlayer(
          player,
          "You have rocketed " + (target != player ? target.getPlayer().getName() : "Yourself"));
      return true;
    }

    return false;
  }
Пример #7
0
  public static void removeVanishPlayer(PerkPlayer player) {

    String query =
        "DELETE FROM `perks_vanish` " + "WHERE player=" + "'" + player.getPlayer().getName() + "';";
    m_perksDB.query(query, true);
  }