public void applyTemplate(Player player, FlagPermissions list, boolean resadmin) {
   if (player != null) {
     if (!resadmin) {
       if (!Residence.getConfigManager().isOfflineMode()
           && !player.getUniqueId().toString().equals(ownerUUID.toString())) {
         player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
         return;
       } else if (!player.getName().equals(ownerLastKnownName)) {
         player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
         return;
       }
     }
   } else {
     resadmin = true;
   }
   PermissionGroup group = Residence.getPermissionManager().getGroup(this.getOwner(), world);
   for (Entry<String, Boolean> flag : list.cuboidFlags.entrySet()) {
     if (group.hasFlagAccess(flag.getKey()) || resadmin) {
       this.cuboidFlags.put(flag.getKey(), flag.getValue());
     } else {
       if (player != null)
         player.sendMessage(
             ChatColor.RED
                 + Residence.getLanguage()
                     .getPhrase("FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
     }
   }
   for (Entry<String, Map<String, Boolean>> plists : list.playerFlags.entrySet()) {
     Map<String, Boolean> map = this.getPlayerFlags(plists.getKey(), true);
     for (Entry<String, Boolean> flag : plists.getValue().entrySet()) {
       if (group.hasFlagAccess(flag.getKey()) || resadmin) {
         map.put(flag.getKey(), flag.getValue());
       } else {
         if (player != null)
           player.sendMessage(
               ChatColor.RED
                   + Residence.getLanguage()
                       .getPhrase(
                           "FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
       }
     }
   }
   for (Entry<String, Map<String, Boolean>> glists : list.groupFlags.entrySet()) {
     for (Entry<String, Boolean> flag : glists.getValue().entrySet()) {
       if (group.hasFlagAccess(flag.getKey()) || resadmin) {
         if (!this.groupFlags.containsKey(glists.getKey()))
           this.groupFlags.put(
               glists.getKey(), Collections.synchronizedMap(new HashMap<String, Boolean>()));
         this.groupFlags.get(glists.getKey()).put(flag.getKey(), flag.getValue());
       } else {
         if (player != null)
           player.sendMessage(
               ChatColor.RED
                   + Residence.getLanguage()
                       .getPhrase(
                           "FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
       }
     }
   }
   if (player != null)
     player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("PermissionsApply"));
 }
 private boolean hasFlagAccess(String player, String flag) {
   PermissionGroup group = Residence.getPermissionManager().getGroup(player, world);
   return group.hasFlagAccess(flag);
 }