示例#1
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"));
  }
示例#2
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));
  }