Example #1
0
    @Override
    public void run() {
      if (!MyWarp.inst().getTimerFactory().hasRunningTimer(type, WarpWarmup.class)) {
        cancel();
        return;
      }

      Player player = MyWarp.server().getPlayerExact(type);
      if (player == null) {
        cancel();
        return;
      }

      Location loc = player.getLocation();
      if (loc.distanceSquared(originalLoc) >= 2 * 2) {
        if (!MyWarp.inst()
            .getPermissionsManager()
            .hasPermission(player, "mywarp.warmup.disobey.moveabort")) {
          WarpWarmup.this.cancel();
          player.sendMessage(
              MyWarp.inst()
                  .getLocalizationManager()
                  .getString("commands.warp-to.warmup.cancelled-move", player));
          cancel();
        }
      }
    }
Example #2
0
    @Override
    public void run() {
      if (!MyWarp.inst().getTimerFactory().hasRunningTimer(type, WarpWarmup.class)) {
        cancel();
        return;
      }

      Player player = MyWarp.server().getPlayerExact(type);
      if (player == null) {
        cancel();
        return;
      }

      if (player.getHealth() < originalHealth) {
        if (!MyWarp.inst()
            .getPermissionsManager()
            .hasPermission(player, "mywarp.warmup.disobey.dmgabort")) {
          WarpWarmup.this.cancel();
          player.sendMessage(
              MyWarp.inst()
                  .getLocalizationManager()
                  .getString("commands.warp-to.warmup.cancelled-damage", player));
          cancel();
        }
      }
    }
Example #3
0
  @Override
  public void action() {
    Player player = MyWarp.server().getPlayerExact(type);
    if (player == null) {
      return;
    }

    if (MyWarp.inst().getWarpSettings().economyEnabled) {
      double fee =
          MyWarp.inst().getPermissionsManager().getEconomyPrices(player).getFee(Fee.WARP_TO);

      if (!MyWarp.inst().getEconomyLink().canAfford(player, fee)) {
        player.sendMessage(
            ChatColor.RED
                + MyWarp.inst()
                    .getLocalizationManager()
                    .getString("economy.cannot-afford", player, fee));
        return;
      }
    }

    warp.warp(player, true);
    if (!MyWarp.inst().getPermissionsManager().hasPermission(player, "mywarp.cooldown.disobey")) {
      MyWarp.inst()
          .getTimerFactory()
          .registerNewTimer(
              new WarpCooldown(
                  MyWarp.inst().getTimerFactory(),
                  player,
                  MyWarp.inst().getPermissionsManager().getCooldown(player)));
    }
  }
Example #4
0
  @Override
  public void execute(CommandSender sender, String identifier, String[] args)
      throws CommandException {
    Warp warp = CommandUtils.getWarpForUsage(sender, CommandUtils.toWarpName(args));

    plugin.getWarpList().point(warp, (Player) sender);
    sender.sendMessage(LanguageManager.getEffectiveString("warp.point", "%warp%", warp.name));
  }
Example #5
0
  /**
   * Displays the results to the sender. Individual results are parsed via {@link #format(Object,
   * CommandSender)};
   *
   * @param sender the command sender
   * @param results results to display
   * @param page the page to display
   * @throws CommandException if the page does not exist or the given list is empty
   */
  public void display(CommandSender sender, List<? extends T> results, int page)
      throws CommandException {
    if (results.size() == 0) {
      throw new CommandException(
          MyWarp.inst().getLocalizationManager().getString("lister.no-results", sender));
    }
    --page;

    int resultsPerPage = note != null ? PER_PAGE - 1 : PER_PAGE;

    int maxPages = results.size() / resultsPerPage;
    if (page < 0 || page > maxPages) {
      throw new CommandException(
          MyWarp.inst()
              .getLocalizationManager()
              .getString("lister.unknown-page", sender, maxPages + 1));
    }

    sender.sendMessage(
        ChatColor.GOLD
            + MinecraftFontWidthCalculator.centralize(
                " "
                    + header
                    + MyWarp.inst()
                        .getLocalizationManager()
                        .getColorlessString("lister.page", sender)
                    + " "
                    + (page + 1)
                    + "/"
                    + (maxPages + 1)
                    + " ",
                '-'));
    if (note != null) {
      sender.sendMessage(ChatColor.ITALIC + note);
    }
    for (int i = resultsPerPage * page;
        i < resultsPerPage * page + resultsPerPage && i < results.size();
        i++) {
      sender.sendMessage(format(results.get(i), sender));
    }
  }
Example #6
0
  /**
   * Initializes the warp-warmup.
   *
   * @param timerFactory the {@link TimerFactory} instance this action is registered on
   * @param player the player who is cooling down
   * @param warp the warp that the player wants to use
   * @param duration the duration of the warmup
   */
  public WarpWarmup(TimerFactory timerFactory, Player player, Warp warp, Time duration) {
    timerFactory.super(player.getName(), duration.getTicks());
    this.warp = warp;

    originalLoc = player.getLocation().clone();
    originalHealth = player.getHealth();

    if (MyWarp.inst().getWarpSettings().timersWarmupNotify) {
      player.sendMessage(
          MyWarp.inst()
              .getLocalizationManager()
              .getString(
                  "commands.warp-to.warmup.started",
                  player,
                  warp.getName(),
                  duration.getSeconds()));
    }

    if (MyWarp.inst().getWarpSettings().timersAbortOnDamage) {
      new HealthCheck().runTaskTimer(MyWarp.inst(), 20 * CHECK_FREQUENCY, 20 * CHECK_FREQUENCY);
    }
    if (MyWarp.inst().getWarpSettings().timersAbortOnMove) {
      new MovementCheck().runTaskTimer(MyWarp.inst(), 20 * CHECK_FREQUENCY, 20 * CHECK_FREQUENCY);
    }
  }