Пример #1
0
  @Override
  public void perform() {
    if (!assertHasFaction()) {
      return;
    }

    if (isLocked()) {
      sendLockMessage();
      return;
    }

    // default: toggle existing value
    boolean enable = !me.autoClaimEnabled();

    // if on|off is specified, use that instead
    if (parameters.size() > 0) enable = parseBool(parameters.get(0));

    me.enableAutoClaim(enable);

    if (!enable) {
      sendMessage("Auto-claiming of land disabled.");
      return;
    }

    Faction myFaction = me.getFaction();
    FLocation flocation = new FLocation(me);

    if (!assertMinRole(Role.MODERATOR)) {
      me.enableAutoClaim(false);
      return;
    }

    if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
      sendMessage("Sorry, this world has land claiming disabled.");
      me.enableAutoClaim(false);
      return;
    }

    if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) {
      sendMessage("You can't claim more land! You need more power!");
      me.enableAutoClaim(false);
      return;
    }

    sendMessage("Auto-claiming of land enabled.");
    me.attemptClaim(false);
  }
Пример #2
0
  @Override
  public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    FPlayer me = FPlayer.get(player);

    // Did we change coord?
    FLocation from = me.getLastStoodAt();
    FLocation to = new FLocation(player.getLocation());

    if (from.equals(to)) {
      return;
    }

    // Yes we did change coord (:

    me.setLastStoodAt(to);

    if (me.isMapAutoUpdating()) {
      me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw()));
    } else {
      // Did we change "host"(faction)?
      Faction factionFrom = Board.getFactionAt(from);
      Faction factionTo = Board.getFactionAt(to);
      Faction myFaction = me.getFaction();
      String ownersTo = myFaction.getOwnerListString(to);
      if (factionFrom != factionTo) {
        me.sendFactionHereMessage();
        if (Conf.ownedAreasEnabled
            && Conf.ownedMessageOnBorder
            && myFaction == factionTo
            && !ownersTo.isEmpty()) {
          me.sendMessage(Conf.ownedLandMessage + ownersTo);
        }
      } else if (Conf.ownedAreasEnabled
          && Conf.ownedMessageInsideTerritory
          && factionFrom == factionTo
          && myFaction == factionTo) {
        String ownersFrom = myFaction.getOwnerListString(from);
        if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) {
          if (!ownersTo.isEmpty()) {
            me.sendMessage(Conf.ownedLandMessage + ownersTo);
          } else if (!Conf.publicLandMessage.isEmpty()) {
            me.sendMessage(Conf.publicLandMessage);
          }
        }
      }
    }

    if (me.autoClaimEnabled()) {
      Faction myFaction = me.getFaction();
      Faction otherFaction = Board.getFactionAt(to);
      double cost = Econ.calculateClaimCost(myFaction.getLandRounded(), otherFaction.isNormal());

      if (me.getRole().value < Role.MODERATOR.value) {
        me.sendMessage("You must be " + Role.MODERATOR + " to claim land.");
        me.enableAutoClaim(false);
      } else if (Conf.worldsNoClaiming.contains(to.getWorldName())) {
        me.sendMessage("Sorry, this world has land claiming disabled.");
        me.enableAutoClaim(false);
      } else if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) {
        me.sendMessage("You can't claim more land! You need more power!");
        me.enableAutoClaim(false);
      } else if (!Econ.canAfford(player.getName(), cost)) {
        String costString = Econ.moneyString(cost);
        me.sendMessage(
            "Claiming this land will cost " + costString + ", which you can't currently afford.");
        me.enableAutoClaim(false);
      } else me.attemptClaim(false);
    } else if (me.autoSafeZoneEnabled()) {
      if (!Factions.hasPermManageSafeZone((CommandSender) player)) {
        me.enableAutoSafeZone(false);
      } else {
        FLocation playerFlocation = new FLocation(me);

        if (!Board.getFactionAt(playerFlocation).isSafeZone()) {
          Board.setFactionAt(Faction.getSafeZone(), playerFlocation);
          me.sendMessage("This land is now a safe zone.");
        }
      }
    } else if (me.autoWarZoneEnabled()) {
      if (!Factions.hasPermManageWarZone((CommandSender) player)) {
        me.enableAutoWarZone(false);
      } else {
        FLocation playerFlocation = new FLocation(me);

        if (!Board.getFactionAt(playerFlocation).isWarZone()) {
          Board.setFactionAt(Faction.getWarZone(), playerFlocation);
          me.sendMessage("This land is now a war zone.");
        }
      }
    }
  }