public String doClaim(MPlayer player) {
    if (!player.hasPermission("mafiacraft.citizen")) {
      return "You must be a citizen to use this command. "
          + "Apply for citizen on the website at "
          + MsgColor.URL
          + "http://voxton.net/"
          + ".";
    }

    Government gov = player.getGovernment();
    if (gov == null) {
      return "You aren't in a government.";
    }

    if (!player.getPosition().isAtLeast(Position.VICE_LEADER)) {
      return "You aren't allowed to claim land for your government.";
    }

    Section section = player.getSection();
    District district = player.getDistrict();

    if (!district.canBeClaimed(section, gov)) {
      return "Your government isn't allowed to claim the given district.";
    }

    double price = district.getLandCost();
    if (!gov.hasEnough(price)) {
      return "Your government does not have enough money to purchase this land.";
    }

    gov.claim(section);
    gov.subtractMoney(price);

    player.sendMessage(
        MsgColor.SUCCESS
            + "You have successfully claimed the section "
            + section.getName()
            + " for your "
            + gov.getType().getName()
            + ".");
    return null;
  }
  public String doSetHq(MPlayer player) {
    if (!player.hasPermission("mafiacraft.citizen")) {
      return "You must be a citizen to use this command. "
          + "Apply for citizen on the website at "
          + MsgColor.URL
          + "http://voxton.net/"
          + ".";
    }

    if (!player.getPosition().isAtLeast(Position.VICE_LEADER)) {
      return "You aren't allowed to set the HQ of your government.";
    }

    Government gov = player.getGovernment();
    if (gov == null) {
      return "You aren't in a government.";
    }

    Section section = player.getSection();
    if (!section.getOwner().equals(gov)) {
      return "The HQ must be specified within HQ land.";
    }

    double needed = Config.getDouble("prices.gov.sethq");
    if (!gov.hasEnough(needed)) {
      return "Your "
          + gov.getType().getName()
          + " does not have enough money to set its HQ. (Costs "
          + needed
          + ")";
    }

    gov.setHq(player.getPoint()).subtractMoney(needed);
    player.sendMessage(
        MsgColor.SUCCESS
            + "Your "
            + gov.getType().getName()
            + " HQ has been set to your current location.");
    return null;
  }
Beispiel #3
0
 /**
  * Creates a district based on a sample chunk within the potential district.
  *
  * @param sample
  * @return
  */
 private District createDistrict(Section sample) {
   return createDistrict(sample.getWorld(), ((sample.getX()) >> 4), ((sample.getZ() >> 4)));
 }