@SuppressWarnings("deprecation")
 public void useAltar(Player player) {
   Location location = player.getLocation();
   World world = location.getWorld();
   int locX = location.getBlockX();
   int locY = location.getBlockY();
   int locZ = location.getBlockZ();
   SuperNPlayer snplayer = SuperNManager.get(player);
   int amount = 0;
   int delta = 0;
   if (world.getName().equalsIgnoreCase(SNConfigHandler.priestChurchWorld)) {
     if (Math.abs(locX - SNConfigHandler.priestChurchLocationX) <= 10) {
       if (Math.abs(locY - SNConfigHandler.priestChurchLocationY) <= 10) {
         if (Math.abs(locZ - SNConfigHandler.priestChurchLocationZ) <= 10) {
           if (snplayer.isPriest()) {
             if (player.getItemInHand().getType().equals(Material.COAL)) {
               SuperNManager.sendMessage(snplayer, "The Church excommunicates you!");
               SuperNManager.cure(snplayer);
             } else {
               PlayerInventory inv = player.getInventory();
               ItemStack[] items = inv.getContents();
               for (Material mat : SNConfigHandler.priestDonationMap.keySet()) {
                 for (ItemStack itemStack : items) {
                   if (itemStack != null) {
                     if (itemStack.getType().equals(mat)) {
                       amount += itemStack.getAmount();
                     }
                   }
                 }
                 delta += amount * SNConfigHandler.priestDonationMap.get(mat);
                 amount = 0;
               }
               for (Material mat : SNConfigHandler.priestDonationMap.keySet()) {
                 inv.remove(mat);
               }
               player.updateInventory();
               SuperNManager.sendMessage(
                   snplayer,
                   "The Church accepts your gracious donations of Bread, Fish, Grilled Pork and Apples.");
               SuperNManager.alterPower(snplayer, delta, "Donations!");
             }
           } else {
             SuperNManager.sendMessage(snplayer, "The Church Altar radiates holy power.");
             if (snplayer.isSuper()) {
               SuperNManager.sendMessage(
                   snplayer, "The holy power of the Church tears you asunder!");
               EntityDamageEvent event =
                   new EntityDamageEvent(player, DamageCause.BLOCK_EXPLOSION, 20);
               player.setLastDamageCause(event);
               player.setHealth(0);
               if (snplayer.isGhoul()) {
                 double random = Math.random();
                 if (random < SNConfigHandler.ghoulCureChance - 0.1) {
                   SuperNManager.cure(snplayer);
                 }
               }
               return;
             }
             if (SNConfigHandler.priestAltarRecipe.playerHasEnough(player)) {
               if (!SupernaturalsPlugin.hasPermissions(
                   player, "supernatural.player.shrineuse.priest")) {
                 SuperNManager.sendMessage(snplayer, "You cannot use priest altars.");
                 return;
               }
               SuperNManager.sendMessage(snplayer, "You donate these items to the Church:");
               SuperNManager.sendMessage(
                   snplayer, SNConfigHandler.priestAltarRecipe.getRecipeLine());
               SuperNManager.sendMessage(
                   snplayer,
                   "The Church recognizes your holy spirit and accepts you into the priesthood.");
               SNConfigHandler.priestAltarRecipe.removeFromPlayer(player);
               SuperNManager.convert(snplayer, "priest", SNConfigHandler.priestPowerStart);
             } else {
               SuperNManager.sendMessage(
                   snplayer,
                   "The Church judges your intended donate insufficient.  You must gather the following: ");
               SuperNManager.sendMessage(
                   snplayer, SNConfigHandler.priestAltarRecipe.getRecipeLine());
             }
           }
         }
       }
     }
   }
 }
  /** @see Runnable.run() */
  public void run() {
    if (!War.war.isLoaded()) {
      return;
    }
    for (Warzone zone : War.war.getWarzones()) {
      for (Team team : zone.getTeams()) {
        for (Player player : team.getPlayers()) {
          PlayerInventory playerInv = player.getInventory();
          Material teamBlockMaterial;
          if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
            teamBlockMaterial = team.getKind().getMaterial();
            // 1) Replace missing block head
            if (playerInv.getHelmet().getType() != teamBlockMaterial) {
              playerInv.setHelmet(this.createBlockHead(team));
            }
            // 2) Get rid of extra blocks in inventory: only keep one
            HashMap<Integer, ? extends ItemStack> blocks = playerInv.all(teamBlockMaterial);
            if (blocks.size() > 1
                || (blocks.size() == 1
                    && blocks.get(blocks.keySet().iterator().next()).getAmount() > 1)) {
              int i = 0;
              int removed = 0;
              for (ItemStack item : playerInv.getContents()) {
                // remove only same colored wool
                if (item != null
                    && item.getType() == teamBlockMaterial
                    && item.getData().getData() == team.getKind().getData()) {
                  playerInv.clear(i);
                  removed++;
                }
                i++;
              }

              int firstEmpty = playerInv.firstEmpty();
              if (firstEmpty > 0) {
                playerInv.setItem(firstEmpty, this.createBlockHead(team));
              }

              if (removed > 1) {
                War.war.badMsg(
                    player, "All that " + team.getName() + " wool must have been heavy!");
              }
            }
          } else {
            // enfore helmet (good thing?)
            if (team.getKind() == TeamKind.GOLD) {
              teamBlockMaterial = Material.GOLD_HELMET;
            } else if (team.getKind() == TeamKind.DIAMOND) {
              teamBlockMaterial = Material.DIAMOND_HELMET;
            } else if (team.getKind() == TeamKind.IRON) {
              teamBlockMaterial = Material.IRON_HELMET;
            } else {
              teamBlockMaterial = Material.LEATHER_HELMET;
            }
            if (playerInv.getHelmet() != null
                && playerInv.getHelmet().getType() != teamBlockMaterial) {
              playerInv.setHelmet(new ItemStack(teamBlockMaterial));
            }
            HashMap<Integer, ? extends ItemStack> helmets = playerInv.all(teamBlockMaterial);
            if (helmets.size() > 1
                || (helmets.size() == 1
                    && helmets.get(helmets.keySet().iterator().next()).getAmount() > 1)) {
              playerInv.remove(teamBlockMaterial);
              playerInv.setItem(playerInv.firstEmpty(), new ItemStack(teamBlockMaterial));
              War.war.badMsg(player, "All those helmets must have been heavy!");
            }
          }

          // check for thieves without their treasure in their hands
          if (zone.isFlagThief(player.getName())) {
            Team victim = zone.getVictimTeamForFlagThief(player.getName());
            player.setItemInHand(null);
            player
                .getInventory()
                .addItem(
                    new ItemStack(
                        victim.getKind().getMaterial(),
                        2240,
                        victim.getKind().getData(),
                        victim.getKind().getData()));
          } else if (zone.isBombThief(player.getName())) {
            player.setItemInHand(null);
            player.getInventory().addItem(new ItemStack(Material.TNT, 2240));
          } else if (zone.isCakeThief(player.getName())) {
            player.setItemInHand(null);
            player.getInventory().addItem(new ItemStack(Material.CAKE_BLOCK, 2240));
          }
        }
      }
    }
  }