Search in sources :

Example 21 with Siege

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);
    }
}
Also used : Siege(com.gmail.goosius.siegewar.objects.Siege)

Example 22 with 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();
                }
            }
        }
    }
}
Also used : Siege(com.gmail.goosius.siegewar.objects.Siege) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Siege (com.gmail.goosius.siegewar.objects.Siege)22 Resident (com.palmergames.bukkit.towny.object.Resident)7 Town (com.palmergames.bukkit.towny.object.Town)7 Translator (com.palmergames.bukkit.towny.object.Translator)6 EventHandler (org.bukkit.event.EventHandler)5 TownyException (com.palmergames.bukkit.towny.exceptions.TownyException)4 Nation (com.palmergames.bukkit.towny.object.Nation)4 ArrayList (java.util.ArrayList)4 TextComponent (net.md_5.bungee.api.chat.TextComponent)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 Material (org.bukkit.Material)2 Block (org.bukkit.block.Block)2 SiegeSide (com.gmail.goosius.siegewar.enums.SiegeSide)1 SiegeStatus (com.gmail.goosius.siegewar.enums.SiegeStatus)1 BattleSessionEndedEvent (com.gmail.goosius.siegewar.events.BattleSessionEndedEvent)1 SiegeWarStartEvent (com.gmail.goosius.siegewar.events.SiegeWarStartEvent)1 BattleSession (com.gmail.goosius.siegewar.objects.BattleSession)1 TextComponent (com.palmergames.adventure.text.TextComponent)1 TownyUniverse (com.palmergames.bukkit.towny.TownyUniverse)1