Пример #1
0
  @Override
  public void onProtectionInteract(LWCProtectionInteractEvent event) {
    if (event.getResult() != Result.DEFAULT) {
      return;
    }

    if (!event.hasAction("info")) {
      return;
    }

    LWC lwc = event.getLWC();
    Protection protection = event.getProtection();
    Player player = event.getPlayer();
    event.setResult(Result.CANCEL);

    String type =
        lwc.getPlugin().getMessageParser().parseMessage(protection.typeToString().toLowerCase());
    lwc.sendLocale(player, "lwc.info", "owner", protection.getOwner(), "type", type);

    if (event.canAdmin()) {
      if (protection.getType() == Protection.Type.PRIVATE
          || protection.getType() == Protection.Type.DONATION) {
        lwc.sendLocale(player, "lwc.acl", "size", protection.getPermissions().size());
        int index = 0;
        for (Permission permission : protection.getPermissions()) {
          if (index >= 9) {
            break;
          }

          player.sendMessage(permission.toString());
          index++;
        }

        if (index == 0) {
          lwc.sendLocale(player, "lwc.acl.empty");
        } else if (index >= 9) {
          lwc.sendLocale(player, "lwc.acl.limitreached");
        }

        player.sendMessage("");
      }
    }

    if (lwc.isAdmin(player)) {
      lwc.sendLocale(player, "protection.interact.info.raw", "raw", protection.toString());
    }

    lwc.removeModes(player);
  }
Пример #2
0
  @Override
  public void onCommand(LWCCommandEvent event) {
    if (event.isCancelled()) {
      return;
    }

    if (!event.hasFlag("limits")) {
      return;
    }

    LWC lwc = event.getLWC();
    CommandSender sender = event.getSender();
    String[] args = event.getArgs();
    event.setCancelled(true);

    if (args.length == 0 && !(sender instanceof Player)) {
      sender.sendMessage(Colors.Red + "Unsupported");
      return;
    }

    String playerName;

    if (args.length == 0) {
      playerName = sender.getName();
    } else {
      if (lwc.isAdmin(sender)) {
        playerName = args[0];
      } else {
        lwc.sendLocale(sender, "protection.accessdenied");
        return;
      }
    }

    Player player = lwc.getPlugin().getServer().getPlayer(playerName);

    if (player == null) {
      return;
    }

    // send their limits to them
    sendLimits(player, player, getPlayerLimits(player));
  }
Пример #3
0
  @Override
  public Result onCommand(LWC lwc, CommandSender sender, String command, String[] args) {
    if (!StringUtils.hasFlag(command, "a") && !StringUtils.hasFlag(command, "admin")) {
      return DEFAULT;
    }

    if (args.length == 0) {
      if (lwc.isAdmin(sender)) {
        lwc.sendLocale(sender, "help.admin");
      }

      return CANCEL;
    } else if (args.length > 0) {
      // check for permissions
      if (!lwc.hasAdminPermission(sender, "lwc.admin." + args[0])) {
        return CANCEL;
      }
    }

    return DEFAULT;
  }