Ejemplo n.º 1
0
  @Override
  public CommandResult process(CommandSource sender, String arguments) throws CommandException {

    String[] args = arguments.split(" ");

    if (!PermissionsUtils.has(sender, "core.heal")) {
      sender.sendMessage(
          Text.builder("You do not have permissions!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (args.length > 1) {
      sender.sendMessage(Text.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/heal [player]"));
      return CommandResult.success();
    }

    if (arguments.equalsIgnoreCase("")) {

      if (sender instanceof Player == false) {
        sender.sendMessage(
            Text.builder("Cannot be run by the console!").color(TextColors.RED).build());
        return CommandResult.success();
      }

      Player p = (Player) sender;
      double max = p.get(Keys.MAX_HEALTH).get();
      p.offer(Keys.HEALTH, max);

      sender.sendMessage(Text.of(TextColors.YELLOW, "You ", TextColors.GRAY, "have been healed."));

    } else if (args.length == 1) {

      if (!PermissionsUtils.has(sender, "core.heal-others")) {
        sender.sendMessage(
            Text.builder("You do not have permissions to heal other players!")
                .color(TextColors.RED)
                .build());
        return CommandResult.success();
      }

      Player p = ServerUtils.getPlayer(args[0]);
      if (p == null) {
        sender.sendMessage(Text.builder("Player not found!").color(TextColors.RED).build());
        return CommandResult.success();
      }

      double max = p.get(Keys.MAX_HEALTH).get();
      p.offer(Keys.HEALTH, max);

      sender.sendMessage(
          Text.of(TextColors.YELLOW, p.getName(), TextColors.GRAY, " has been healed."));
      p.sendMessage(
          Text.of(
              TextColors.GRAY, "You have been healed by ", TextColors.YELLOW, sender.getName()));
    }

    return CommandResult.success();
  }
Ejemplo n.º 2
0
  public CommandBanlistCheck(CommandSource sender, String[] args) {

    if (!PermissionsUtils.has(sender, "core.banlist.check")) {
      sender.sendMessage(
          Texts.builder("You do not have permissions!").color(TextColors.RED).build());
      return;
    }

    if (args.length < 2 || args.length > 2) {
      sender.sendMessage(
          Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/banlist check <name>"));
      return;
    }

    String uuid = CoreDatabase.getUUID(args[1].toLowerCase());

    if (uuid == null) {
      sender.sendMessage(Texts.of(TextColors.RED, "Player not found!"));
      return;
    }

    CoreBan ban = CoreDatabase.getBan(uuid);

    if (ban == null) {
      sender.sendMessage(
          Texts.of(TextColors.YELLOW, args[1].toLowerCase(), TextColors.GRAY, " is not banned."));
      return;
    }

    String time = TimeUtils.toString(ban.getDuration() - System.currentTimeMillis());
    String ago = TimeUtils.toString(System.currentTimeMillis() - ban.getTime());

    sender.sendMessage(
        Texts.of(
            TextColors.YELLOW,
            args[1].toLowerCase(),
            TextColors.GRAY,
            " is banned for another ",
            TextColors.YELLOW,
            time));
    sender.sendMessage(Texts.of(TextColors.YELLOW, "Reason: ", TextColors.GRAY, ban.getReason()));
    sender.sendMessage(
        Texts.of(
            TextColors.GRAY,
            "Banned by ",
            TextColors.YELLOW,
            ban.getSender(),
            TextColors.GRAY,
            " | ",
            TextColors.YELLOW,
            ago,
            TextColors.GRAY,
            " ago"));
  }
Ejemplo n.º 3
0
  public CommandWarpInfo(CommandSource sender, String[] args) {

    if (!PermissionsUtils.has(sender, "core.warp.info")) {
      sender.sendMessage(
          Texts.builder("You do not have permissions!").color(TextColors.RED).build());
      return;
    }

    if (args.length < 2 || args.length > 2) {
      sender.sendMessage(
          Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/warp info <name>"));
      return;
    }

    String name = args[1].toLowerCase();
    CoreWarp warp = CoreDatabase.getWarp(name);

    if (warp == null) {
      sender.sendMessage(Texts.builder("Warp does not exist!").color(TextColors.RED).build());
      return;
    }

    if (!warp.getOwner().equalsIgnoreCase(sender.getName())
        && !PermissionsUtils.has(sender, "core.warp.info-others")) {
      sender.sendMessage(Texts.of(TextColors.RED, "You do not own this warp!"));
      return;
    }

    String invited = SerializeUtils.list(warp.getInvited());
    invited = invited.replaceAll(",", ", ");
    if (invited.equalsIgnoreCase("")) invited = "- none -";

    double x = warp.getX();
    x *= 100;
    x = Math.round(x);
    x /= 100;
    double y = warp.getY();
    y *= 100;
    y = Math.round(y);
    y /= 100;
    double z = warp.getZ();
    z *= 100;
    z = Math.round(z);
    z /= 100;

    sender.sendMessage(
        Texts.of(TextColors.GRAY, "Information on Warp: ", TextColors.GOLD, warp.getName()));
    sender.sendMessage(
        Texts.of(
            TextColors.GRAY,
            "Owner: ",
            TextColors.YELLOW,
            CoreDatabase.getPlayer(warp.getOwner()).getName()));
    sender.sendMessage(
        Texts.of(
            TextColors.GRAY,
            "Location: ",
            TextColors.YELLOW,
            warp.getWorld(),
            " | x:",
            x,
            " y:",
            y,
            " z:",
            z));
    sender.sendMessage(
        Texts.of(TextColors.GRAY, "Private: ", TextColors.YELLOW, warp.getPrivate()));
    if (invited.equalsIgnoreCase("- none -"))
      sender.sendMessage(Texts.of(TextColors.GRAY, "Invited: ", TextColors.YELLOW, invited));
    else
      sender.sendMessage(
          Texts.of(
              TextColors.GRAY,
              "Invited: ",
              TextColors.YELLOW,
              "(",
              warp.getInvited().size(),
              ") ",
              invited));
  }