use of com.gmail.goosius.siegewar.objects.Siege in project SiegeWar by TownyAdvanced.
the class SiegeWarWallBreachUtil method evaluateWallBreaching.
/**
* Evaluate wall breaching
*/
public static void evaluateWallBreaching() {
// Return if battle session is inactive
if (!BattleSession.getBattleSession().isActive())
return;
// Cycle all sieges
for (Siege siege : SiegeController.getSieges()) {
increaseBreachPointsFromBannerControl(siege);
awardWallBreachBonuses(siege);
CannonsIntegration.clearRecentTownFriendlycannonFirers(siege);
}
}
use of com.gmail.goosius.siegewar.objects.Siege in project SiegeWar by TownyAdvanced.
the class SiegeWarTownEventListener method onTownClaim.
/*
* Upon attempting to claim land, SW will stop it under some conditions.
*/
@EventHandler
public void onTownClaim(TownPreClaimEvent event) {
if (SiegeWarSettings.getWarSiegeEnabled()) {
if (SiegeWarSettings.getWarSiegeBesiegedTownClaimingDisabled()) {
// If the claimer's town is under siege, they cannot claim any land
if (SiegeController.hasActiveSiege(event.getTown())) {
event.setCancelled(true);
event.setCancelMessage(Translation.of("siegewar_plugin_prefix") + Translation.of("msg_err_siege_besieged_town_cannot_claim"));
return;
}
// If the town is fighting a home-defence war, they cannot claim any land
if (SiegeWarSettings.isNationSiegeImmunityEnabled() && SiegeController.isTownsNationFightingAHomeDefenceWar(event.getTown())) {
event.setCancelled(true);
event.setCancelMessage(Translation.of("siegewar_plugin_prefix") + Translation.of("msg_err_siege_affected_home_nation_town_cannot_claim"));
return;
}
}
// If the land is too near any active siege zone, it cannot be claimed.
if (SiegeWarSettings.getWarSiegeClaimingDisabledNearSiegeZones()) {
for (Siege siege : SiegeController.getSieges()) {
try {
if (siege.getStatus().isActive() && SiegeWarDistanceUtil.isInSiegeZone(event.getPlayer(), siege)) {
event.setCancelled(true);
event.setCancelMessage(Translation.of("siegewar_plugin_prefix") + Translation.of("msg_err_siege_claim_too_near_siege_zone"));
break;
}
} catch (Exception e) {
// Problem with this particular siegezone. Ignore siegezone
try {
SiegeWar.severe("Problem with verifying claim against the following siege zone" + siege.getTown().getName() + ". Claim allowed.");
} catch (Exception e2) {
SiegeWar.severe("Problem with verifying claim against a siege zone (name could not be read). Claim allowed");
}
e.printStackTrace();
}
}
}
}
}
Aggregations