|
|
@ -74,7 +74,7 @@ public class City extends AbstractWorldObject { |
|
|
|
private boolean forceRename = false; |
|
|
|
private boolean forceRename = false; |
|
|
|
private boolean noTeleport = false; //used by npc cities
|
|
|
|
private boolean noTeleport = false; //used by npc cities
|
|
|
|
private boolean noRepledge = false; //used by npc cities
|
|
|
|
private boolean noRepledge = false; //used by npc cities
|
|
|
|
private boolean isOpen = false; |
|
|
|
private final boolean isOpen = false; |
|
|
|
private int treeOfLifeID; |
|
|
|
private int treeOfLifeID; |
|
|
|
private Vector3fImmutable location = Vector3fImmutable.ZERO; |
|
|
|
private Vector3fImmutable location = Vector3fImmutable.ZERO; |
|
|
|
|
|
|
|
|
|
|
@ -191,7 +191,6 @@ public class City extends AbstractWorldObject { |
|
|
|
Logger.error("NULL TOL FOR " + city.cityName); |
|
|
|
Logger.error("NULL TOL FOR " + city.cityName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assign city owner
|
|
|
|
// Assign city owner
|
|
|
|
|
|
|
|
|
|
|
|
if (city.getTOL() != null) |
|
|
|
if (city.getTOL() != null) |
|
|
@ -209,7 +208,8 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
rulingNation = rulingGuild.getNation(); |
|
|
|
rulingNation = rulingGuild.getNation(); |
|
|
|
|
|
|
|
|
|
|
|
// Begin Serialzing soverign guild data
|
|
|
|
// Begin Serializing sovereign guild data
|
|
|
|
|
|
|
|
|
|
|
|
writer.putInt(city.getObjectType().ordinal()); |
|
|
|
writer.putInt(city.getObjectType().ordinal()); |
|
|
|
writer.putInt(city.getObjectUUID()); |
|
|
|
writer.putInt(city.getObjectUUID()); |
|
|
|
writer.putString(city.cityName); |
|
|
|
writer.putString(city.cityName); |
|
|
@ -264,7 +264,6 @@ public class City extends AbstractWorldObject { |
|
|
|
writer.putInt(rulingNation.getObjectUUID()); |
|
|
|
writer.putInt(rulingNation.getObjectUUID()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Serialize nation name
|
|
|
|
// Serialize nation name
|
|
|
|
|
|
|
|
|
|
|
|
if (rulingNation.isEmptyGuild()) |
|
|
|
if (rulingNation.isEmptyGuild()) |
|
|
@ -286,16 +285,8 @@ public class City extends AbstractWorldObject { |
|
|
|
else |
|
|
|
else |
|
|
|
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName()); |
|
|
|
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putLocalDateTime(city.established); |
|
|
|
writer.putLocalDateTime(city.established); |
|
|
|
|
|
|
|
|
|
|
|
// writer.put((byte) city.established.getDayOfMonth());
|
|
|
|
|
|
|
|
// writer.put((byte) city.established.minusMonths(1).getMonth().getValue());
|
|
|
|
|
|
|
|
// writer.putInt((int) years);
|
|
|
|
|
|
|
|
// writer.put((byte) hours);
|
|
|
|
|
|
|
|
// writer.put((byte) minutes);
|
|
|
|
|
|
|
|
// writer.put((byte) seconds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putFloat(city.location.x); |
|
|
|
writer.putFloat(city.location.x); |
|
|
|
writer.putFloat(city.location.y); |
|
|
|
writer.putFloat(city.location.y); |
|
|
|
writer.putFloat(city.location.z); |
|
|
|
writer.putFloat(city.location.z); |
|
|
@ -334,6 +325,7 @@ public class City extends AbstractWorldObject { |
|
|
|
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City); |
|
|
|
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City); |
|
|
|
|
|
|
|
|
|
|
|
//add npc cities
|
|
|
|
//add npc cities
|
|
|
|
|
|
|
|
|
|
|
|
for (AbstractGameObject ago : worldCities.values()) { |
|
|
|
for (AbstractGameObject ago : worldCities.values()) { |
|
|
|
|
|
|
|
|
|
|
|
if (ago.getObjectType().equals(GameObjectType.City)) { |
|
|
|
if (ago.getObjectType().equals(GameObjectType.City)) { |
|
|
@ -350,6 +342,7 @@ public class City extends AbstractWorldObject { |
|
|
|
//list Player cities
|
|
|
|
//list Player cities
|
|
|
|
|
|
|
|
|
|
|
|
//open city, just list
|
|
|
|
//open city, just list
|
|
|
|
|
|
|
|
|
|
|
|
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { |
|
|
|
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { |
|
|
|
|
|
|
|
|
|
|
|
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) |
|
|
|
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) |
|
|
@ -359,7 +352,9 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (city.isNpc == 1) { |
|
|
|
} else if (city.isNpc == 1) { |
|
|
|
|
|
|
|
|
|
|
|
//list NPC cities
|
|
|
|
//list NPC cities
|
|
|
|
|
|
|
|
|
|
|
|
Guild g = city.getGuild(); |
|
|
|
Guild g = city.getGuild(); |
|
|
|
if (g == null) { |
|
|
|
if (g == null) { |
|
|
|
if (city.isNpc == 1) |
|
|
|
if (city.isNpc == 1) |
|
|
@ -369,13 +364,9 @@ public class City extends AbstractWorldObject { |
|
|
|
} else if (pc.getLevel() > 9) |
|
|
|
} else if (pc.getLevel() > 9) |
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
|
|
|
|
|
|
|
|
|
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) { |
|
|
|
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -383,18 +374,24 @@ public class City extends AbstractWorldObject { |
|
|
|
return cities; |
|
|
|
return cities; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ArrayList<City> getCitiesToRepledgeTo(PlayerCharacter pc) { |
|
|
|
public static ArrayList<City> getCitiesToRepledgeTo(PlayerCharacter playerCharacter) { |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<City> cities = new ArrayList<>(); |
|
|
|
ArrayList<City> cities = new ArrayList<>(); |
|
|
|
if (pc == null) |
|
|
|
|
|
|
|
|
|
|
|
if (playerCharacter == null) |
|
|
|
return cities; |
|
|
|
return cities; |
|
|
|
Guild pcG = pc.getGuild(); |
|
|
|
|
|
|
|
|
|
|
|
Guild pcG = playerCharacter.getGuild(); |
|
|
|
|
|
|
|
|
|
|
|
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City); |
|
|
|
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City); |
|
|
|
|
|
|
|
|
|
|
|
//add npc cities
|
|
|
|
//add npc cities
|
|
|
|
|
|
|
|
|
|
|
|
for (AbstractGameObject ago : worldCities.values()) { |
|
|
|
for (AbstractGameObject ago : worldCities.values()) { |
|
|
|
if (ago.getObjectType().equals(GameObjectType.City)) { |
|
|
|
if (ago.getObjectType().equals(GameObjectType.City)) { |
|
|
|
|
|
|
|
|
|
|
|
City city = (City) ago; |
|
|
|
City city = (City) ago; |
|
|
|
|
|
|
|
|
|
|
|
if (city.noRepledge) |
|
|
|
if (city.noRepledge) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
@ -402,11 +399,12 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
//list Player cities
|
|
|
|
//list Player cities
|
|
|
|
//open city, just list
|
|
|
|
//open city, just list
|
|
|
|
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) { |
|
|
|
|
|
|
|
|
|
|
|
if (playerCharacter.getAccount().status.equals(AccountStatus.ADMIN)) { |
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
|
} else if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { |
|
|
|
} else if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { |
|
|
|
|
|
|
|
|
|
|
|
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) |
|
|
|
if (!BuildingManager.IsPlayerHostile(city.getTOL(), playerCharacter)) |
|
|
|
cities.add(city); //verify nation or guild is same
|
|
|
|
cities.add(city); //verify nation or guild is same
|
|
|
|
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG)) |
|
|
|
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG)) |
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
@ -414,15 +412,16 @@ public class City extends AbstractWorldObject { |
|
|
|
} else if (city.isNpc == 1) { |
|
|
|
} else if (city.isNpc == 1) { |
|
|
|
//list NPC cities
|
|
|
|
//list NPC cities
|
|
|
|
|
|
|
|
|
|
|
|
Guild g = city.getGuild(); |
|
|
|
Guild guild = city.getGuild(); |
|
|
|
if (g == null) { |
|
|
|
|
|
|
|
|
|
|
|
if (guild == null) { |
|
|
|
if (city.isNpc == 1) |
|
|
|
if (city.isNpc == 1) |
|
|
|
if (city.isNoobIsle == 1) { |
|
|
|
if (city.isNoobIsle == 1) { |
|
|
|
if (pc.getLevel() < 21) |
|
|
|
if (playerCharacter.getLevel() < 21) |
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
|
} else if (pc.getLevel() > 9) |
|
|
|
} else if (playerCharacter.getLevel() > 9) |
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
|
} else if (pc.getLevel() >= g.getRepledgeMin() && pc.getLevel() <= g.getRepledgeMax()) { |
|
|
|
} else if (playerCharacter.getLevel() >= guild.getRepledgeMin() && playerCharacter.getLevel() <= guild.getRepledgeMax()) { |
|
|
|
|
|
|
|
|
|
|
|
cities.add(city); |
|
|
|
cities.add(city); |
|
|
|
} |
|
|
|
} |
|
|
@ -438,6 +437,7 @@ public class City extends AbstractWorldObject { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
City city = (City) DbManager.getFromCache(Enum.GameObjectType.City, cityId); |
|
|
|
City city = (City) DbManager.getFromCache(Enum.GameObjectType.City, cityId); |
|
|
|
|
|
|
|
|
|
|
|
if (city != null) |
|
|
|
if (city != null) |
|
|
|
return city; |
|
|
|
return city; |
|
|
|
|
|
|
|
|
|
|
@ -454,8 +454,10 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean renameCity(String cityName) { |
|
|
|
public boolean renameCity(String cityName) { |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.CityQueries.renameCity(this, cityName)) |
|
|
|
if (!DbManager.CityQueries.renameCity(this, cityName)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.CityQueries.updateforceRename(this, false)) |
|
|
|
if (!DbManager.CityQueries.updateforceRename(this, false)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
@ -465,17 +467,22 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean updateTOL(Building tol) { |
|
|
|
public boolean updateTOL(Building tol) { |
|
|
|
|
|
|
|
|
|
|
|
if (tol == null) |
|
|
|
if (tol == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.CityQueries.updateTOL(this, tol.getObjectUUID())) |
|
|
|
if (!DbManager.CityQueries.updateTOL(this, tol.getObjectUUID())) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
this.treeOfLifeID = tol.getObjectUUID(); |
|
|
|
this.treeOfLifeID = tol.getObjectUUID(); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean renameCityForNewPlant(String cityName) { |
|
|
|
public boolean renameCityForNewPlant(String cityName) { |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.CityQueries.renameCity(this, cityName)) |
|
|
|
if (!DbManager.CityQueries.renameCity(this, cityName)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.CityQueries.updateforceRename(this, true)) |
|
|
|
if (!DbManager.CityQueries.updateforceRename(this, true)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
@ -498,19 +505,11 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Building getTOL() { |
|
|
|
public Building getTOL() { |
|
|
|
|
|
|
|
|
|
|
|
if (this.treeOfLifeID == 0) |
|
|
|
if (this.treeOfLifeID == 0) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
return BuildingManager.getBuildingFromCache(this.treeOfLifeID); |
|
|
|
return BuildingManager.getBuildingFromCache(this.treeOfLifeID); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getIsNoobIsle() { |
|
|
|
|
|
|
|
return isNoobIsle; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getPopulation() { |
|
|
|
|
|
|
|
return population; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -540,14 +539,6 @@ public class City extends AbstractWorldObject { |
|
|
|
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID()); |
|
|
|
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public float getLatitude() { |
|
|
|
|
|
|
|
return this.location.x; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float getLongitude() { |
|
|
|
|
|
|
|
return this.location.z; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float getAltitude() { |
|
|
|
public float getAltitude() { |
|
|
|
return this.location.y; |
|
|
|
return this.location.y; |
|
|
|
} |
|
|
|
} |
|
|
@ -557,34 +548,10 @@ public class City extends AbstractWorldObject { |
|
|
|
return this.location; |
|
|
|
return this.location; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public byte getIsNpcOwned() { |
|
|
|
|
|
|
|
return isNpc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public byte getIsSafeHold() { |
|
|
|
|
|
|
|
return this.isSafeHold; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isSafeHold() { |
|
|
|
public boolean isSafeHold() { |
|
|
|
return (this.isSafeHold == (byte) 1); |
|
|
|
return (this.isSafeHold == (byte) 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public byte getIsCapital() { |
|
|
|
|
|
|
|
return isCapital; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setIsCapital(boolean state) { |
|
|
|
|
|
|
|
this.isCapital = (state) ? (byte) 1 : (byte) 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getRadiusType() { |
|
|
|
|
|
|
|
return this.radiusType; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float getBindRadius() { |
|
|
|
|
|
|
|
return this.bindRadius; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getRank() { |
|
|
|
public int getRank() { |
|
|
|
return (this.getTOL() == null) ? 0 : this.getTOL().getRank(); |
|
|
|
return (this.getTOL() == null) ? 0 : this.getTOL().getRank(); |
|
|
|
} |
|
|
|
} |
|
|
@ -650,13 +617,13 @@ public class City extends AbstractWorldObject { |
|
|
|
if (this.getTOL() == null) |
|
|
|
if (this.getTOL() == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.isNpc == 1) { |
|
|
|
if (this.isNpc == 1) { |
|
|
|
|
|
|
|
|
|
|
|
if (this.getTOL().getOwner() == null) |
|
|
|
if (this.getTOL().getOwner() == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
return this.getTOL().getOwner().getGuild(); |
|
|
|
return this.getTOL().getOwner().getGuild(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
if (this.getTOL().getOwner() == null) |
|
|
|
if (this.getTOL().getOwner() == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
return this.getTOL().getOwner().getGuild(); |
|
|
|
return this.getTOL().getOwner().getGuild(); |
|
|
@ -664,13 +631,16 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean openCity(boolean open) { |
|
|
|
public boolean openCity(boolean open) { |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.CityQueries.updateOpenCity(this, open)) |
|
|
|
if (!DbManager.CityQueries.updateOpenCity(this, open)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
this.open = open; |
|
|
|
this.open = open; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Vector3fImmutable getBindLoc() { |
|
|
|
public Vector3fImmutable getBindLoc() { |
|
|
|
|
|
|
|
|
|
|
|
Vector3fImmutable treeLoc = null; |
|
|
|
Vector3fImmutable treeLoc = null; |
|
|
|
|
|
|
|
|
|
|
|
if (this.getTOL() != null && this.getTOL().getRank() == 8) |
|
|
|
if (this.getTOL() != null && this.getTOL().getRank() == 8) |
|
|
@ -680,7 +650,9 @@ public class City extends AbstractWorldObject { |
|
|
|
return treeLoc; |
|
|
|
return treeLoc; |
|
|
|
|
|
|
|
|
|
|
|
if (this.radiusType == 1 && this.bindRadius > 0f) { |
|
|
|
if (this.radiusType == 1 && this.bindRadius > 0f) { |
|
|
|
|
|
|
|
|
|
|
|
//square radius
|
|
|
|
//square radius
|
|
|
|
|
|
|
|
|
|
|
|
float x = this.bindLoc.getX(); |
|
|
|
float x = this.bindLoc.getX(); |
|
|
|
float z = this.bindLoc.getZ(); |
|
|
|
float z = this.bindLoc.getZ(); |
|
|
|
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * this.bindRadius; |
|
|
|
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * this.bindRadius; |
|
|
@ -801,7 +773,6 @@ public class City extends AbstractWorldObject { |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.getTOL().addEffectBit((1 << 16)); |
|
|
|
this.getTOL().addEffectBit((1 << 16)); |
|
|
|
this.getBane().getStone().addEffectBit((1 << 19)); |
|
|
|
this.getBane().getStone().addEffectBit((1 << 19)); |
|
|
|
; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Logger.info("Failed ao add bane effects on city." + e.getMessage()); |
|
|
|
Logger.info("Failed ao add bane effects on city." + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
@ -826,6 +797,7 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
if (playerObject == null) |
|
|
|
if (playerObject == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (!this.isLocationWithinSiegeBounds(playerObject.getLoc())) |
|
|
|
if (!this.isLocationWithinSiegeBounds(playerObject.getLoc())) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
@ -842,7 +814,6 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
// Remove the city effect from the ago's internal collection
|
|
|
|
// Remove the city effect from the ago's internal collection
|
|
|
|
|
|
|
|
|
|
|
|
if (this.getEffects().containsKey(Integer.toString(effectBase.getUUID()))) |
|
|
|
|
|
|
|
this.getEffects().remove(Integer.toString(effectBase.getUUID())); |
|
|
|
this.getEffects().remove(Integer.toString(effectBase.getUUID())); |
|
|
|
|
|
|
|
|
|
|
|
// Any players currently in the zone will not be processed by the heartbeat
|
|
|
|
// Any players currently in the zone will not be processed by the heartbeat
|
|
|
@ -852,6 +823,7 @@ public class City extends AbstractWorldObject { |
|
|
|
for (Integer playerID : this._playerMemory) { |
|
|
|
for (Integer playerID : this._playerMemory) { |
|
|
|
|
|
|
|
|
|
|
|
player = PlayerCharacter.getFromCache(playerID); |
|
|
|
player = PlayerCharacter.getFromCache(playerID); |
|
|
|
|
|
|
|
|
|
|
|
if (player == null) |
|
|
|
if (player == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
@ -867,8 +839,10 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Warehouse getWarehouse() { |
|
|
|
public Warehouse getWarehouse() { |
|
|
|
|
|
|
|
|
|
|
|
if (this.warehouseBuildingID == 0) |
|
|
|
if (this.warehouseBuildingID == 0) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
return Warehouse.warehouseByBuildingUUID.get(this.warehouseBuildingID); |
|
|
|
return Warehouse.warehouseByBuildingUUID.get(this.warehouseBuildingID); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1040,7 +1014,6 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
_playerMemory.removeAll(toRemove); |
|
|
|
_playerMemory.removeAll(toRemove); |
|
|
|
for (Integer removalUUID : toRemove) { |
|
|
|
for (Integer removalUUID : toRemove) { |
|
|
|
if (this.cityOutlaws.contains(removalUUID)) |
|
|
|
|
|
|
|
this.cityOutlaws.remove(removalUUID); |
|
|
|
this.cityOutlaws.remove(removalUUID); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1142,6 +1115,7 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
// All protection contracts are void upon transfer of a city
|
|
|
|
// All protection contracts are void upon transfer of a city
|
|
|
|
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
|
|
|
|
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
|
|
|
|
|
|
|
|
|
|
|
|
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() |
|
|
|
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() |
|
|
|
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE) |
|
|
|
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE) |
|
|
|
cityBuilding.setProtectionState(ProtectionState.NONE); |
|
|
|
cityBuilding.setProtectionState(ProtectionState.NONE); |
|
|
@ -1173,7 +1147,6 @@ public class City extends AbstractWorldObject { |
|
|
|
Zone cityZone; |
|
|
|
Zone cityZone; |
|
|
|
sourceGuild = sourcePlayer.getGuild(); |
|
|
|
sourceGuild = sourcePlayer.getGuild(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sourceGuild == null) |
|
|
|
if (sourceGuild == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
@ -1229,14 +1202,6 @@ public class City extends AbstractWorldObject { |
|
|
|
this.forceRename = forceRename; |
|
|
|
this.forceRename = forceRename; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isReverseKOS() { |
|
|
|
|
|
|
|
return reverseKOS; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setReverseKOS(boolean reverseKOS) { |
|
|
|
|
|
|
|
this.reverseKOS = reverseKOS; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getHash() { |
|
|
|
public String getHash() { |
|
|
|
return hash; |
|
|
|
return hash; |
|
|
|
} |
|
|
|
} |
|
|
@ -1264,26 +1229,6 @@ public class City extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO use this for taxing later.
|
|
|
|
|
|
|
|
// public boolean isAfterTaxPeriod(LocalDateTime dateTime,PlayerCharacter player){
|
|
|
|
|
|
|
|
// if (dateTime.isBefore(realmTaxDate)){
|
|
|
|
|
|
|
|
// String wait = "";
|
|
|
|
|
|
|
|
// float hours = 1000*60*60;
|
|
|
|
|
|
|
|
// float seconds = 1000;
|
|
|
|
|
|
|
|
// float hoursUntil = realmTaxDate.minus(dateTime.get).getMillis() /hours;
|
|
|
|
|
|
|
|
// int secondsUntil = (int) (realmTaxDate.minus(dateTime.getMillis()).getMillis() /seconds);
|
|
|
|
|
|
|
|
// if (hoursUntil < 1)
|
|
|
|
|
|
|
|
// wait = "You must wait " + secondsUntil + " seconds before taxing this city again!";
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// wait = "You must wait " + hoursUntil + " hours before taxing this city again!";
|
|
|
|
|
|
|
|
// ErrorPopupMsg.sendErrorMsg(player, wait);
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) { |
|
|
|
public synchronized boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) { |
|
|
|
|
|
|
|
|
|
|
|
// Member variable declaration
|
|
|
|
// Member variable declaration
|
|
|
@ -1296,12 +1241,12 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
City city = building.getCity(); |
|
|
|
City city = building.getCity(); |
|
|
|
|
|
|
|
|
|
|
|
if (city == null) { |
|
|
|
if (city == null) { |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city."); |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city."); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playerGuild == null || playerGuild.isEmptyGuild()) { |
|
|
|
if (playerGuild == null || playerGuild.isEmptyGuild()) { |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!"); |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -1326,6 +1271,7 @@ public class City extends AbstractWorldObject { |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!"); |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Realm targetRealm = RealmMap.getRealmForCity(city); |
|
|
|
Realm targetRealm = RealmMap.getRealmForCity(city); |
|
|
|
|
|
|
|
|
|
|
|
if (targetRealm == null) { |
|
|
|
if (targetRealm == null) { |
|
|
@ -1354,31 +1300,32 @@ public class City extends AbstractWorldObject { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.realmTaxDate.isAfter(LocalDateTime.now())) |
|
|
|
if (this.realmTaxDate.isAfter(LocalDateTime.now())) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
if (msg.getResources().size() == 0) |
|
|
|
if (msg.getResources().size() == 0) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
if (city.getWarehouse() == null) |
|
|
|
if (city.getWarehouse() == null) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
Warehouse ruledWarehouse = playerGuild.getOwnedCity().getWarehouse(); |
|
|
|
Warehouse ruledWarehouse = playerGuild.getOwnedCity().getWarehouse(); |
|
|
|
|
|
|
|
|
|
|
|
if (ruledWarehouse == null) |
|
|
|
if (ruledWarehouse == null) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemBase.getItemHashIDMap(); |
|
|
|
ItemBase.getItemHashIDMap(); |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> resources = new ArrayList<>(); |
|
|
|
ArrayList<Integer> resources = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
float taxPercent = msg.getTaxPercent(); |
|
|
|
float taxPercent = msg.getTaxPercent(); |
|
|
|
|
|
|
|
|
|
|
|
if (taxPercent > 20) |
|
|
|
if (taxPercent > 20) |
|
|
|
taxPercent = .20f; |
|
|
|
taxPercent = .20f; |
|
|
|
|
|
|
|
|
|
|
|
for (int resourceHash : msg.getResources().keySet()) { |
|
|
|
for (int resourceHash : msg.getResources().keySet()) { |
|
|
|
if (ItemBase.getItemHashIDMap().get(resourceHash) != null) |
|
|
|
if (ItemBase.getItemHashIDMap().get(resourceHash) != null) |
|
|
|
resources.add(ItemBase.getItemHashIDMap().get(resourceHash)); |
|
|
|
resources.add(ItemBase.getItemHashIDMap().get(resourceHash)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (Integer itemBaseID : resources) { |
|
|
|
for (Integer itemBaseID : resources) { |
|
|
@ -1396,6 +1343,7 @@ public class City extends AbstractWorldObject { |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Failed to Update next Tax Date due to internal Error. City was not charged taxes this time."); |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Failed to Update next Tax Date due to internal Error. City was not charged taxes this time."); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
city.getWarehouse().transferResources(player, msg, resources, taxPercent, ruledWarehouse); |
|
|
|
city.getWarehouse().transferResources(player, msg, resources, taxPercent, ruledWarehouse); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -1413,6 +1361,5 @@ public class City extends AbstractWorldObject { |
|
|
|
dispatch = Dispatch.borrow(player, msg); |
|
|
|
dispatch = Dispatch.borrow(player, msg); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|