Beispiel #1
0
  @Override
  public void onProtectionInteract(LWCProtectionInteractEvent event) {
    if (event.getResult() != Result.DEFAULT) {
      return;
    }

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

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

    Action action = lwc.getMemoryDatabase().getAction("forceowner", player.getName());
    String newOwner = action.getData();

    protection.setOwner(newOwner);
    protection.save();

    lwc.sendLocale(player, "protection.interact.forceowner.finalize", "player", newOwner);
    lwc.removeModes(player);
    event.setResult(Result.CANCEL);

    return;
  }
  @Override
  public void onProtectionInteract(LWCProtectionInteractEvent event) {
    if (event.getResult() != Result.DEFAULT) {
      return;
    }

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

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

    if (protection.isOwner(player)) {
      lwc.sendLocale(
          player,
          "protection.interact.error.alreadyregistered",
          "block",
          LWC.materialToString(protection.getBlockId()));
    } else {
      lwc.sendLocale(
          player,
          "protection.interact.error.notowner",
          "block",
          LWC.materialToString(protection.getBlockId()));
    }

    lwc.removeModes(player);
    event.setResult(Result.CANCEL);
  }
Beispiel #3
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);
  }
Beispiel #4
0
  @Override
  public void onProtectionInteract(LWCProtectionInteractEvent event) {
    LWC lwc = event.getLWC();
    Protection protection = event.getProtection();
    Set<String> actions = event.getActions();
    boolean canAccess = event.canAccess();

    Player bPlayer = event.getPlayer();
    LWCPlayer player = lwc.wrapPlayer(bPlayer);

    if (!actions.contains("dropTransferSelect")) {
      return;
    }

    if (!canAccess) {
      lwc.sendLocale(player, "protection.interact.dropxfer.noaccess");
    } else {
      if (protection.getBlockId() != Material.CHEST.getId()) {
        lwc.sendLocale(player, "protection.interact.dropxfer.notchest");
        player.removeAllActions();
        event.setResult(Result.CANCEL);

        return;
      }

      Mode mode = new Mode();
      mode.setName("dropTransfer");
      mode.setData(protection.getId() + "");
      mode.setPlayer(bPlayer);
      player.enableMode(mode);
      mode = new Mode();
      mode.setName("+dropTransfer");
      mode.setPlayer(bPlayer);
      player.enableMode(mode);

      lwc.sendLocale(player, "protection.interact.dropxfer.finalize");
    }

    player.removeAllActions(); // ignore the persist mode
  }