Example #1
0
  @Override
  public void onEnable() {
    log = Logger.getLogger("Minecraft");

    setupPermissions();

    settings = new Settings();
    database = new Database(this);
    logThread = new LogThread(this);
    getServer().getScheduler().scheduleAsyncRepeatingTask(this, logThread, 1L, 20L);

    commandHandler = new CommandHandler(this);
    selectionMap = new HashMap<String, Selection>();
    playerCache = new HashMap<String, PlayerCache>();
    cityCache = new HashMap<String, City>();
    claimMap = new HashMap<String, Claim>();

    populateCityCache();
    populateClaimsCache();
    populatePlayerCache();

    registerEvents();

    database.deleteOldInvites();

    log.info("Cityscape loaded.");
    logThread.addLogEntry("SERVER", "Cityscape Enabled.");
  }
Example #2
0
 public void populateClaimsCache() {
   ArrayList<Claim> claimsArray = database.getClaims();
   if (claimsArray != null) {
     for (Claim claim : claimsArray) {
       addClaim(claim);
     }
   }
 }
Example #3
0
 public void populateCityCache() {
   ArrayList<City> cityArray = database.getCities();
   if (cityArray != null) {
     for (City city : cityArray) {
       cityCache.put(city.getName(), city);
     }
   }
 }
Example #4
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);
  }
Example #5
0
 public void checkCityRank(String cityName) {
   City city = cityCache.get(cityName);
   int residents = database.getNumResidents(cityName);
   switch (residents) {
     case 1:
       city.setBaseClaims(16);
       break;
     case 3:
       city.setBaseClaims(64);
       break;
     case 6:
       city.setBaseClaims(128);
       break;
     case 12:
       city.setBaseClaims(256);
       break;
     case 100:
       city.setBaseClaims(2000);
       break;
   }
 }