Beispiel #1
0
  public void addClaim(Claim claim) {
    claimMap.put(claim.toString(), claim);
    com.sethcran.cityscape.Claim north =
        getClaimAt(claim.getX(), claim.getZ() + 1, claim.getWorld());
    com.sethcran.cityscape.Claim east =
        getClaimAt(claim.getX() + 1, claim.getZ(), claim.getWorld());
    com.sethcran.cityscape.Claim south =
        getClaimAt(claim.getX(), claim.getZ() - 1, claim.getWorld());
    com.sethcran.cityscape.Claim west =
        getClaimAt(claim.getX() - 1, claim.getZ(), claim.getWorld());

    if (north != null) {
      if (!north.getCityName().equals(claim.getCityName())) north = null;
    }
    if (east != null) {
      if (!east.getCityName().equals(claim.getCityName())) east = null;
    }
    if (south != null) {
      if (!south.getCityName().equals(claim.getCityName())) south = null;
    }
    if (west != null) {
      if (!west.getCityName().equals(claim.getCityName())) west = null;
    }
    getCity(claim.getCityName()).addClaim(claim, north, east, south, west);
  }
Beispiel #2
0
  public void renameCity(String oldName, String newName) {
    for (Claim claim : claimMap.values()) {
      if (oldName.equals(claim.getCityName())) claim.setCityName(newName);
    }

    City city = cityCache.get(oldName);
    cityCache.remove(oldName);
    city.rename(newName);
    cityCache.put(newName, city);

    for (PlayerCache pc : playerCache.values()) {
      if (oldName.equals(pc.getCity())) pc.setCity(newName);
    }
  }
Beispiel #3
0
  public void unclaimAll(String cityName, Claim claim) {
    City city = cityCache.get(cityName);

    Collection<Claim> cc = claimMap.values();
    Iterator<Claim> iter = cc.iterator();
    while (iter.hasNext()) {
      Claim c = iter.next();
      if (c.getCityName().equals(cityName)) {
        iter.remove();
        city.removeClaim(c);
      }
    }
    claimMap.put(claim.toString(), claim);
    city.addClaim(claim, null, null, null, null);

    city.setUsedClaims(1);
    city.removeAllPlots();
  }
Beispiel #4
0
  public void deleteCity(String city) {

    Collection<Claim> cc = claimMap.values();
    Iterator<Claim> iter = cc.iterator();
    while (iter.hasNext()) {
      Claim claim = iter.next();
      if (city.equals(claim.getCityName())) iter.remove();
    }

    cityCache.remove(city);

    for (PlayerCache pc : playerCache.values()) {
      if (city.equals(pc.getCity())) {
        pc.setCity(null);
        pc.setRank(null);
      }
    }
  }
Beispiel #5
0
  public void removeClaim(Claim claim) {
    claimMap.remove(claim.toString());

    Chunk chunk = getServer().getWorld(claim.getWorld()).getChunkAt(claim.getX(), claim.getZ());
    Block minBlock = chunk.getBlock(0, 0, 0);
    Block maxBlock = chunk.getBlock(15, 0, 15);
    int xmin = minBlock.getX();
    int zmin = minBlock.getZ();
    int xmax = maxBlock.getX();
    int zmax = maxBlock.getZ();

    City city = getCity(claim.getCityName());
    ArrayList<Integer> idList = city.removeIntersectingPlots(xmin, zmin, xmax, zmax);
    for (int i : idList) {
      database.removePlot(i);
    }

    city.setUsedClaims(city.getUsedClaims() - 1);
    city.removeClaim(claim);
  }
Beispiel #6
0
 public City getCityAt(int x, int z, String world) {
   Claim claim = claimMap.get(new Claim(world, x, z).toString());
   if (claim == null) return null;
   return cityCache.get(claim.getCityName());
 }