Search in sources :

Example 1 with TownUnclaimEvent

use of com.palmergames.bukkit.towny.event.TownUnclaimEvent in project Towny by ElgarL.

the class TownClaim method townUnclaim.

private void townUnclaim(final Town town, final WorldCoord worldCoord, boolean force) throws TownyException {
    try {
        final TownBlock townBlock = worldCoord.getTownBlock();
        if (town != townBlock.getTown() && !force)
            throw new TownyException(TownySettings.getLangString("msg_area_not_own"));
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

            @Override
            public void run() {
                TownyUniverse.getDataSource().removeTownBlock(townBlock);
                // Raise an event to signal the unclaim
                BukkitTools.getPluginManager().callEvent(new TownUnclaimEvent(town, worldCoord));
            }
        }, 1);
    } catch (NotRegisteredException e) {
        throw new TownyException(TownySettings.getLangString("msg_not_claimed_1"));
    }
}
Also used : NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) TownUnclaimEvent(com.palmergames.bukkit.towny.event.TownUnclaimEvent) TownBlock(com.palmergames.bukkit.towny.object.TownBlock) TownyException(com.palmergames.bukkit.towny.exceptions.TownyException)

Aggregations

TownUnclaimEvent (com.palmergames.bukkit.towny.event.TownUnclaimEvent)1 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)1 TownyException (com.palmergames.bukkit.towny.exceptions.TownyException)1 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)1