32 lines
920 B
Java
32 lines
920 B
Java
package moe.oko.opennaw.util;
|
|
|
|
import moe.oko.opennaw.model.City;
|
|
import moe.oko.opennaw.model.Nation;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Material;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
public class CityHandler {
|
|
private HashMap<String, City> cities = new HashMap<>();
|
|
|
|
public void addCity(String name, String resource, Location location) {
|
|
cities.put(name, new City(name, resource, location));
|
|
location.getBlock().setType(Material.SPONGE);
|
|
}
|
|
|
|
public void removeCity(String name) { cities.remove(name);}
|
|
|
|
public void setCityOwner(City city, Nation nation) { cities.get(city.getName()).setOwner(nation); }
|
|
|
|
public List<String> getCityList() {
|
|
List<String> cityList = new ArrayList<String>();
|
|
for (City city : cities.values()) {
|
|
cityList.add(city.getName());
|
|
}
|
|
return cityList;
|
|
}
|
|
}
|