public boolean exec(IPlayer player, String[] args) {
    if (manager.isPlotWorld(player)) {
      if (player.hasPermission(PermissionNames.ADMIN_DONE)) {

        int page = 1;

        if (args.length == 2) {
          page = Integer.parseInt(args[1]);
        }

        int maxPage =
            (int)
                Math.ceil(
                    plugin.getSqlManager().getFinishedPlotCount(player.getWorld().getName()) / 8F);

        if (page < 1) {
          page = 1;
        } else if (page > maxPage) {
          page = maxPage;
        }

        List<Plot> donePlots =
            plugin.getSqlManager().getDonePlots(player.getWorld().getName(), page, 8);

        if (donePlots.isEmpty()) {
          player.sendMessage(C("MsgNoPlotsFinished"));
        } else {
          player.sendMessage(C("MsgFinishedPlotsPage") + " " + page + "/" + maxPage);

          for (Plot plot : donePlots) {
            String startText = "  §b" + plot.getId() + "§r -> " + plot.getOwner();

            int textLength = MinecraftFontWidthCalculator.getStringWidth(startText);

            String line = startText + whitespace(550 - textLength) + "@" + plot.getFinishedDate();

            player.sendMessage(line);
          }
        }
      } else {
        player.sendMessage("§c" + C("MsgPermissionDenied"));
        return false;
      }
    } else {
      player.sendMessage("§c" + C("MsgNotPlotWorld"));
    }
    return true;
  }
  public boolean execute(ICommandSender sender, String[] args) {
    IPlayer player = (IPlayer) sender;
    if (player.hasPermission(PermissionNames.ADMIN_EXPIRED)) {
      if (manager.isPlotWorld(player.getWorld())) {
        PlotMapInfo pmi = manager.getMap(player);
        if (pmi.getDaysToExpiration() != 0) {
          int page = 1;

          if (args.length == 2) {
            page = Integer.parseInt(args[1]);
          }
          List<List<Plot>> partition =
              Lists.partition(plugin.getSqlManager().getExpiredPlots(player.getWorld()), 10);
          if (partition.isEmpty()) {
            player.sendMessage(C("MsgNoPlotExpired"));
          } else {
            player.sendMessage(C("MsgExpiredPlotsPage", page, partition.size()));
            for (Plot plot : partition.get(page - 1)) {
              assert plot.getExpiredDate() != null;
              player.sendMessage(
                  plot.getId()
                      + " -> "
                      + plot.getOwner()
                      + " @ "
                      + plot.getExpiredDate().toString());
            }
          }
        } else {
          return true;
        }
      } else {
        player.sendMessage(C("NotPlotWorld"));
        return true;
      }
    } else {
      return false;
    }
    return true;
  }
Example #3
0
  public boolean execute(ICommandSender sender, String[] args) {
    if (args.length > 1) {
      sender.sendMessage(getUsage());
      return true;
    }
    IPlayer player = (IPlayer) sender;
    if (player.hasPermission(PermissionNames.ADMIN_CLEAR)
        || player.hasPermission(PermissionNames.USER_CLEAR)) {
      IWorld world = player.getWorld();
      PlotMapInfo pmi = manager.getMap(world);
      if (manager.isPlotWorld(world)) {
        Plot plot = manager.getPlot(player);
        if (plot == null) {
          player.sendMessage(C("NoPlotFound"));
          return true;
        } else if (plot.isProtected()) {
          player.sendMessage(C("MsgPlotProtectedCannotClear"));
        } else {
          String playerName = player.getName();

          if (player.getUniqueId().equals(plot.getOwnerId())
              || player.hasPermission(PermissionNames.ADMIN_CLEAR)) {

            double price = 0.0;

            PlotClearEvent event = new PlotClearEvent(plot, player);

            if (manager.isEconomyEnabled(pmi)) {
              price = pmi.getClearPrice();

              if (serverBridge.has(player, price)) {
                plugin.getEventBus().post(event);
                if (event.isCancelled()) {
                  return true;
                } else {
                  EconomyResponse er = serverBridge.withdrawPlayer(player, price);

                  if (!er.transactionSuccess()) {
                    player.sendMessage(er.errorMessage);
                    serverBridge.getLogger().warning(er.errorMessage);
                    return true;
                  }
                }
              } else {
                player.sendMessage(
                    C("MsgNotEnoughClear")
                        + " "
                        + C("WordMissing")
                        + " "
                        + serverBridge.getEconomy().get().format(price));
                return true;
              }
            } else {
              plugin.getEventBus().post(event);
            }

            if (!event.isCancelled()) {
              manager.clear(plot, player, ClearReason.Clear);

              if (isAdvancedLogging()) {
                if (price == 0) {
                  serverBridge
                      .getLogger()
                      .info(playerName + " " + C("MsgClearedPlot") + " " + plot.getId().getID());
                } else {
                  serverBridge
                      .getLogger()
                      .info(
                          playerName
                              + " "
                              + C("MsgClearedPlot")
                              + " "
                              + plot.getId().getID()
                              + (" " + C("WordFor") + " " + price));
                }
              }
            }
          } else {
            player.sendMessage(
                C("MsgThisPlot")
                    + "("
                    + plot.getId().getID()
                    + ") "
                    + C("MsgNotYoursNotAllowedClear"));
          }
        }
      } else {
        player.sendMessage(C("NotPlotWorld"));
      }
    } else {
      return false;
    }
    return true;
  }
Example #4
0
  public boolean execute(ICommandSender sender, String[] args) {
    if (args.length > 1) {
      sender.sendMessage(getUsage());
      return true;
    }
    IPlayer player = (IPlayer) sender;
    if (player.hasPermission(PermissionNames.USER_INFO)) {
      IWorld world = player.getWorld();
      if (manager.isPlotWorld(world)) {
        Plot plot = manager.getPlot(player);

        if (plot == null) {
          player.sendMessage(C("MsgNoPlotFound"));
          return true;
        }
        player.sendMessage("Internal ID: " + plot.getInternalID());
        player.sendMessage(
            "ID: "
                + plot.getId().getID()
                + " "
                + C("InfoOwner")
                + ": "
                + plot.getOwner()
                + " "
                + C("InfoBiome")
                + ": "
                + plot.getBiome());
        player.sendMessage("Likes: " + plot.getLikes());
        player.sendMessage("Created: " + plot.getCreatedDate());
        final String neverExpire = C("InfoExpire") + ": " + C("WordNever");
        if (plot.getExpiredDate() == null) {
          if (plot.isFinished()) {
            if (plot.isProtected()) {
              player.sendMessage(
                  neverExpire
                      + " "
                      + C("InfoFinished")
                      + ": "
                      + C("WordYes")
                      + " "
                      + C("InfoProtected")
                      + ": "
                      + C("WordYes"));
            } else {
              player.sendMessage(
                  neverExpire
                      + " "
                      + C("InfoFinished")
                      + ": "
                      + C("WordYes")
                      + " "
                      + C("InfoProtected")
                      + ": "
                      + C("WordNo"));
            }
          } else {
            if (plot.isProtected()) {
              player.sendMessage(
                  neverExpire
                      + " "
                      + C("InfoFinished")
                      + ": "
                      + C("WordNo")
                      + " "
                      + C("InfoProtected")
                      + ": "
                      + C("WordYes"));
            } else {
              player.sendMessage(
                  neverExpire
                      + " "
                      + C("InfoFinished")
                      + ": "
                      + C("WordNo")
                      + " "
                      + C("InfoProtected")
                      + ": "
                      + C("WordNo"));
            }
          }
        } else if (plot.isProtected()) {
          if (plot.isFinished()) {
            player.sendMessage(
                neverExpire
                    + " "
                    + C("InfoFinished")
                    + ": "
                    + C("WordYes")
                    + " "
                    + C("InfoProtected")
                    + ": "
                    + C("WordYes"));
          } else {
            player.sendMessage(
                neverExpire
                    + " "
                    + C("InfoFinished")
                    + ": "
                    + C("WordNo")
                    + " "
                    + C("InfoProtected")
                    + ": "
                    + C("WordYes"));
          }
        } else if (plot.isFinished()) {
          player.sendMessage(
              C("InfoExpire")
                  + ": "
                  + plot.getExpiredDate()
                  + " "
                  + C("InfoFinished")
                  + ": "
                  + C("WordYes")
                  + " "
                  + C("InfoProtected")
                  + ": "
                  + C("WordNo"));
        } else {
          player.sendMessage(
              C("InfoExpire")
                  + ": "
                  + plot.getExpiredDate()
                  + " "
                  + C("InfoFinished")
                  + ": "
                  + C("WordNo")
                  + " "
                  + C("InfoProtected")
                  + ": "
                  + C("WordNo"));
        }

        if (!plot.getMembers().isEmpty()) {
          StringBuilder builder = new StringBuilder("Members: ");
          if (!plot.getMembers().containsKey("*")) {
            for (Map.Entry<String, Plot.AccessLevel> member : plot.getMembers().entrySet()) {
              builder
                  .append(
                      plugin
                          .getServerBridge()
                          .getOfflinePlayer(UUID.fromString(member.getKey()))
                          .getName())
                  .append(" (")
                  .append(member.getValue().toString())
                  .append(")   ");
            }
          } else {
            builder.append("*");
          }
          player.sendMessage(builder.toString());
        }

        if (!plot.getDenied().isEmpty()) {
          StringBuilder builder = new StringBuilder(C("InfoDenied"));
          builder.append(": ");
          if (!plot.getDenied().contains("*")) {
            for (String s : plot.getDenied()) {
              builder
                  .append(plugin.getServerBridge().getOfflinePlayer(UUID.fromString(s)).getName())
                  .append("  ");
            }
          } else {
            builder.append('*');
          }

          player.sendMessage(builder.toString());
        }

        if (manager.isEconomyEnabled(world)) {
          if (plot.isForSale()) {
            player.sendMessage(C("InfoForSale") + ": " + plot.getPrice());
          } else {
            player.sendMessage(C("InfoForSale") + ": " + C("WordNo"));
          }
        }

        player.sendMessage(C("WordBottom") + ": " + plot.getPlotBottomLoc().toString());
        player.sendMessage(C("WordTop") + ": " + plot.getPlotTopLoc());

      } else {
        player.sendMessage(C("MsgNotPlotWorld"));
      }
    } else {
      return false;
    }
    return true;
  }