use of com.palmergames.bukkit.towny.event.town.TownUnclaimEvent in project Towny by TownyAdvanced.
the class TownyDatabaseHandler method removeTownBlock.
@Override
public void removeTownBlock(TownBlock townBlock) {
Town town = townBlock.getTownOrNull();
if (town == null)
// Log as error because TownBlocks *must* have a town.
logger.error(String.format("The TownBlock at (%s, %d, %d) is not registered to a town.", townBlock.getWorld().getName(), townBlock.getX(), townBlock.getZ()));
TownPreUnclaimEvent event = new TownPreUnclaimEvent(town, townBlock);
BukkitTools.getPluginManager().callEvent(event);
if (event.isCancelled()) {
// Log as Warn because the event has been processed
logger.warn(event.getCancelMessage());
return;
}
if (townBlock.isJail() && townBlock.getJail() != null)
removeJail(townBlock.getJail());
universe.removeTownBlock(townBlock);
deleteTownBlock(townBlock);
if (townBlock.getWorld().isUsingPlotManagementDelete())
TownyRegenAPI.addDeleteTownBlockIdQueue(townBlock.getWorldCoord());
// Move the plot to be restored
if (townBlock.getWorld().isUsingPlotManagementRevert())
TownyRegenAPI.addToRegenQueueList(townBlock.getWorldCoord(), true);
// Raise an event to signal the unclaim
BukkitTools.getPluginManager().callEvent(new TownUnclaimEvent(town, townBlock.getWorldCoord()));
}
Aggregations