Examples of Nation


Examples of civquest.nation.Nation

         assert unit != null;
         assert nation != null;
           
         if (unit.getOwner() != null) {
             Nation prevNation = unit.getOwner();
             prevNation.removeUnit(unit);
         }
               
         unit.setOwner(nation);
         nation.addUnit(unit);
     }
View Full Code Here

Examples of civquest.nation.Nation

        assert city != null;

        Field field = city.getField();
        field.removeMapObject(city);
       
        Nation owner = city.getOwner();
        if (owner != null) {
            owner.removeCity(city);
        }

    game.remove(city);
  }
View Full Code Here

Examples of civquest.nation.Nation

        assert city != null;
        assert nation != null;
           
        if (city.getOwner() != null) {
            Nation prevOwner = city.getOwner();
            prevOwner.removeCity(city);
        }
               
        city.setOwner(nation);
        nation.addCity(city);
    }
View Full Code Here

Examples of civquest.nation.Nation

  public boolean isFieldOwnerAvailable(Coordinate position) {
    return true;
  }

  public Long getFieldOwner(Coordinate position) {
    Nation owner = getField(position).getOwner();
    return (owner != null ? owner.getID() : null);
  }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Nation

                  if (!resident.hasTown()) {
                    townSpawnPermission = TownSpawnLevel.UNAFFILIATED;
                  } else if (resident.getTown() == town) {
                    townSpawnPermission = TownSpawnLevel.TOWN_RESIDENT;
                  } else if (resident.hasNation() && town.hasNation()) {
                    Nation playerNation = resident.getTown().getNation();
                    Nation targetNation = town.getNation();
                   
                    if (playerNation == targetNation) {
                      townSpawnPermission = TownSpawnLevel.PART_OF_NATION;
                    } else if (targetNation.hasEnemy(playerNation)) {
                      // Prevent enemies from using spawn travel.
                            throw new TownyException(TownySettings.getLangString("msg_err_public_spawn_enemy"));
                    } else if (targetNation.hasAlly(playerNation)) {
                      townSpawnPermission = TownSpawnLevel.NATION_ALLY;
                    } else {
                        townSpawnPermission = TownSpawnLevel.UNAFFILIATED;
                      }
                  } else {
                    townSpawnPermission = TownSpawnLevel.UNAFFILIATED;
                  }
                }
               
                TownyMessaging.sendDebugMsg(townSpawnPermission.toString() + " " + townSpawnPermission.isAllowed());
                townSpawnPermission.checkIfAllowed(plugin, player);
               
                if (!(isTownyAdmin || townSpawnPermission == TownSpawnLevel.TOWN_RESIDENT) && !town.isPublic())
                  throw new TownyException(TownySettings.getLangString("msg_err_not_public"));
               
                if (!isTownyAdmin) {
                    // Prevent spawn travel while in disallowed zones (if configured)
                    List<String> disallowedZones = TownySettings.getDisallowedTownSpawnZones();
                   
                    if (!disallowedZones.isEmpty()) {
                        String inTown = null;
                        try {
                            Location loc = plugin.getCache(player).getLastLocation();
                            inTown = plugin.getTownyUniverse().getTownName(loc);
                        } catch (NullPointerException e) {
                            inTown = plugin.getTownyUniverse().getTownName(player.getLocation());
                        }
                       
                        if (inTown == null && disallowedZones.contains("unclaimed"))
                            throw new TownyException(String.format(TownySettings.getLangString("msg_err_town_spawn_disallowed_from"), "the Wilderness"));
                        if (inTown != null && resident.hasNation() && TownyUniverse.getDataSource().getTown(inTown).hasNation()) {
                            Nation inNation = TownyUniverse.getDataSource().getTown(inTown).getNation();
                            Nation playerNation = resident.getTown().getNation();
                            if (inNation.hasEnemy(playerNation) && disallowedZones.contains("enemy"))
                                throw new TownyException(String.format(TownySettings.getLangString("msg_err_town_spawn_disallowed_from"), "Enemy areas"));
                            if (!inNation.hasAlly(playerNation) && !inNation.hasEnemy(playerNation) && disallowedZones.contains("neutral"))
                                throw new TownyException(String.format(TownySettings.getLangString("msg_err_town_spawn_disallowed_from"), "Neutral towns"));
                        }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Nation

      throw new TownyException(TownySettings.getLangString("msg_err_enemy_war_must_be_placed_above_ground"));
   
    TownyUniverse universe = plugin.getTownyUniverse();
    Resident attackingResident;
    Town landOwnerTown, attackingTown;
    Nation landOwnerNation, attackingNation;
   
    try {
      attackingResident = TownyUniverse.getDataSource().getResident(player.getName());
      attackingTown = attackingResident.getTown();
      attackingNation = attackingTown.getNation();
    } catch (NotRegisteredException e) {
      throw new TownyException(TownySettings.getLangString("msg_err_dont_belong_nation"));
    }
   
    try {
      landOwnerTown = worldCoord.getTownBlock().getTown();
      landOwnerNation = landOwnerTown.getNation();
    } catch (NotRegisteredException e) {
      throw new TownyException(TownySettings.getLangString("msg_err_enemy_war_not_part_of_nation"));
    }
   
    // Check Neutrality
    if (landOwnerNation.isNeutral())
      throw new TownyException(String.format(TownySettings.getLangString("msg_err_enemy_war_is_neutral"), landOwnerNation.getFormattedName()));
    if (!TownyUniverse.getPermissionSource().isTownyAdmin(player) && attackingNation.isNeutral())
      throw new TownyException(String.format(TownySettings.getLangString("msg_err_enemy_war_is_neutral"), attackingNation.getFormattedName()));
   
    // Check Minimum Players Online
    checkIfTownHasMinOnlineForWar(universe, landOwnerTown);
    checkIfNationHasMinOnlineForWar(universe, landOwnerNation);
    checkIfTownHasMinOnlineForWar(universe, attackingTown);
    checkIfNationHasMinOnlineForWar(universe, attackingNation);
   
    // Check that attack takes place on the edge of a town
    if (!TownyUtil.isOnEdgeOfOwnership(landOwnerTown, worldCoord))
      throw new TownyException(TownySettings.getLangString("msg_err_enemy_war_not_on_edge_of_town"));
   
    // Call Event (and make sure an attack isn't already under way)
    CellAttackEvent cellAttackEvent = new CellAttackEvent(player, block);
    plugin.getServer().getPluginManager().callEvent(cellAttackEvent);
   
    if (cellAttackEvent.isCancelled()) {
      if (cellAttackEvent.hasReason())
        throw new TownyException(cellAttackEvent.getReason());
      else
        return false;
    }
   
    // Successful Attack
    if (!landOwnerNation.hasEnemy(attackingNation)) {
      landOwnerNation.addEnemy(attackingNation);
      plugin.getTownyUniverse();
      TownyUniverse.getDataSource().saveNation(landOwnerNation);
    }
   
    // Update Cache
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Nation

     
      TownyUniverse universe = plugin.getTownyUniverse();
      try {
        Resident resident = TownyUniverse.getDataSource().getResident(cell.getNameOfFlagOwner());
        Town town = resident.getTown();
        Nation nation = town.getNation();
       
        TownyWorld world = TownyUniverse.getDataSource().getWorld(cell.getWorldName());
        WorldCoord worldCoord = new WorldCoord(world, cell.getX(), cell.getZ());
        universe.removeWarZone(worldCoord);
       
        TownBlock townBlock = worldCoord.getTownBlock();
        TownyUniverse.getDataSource().removeTownBlock(townBlock);
       
        try {
          List<WorldCoord> selection = new ArrayList<WorldCoord>();
          selection.add(worldCoord);
          TownCommand.checkIfSelectionIsValid(town, selection, false, 0, false);
          new TownClaim(plugin, null, town, selection, true, false).start();
         
          //TownCommand.townClaim(town, worldCoord);
          //TownyUniverse.getDataSource().saveTown(town);
          //TownyUniverse.getDataSource().saveWorld(world);
         
          //TODO
          //PlotCommand.plotClaim(resident, worldCoord);
          //TownyUniverse.getDataSource().saveResident(resident);
          //TownyUniverse.getDataSource().saveWorld(world);
        } catch (TownyException te) {
          // Couldn't claim it.
        }
       
        plugin.updateCache(worldCoord);
       
        TownyMessaging.sendGlobalMessage(String.format(TownySettings.getLangString("msg_enemy_war_area_won"),
            resident.getFormattedName(),
            (nation.hasTag() ? nation.getTag() : nation.getFormattedName()),
            cell.getCellString()));
      } catch (NotRegisteredException e) {
        e.printStackTrace();
      }
    } else if (event.getEventName().equals("CellAttackCanceled")) {
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Nation

        line = kvFile.get("allies");
        if (line != null) {
          tokens = line.split(",");
          for (String token : tokens) {
            Nation friend = getNation(token);
            if (friend != null)
              nation.setAliegeance("ally", friend);
          }
        }

        line = kvFile.get("enemies");
        if (line != null) {
          tokens = line.split(",");
          for (String token : tokens) {
            Nation enemy = getNation(token);
            if (enemy != null)
              nation.setAliegeance("enemy", enemy);
          }
        }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Nation

    return new ArrayList<Nation>(universe.getNationsMap().values());
  }

  @Override
  public Nation getNation(String name) throws NotRegisteredException {
    Nation nation = universe.getNationsMap().get(name.toLowerCase());
    if (nation == null)
      throw new NotRegisteredException(String.format("The nation '%s' is not registered.", name));
    return nation;
  }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Nation

    }

    if (universe.getNationsMap().containsKey(filteredName.toLowerCase()))
      throw new AlreadyRegisteredException("The nation " + filteredName + " is already in use.");

    universe.getNationsMap().put(filteredName.toLowerCase(), new Nation(filteredName));

    universe.setChangedNotify(NEW_NATION);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.