package com.zivilon.cinder_loe.mixins;

import lotr.common.LOTRLevelData;
import lotr.common.fac.LOTRFactionRelations;
import lotr.common.fac.LOTRFactionRelations.Relation;
import lotr.common.fac.LOTRControlZone;
import lotr.common.fac.LOTRFaction;
import lotr.common.world.map.LOTRWaypoint;
import lotr.common.fac.LOTRFactionRank;
import lotr.common.LOTRAchievement;

import java.lang.reflect.Field;
import java.util.List;
import java.util.Collections;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(LOTRFaction.class)
public class MixinLOTRFaction {
    private static LOTRFaction HOBBIT = LOTRFaction.HOBBIT;
    private static LOTRFaction BREE = LOTRFaction.BREE;
    private static LOTRFaction RANGER_NORTH = LOTRFaction.RANGER_NORTH;
    private static LOTRFaction BLUE_MOUNTAINS = LOTRFaction.BLUE_MOUNTAINS;
    private static LOTRFaction HIGH_ELF = LOTRFaction.HIGH_ELF;
    private static LOTRFaction GUNDABAD = LOTRFaction.GUNDABAD;
    private static LOTRFaction ANGMAR = LOTRFaction.ANGMAR;
    private static LOTRFaction WOOD_ELF = LOTRFaction.WOOD_ELF;
    private static LOTRFaction DOL_GULDUR = LOTRFaction.DOL_GULDUR;
    private static LOTRFaction DALE = LOTRFaction.DALE;
    private static LOTRFaction DURINS_FOLK = LOTRFaction.DURINS_FOLK;
    private static LOTRFaction LOTHLORIEN = LOTRFaction.LOTHLORIEN;
    private static LOTRFaction DUNLAND = LOTRFaction.DUNLAND;
    private static LOTRFaction ISENGARD = LOTRFaction.ISENGARD;
    private static LOTRFaction FANGORN = LOTRFaction.FANGORN;
    private static LOTRFaction ROHAN = LOTRFaction.ROHAN;
    private static LOTRFaction GONDOR = LOTRFaction.GONDOR;
    private static LOTRFaction MORDOR = LOTRFaction.MORDOR;
    private static LOTRFaction DORWINION = LOTRFaction.DORWINION;
    private static LOTRFaction RHUDEL = LOTRFaction.RHUDEL;
    private static LOTRFaction NEAR_HARAD = LOTRFaction.NEAR_HARAD;
    private static LOTRFaction MORWAITH = LOTRFaction.MORWAITH;
    private static LOTRFaction TAURETHRIM = LOTRFaction.TAURETHRIM;
    private static LOTRFaction HALF_TROLL = LOTRFaction.HALF_TROLL;
    private static LOTRFaction DARK_HUORN = LOTRFaction.DARK_HUORN;
    private static LOTRFaction RUFFIAN = LOTRFaction.RUFFIAN;
    private static LOTRFaction UTUMNO = LOTRFaction.UTUMNO;
    private static LOTRFaction HOSTILE = LOTRFaction.HOSTILE;
    private static LOTRFaction UNALIGNED = LOTRFaction.UNALIGNED;

    @Shadow(remap = false)
    public static LOTRFaction[] values() {return null;}

    @Overwrite(remap = false)
    public static void initAllProperties() {
        register_default_relations();
        register_war_crimes();
        register_control_zones();
        register_isolationist();
        register_legacy_aliases();
        register_achievement_categories();
        register_achievement_ranks();
    }

    private static void register_default_relations() {
        for (LOTRFaction f : values()) {
            if (f.allowPlayer && f != UTUMNO)
                LOTRFactionRelations.setDefaultRelations(f, UTUMNO, LOTRFactionRelations.Relation.MORTAL_ENEMY);
            if (f.allowPlayer && f != DARK_HUORN)
                LOTRFactionRelations.setDefaultRelations(f, DARK_HUORN, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        }
        // Hobbits
        LOTRFactionRelations.setDefaultRelations(HOBBIT, BREE, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, RANGER_NORTH, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, DALE, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, HIGH_ELF, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, BLUE_MOUNTAINS, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, DURINS_FOLK, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, ANGMAR, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, ISENGARD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, DOL_GULDUR, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HOBBIT, GUNDABAD, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Bree-land
        LOTRFactionRelations.setDefaultRelations(BREE, RANGER_NORTH, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(BREE, ISENGARD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(BREE, GUNDABAD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(BREE, ANGMAR, LOTRFactionRelations.Relation.ENEMY);

        // Dúnedain of the North
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, HIGH_ELF, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, GONDOR, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, BLUE_MOUNTAINS, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, WOOD_ELF, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, ROHAN, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, NEAR_HARAD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, DOL_GULDUR, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, ISENGARD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, ANGMAR, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, GUNDABAD, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(RANGER_NORTH, NEAR_HARAD, LOTRFactionRelations.Relation.ENEMY);

        // Blue Mountains
        LOTRFactionRelations.setDefaultRelations(BLUE_MOUNTAINS, DURINS_FOLK, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(BLUE_MOUNTAINS, HIGH_ELF, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(BLUE_MOUNTAINS, FANGORN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(BLUE_MOUNTAINS, GUNDABAD, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(BLUE_MOUNTAINS, ANGMAR, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // High elves
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, LOTHLORIEN, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, GONDOR, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, DURINS_FOLK, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, ISENGARD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, GUNDABAD, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, ANGMAR, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(HIGH_ELF, DOL_GULDUR, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Gundabad
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, ANGMAR, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, DOL_GULDUR, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, ISENGARD, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, DALE, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, ROHAN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, GONDOR, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, FANGORN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, DORWINION, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, LOTHLORIEN, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, WOOD_ELF, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(GUNDABAD, DURINS_FOLK, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Angmar
        LOTRFactionRelations.setDefaultRelations(ANGMAR, DOL_GULDUR, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(ANGMAR, WOOD_ELF, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(ANGMAR, ROHAN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(ANGMAR, GONDOR, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(ANGMAR, FANGORN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(ANGMAR, LOTHLORIEN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(ANGMAR, DURINS_FOLK, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Woodland Realm
        LOTRFactionRelations.setDefaultRelations(WOOD_ELF, LOTHLORIEN, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(WOOD_ELF, DALE, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(WOOD_ELF, DURINS_FOLK, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(WOOD_ELF, ISENGARD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(WOOD_ELF, DOL_GULDUR, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Dol Guldur
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, GONDOR, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, ROHAN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, DURINS_FOLK, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, DORWINION, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, FANGORN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, DALE, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DOL_GULDUR, LOTHLORIEN, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Dale
        LOTRFactionRelations.setDefaultRelations(DALE, ROHAN, LOTRFactionRelations.Relation.FRIEND);

        // Durin's Folk
        LOTRFactionRelations.setDefaultRelations(DURINS_FOLK, DALE, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(DURINS_FOLK, DUNLAND, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(DURINS_FOLK, ISENGARD, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(DURINS_FOLK, FANGORN, LOTRFactionRelations.Relation.ENEMY);

        // Lothlórien
        LOTRFactionRelations.setDefaultRelations(LOTHLORIEN, FANGORN, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(LOTHLORIEN, ROHAN, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(LOTHLORIEN, ISENGARD, LOTRFactionRelations.Relation.ENEMY);

        // Dunland
        LOTRFactionRelations.setDefaultRelations(DUNLAND, ROHAN, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Isengard
        LOTRFactionRelations.setDefaultRelations(ISENGARD, DUNLAND, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(ISENGARD, ROHAN, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(ISENGARD, FANGORN, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Gondor
        LOTRFactionRelations.setDefaultRelations(GONDOR, ROHAN, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(GONDOR, DORWINION, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(GONDOR, DUNLAND, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GONDOR, MORWAITH, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(GONDOR, RHUDEL, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(GONDOR, ISENGARD, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(GONDOR, NEAR_HARAD, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Half-trolls
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, NEAR_HARAD, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, MORWAITH, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, DALE, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, HIGH_ELF, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, LOTHLORIEN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, WOOD_ELF, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, HOBBIT, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, BREE, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, RANGER_NORTH, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, DUNLAND, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, ROHAN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, DORWINION, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, FANGORN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, GONDOR, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(HALF_TROLL, TAURETHRIM, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Morwaith
        LOTRFactionRelations.setDefaultRelations(MORWAITH, TAURETHRIM, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORWAITH, ROHAN, LOTRFactionRelations.Relation.ENEMY);

        // Near Harad
        LOTRFactionRelations.setDefaultRelations(NEAR_HARAD, TAURETHRIM, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(NEAR_HARAD, MORWAITH, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(NEAR_HARAD, ROHAN, LOTRFactionRelations.Relation.MORTAL_ENEMY);

        // Rhúdel
        LOTRFactionRelations.setDefaultRelations(RHUDEL, ROHAN, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(RHUDEL, WOOD_ELF, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(RHUDEL, DALE, LOTRFactionRelations.Relation.ENEMY);

        // Dorwinion
        LOTRFactionRelations.setDefaultRelations(DORWINION, RHUDEL, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(DORWINION, WOOD_ELF, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(DORWINION, DALE, LOTRFactionRelations.Relation.FRIEND);

        // Mordor
        LOTRFactionRelations.setDefaultRelations(MORDOR, HALF_TROLL, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, ANGMAR, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, DOL_GULDUR, LOTRFactionRelations.Relation.ALLY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, RHUDEL, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(MORDOR, ISENGARD, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(MORDOR, MORWAITH, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(MORDOR, GUNDABAD, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(MORDOR, NEAR_HARAD, LOTRFactionRelations.Relation.FRIEND);
        LOTRFactionRelations.setDefaultRelations(MORDOR, HOBBIT, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, BREE, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, DALE, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, BLUE_MOUNTAINS, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, TAURETHRIM, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, DURINS_FOLK, LOTRFactionRelations.Relation.ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, DORWINION, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, GONDOR, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, FANGORN, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, WOOD_ELF, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, RANGER_NORTH, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, HIGH_ELF, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, LOTHLORIEN, LOTRFactionRelations.Relation.MORTAL_ENEMY);
        LOTRFactionRelations.setDefaultRelations(MORDOR, ROHAN, LOTRFactionRelations.Relation.MORTAL_ENEMY);

    }

    private static void register_war_crimes() {
        HOBBIT.approvesWarCrimes = false;
        BREE.approvesWarCrimes = false;
        RANGER_NORTH.approvesWarCrimes = false;
        BLUE_MOUNTAINS.approvesWarCrimes = false;
        HIGH_ELF.approvesWarCrimes = false;
        GUNDABAD.approvesWarCrimes = true;
        ANGMAR.approvesWarCrimes = true;
        WOOD_ELF.approvesWarCrimes = false;
        DOL_GULDUR.approvesWarCrimes = true;
        DALE.approvesWarCrimes = false;
        DURINS_FOLK.approvesWarCrimes = false;
        LOTHLORIEN.approvesWarCrimes = false;
        DUNLAND.approvesWarCrimes = true;
        ISENGARD.approvesWarCrimes = true;
        FANGORN.approvesWarCrimes = false;
        ROHAN.approvesWarCrimes = false;
        GONDOR.approvesWarCrimes = false;
        MORDOR.approvesWarCrimes = true;
        DORWINION.approvesWarCrimes = false;
        RHUDEL.approvesWarCrimes = false;
        NEAR_HARAD.approvesWarCrimes = false;
        MORWAITH.approvesWarCrimes = true;
        TAURETHRIM.approvesWarCrimes = true;
        HALF_TROLL.approvesWarCrimes = true;
        UTUMNO.approvesWarCrimes = true;
    }
    private static void register_isolationist() {
        HOBBIT.isolationist = true;
        FANGORN.isolationist = true;
    }
    private static void register_control_zones() {
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.BYWATER, 40));
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.BUCKLEBURY, 15));
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.HAYSEND, 10));
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.MICHEL_DELVING, 35));
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.GREENHOLM, 10));
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.LONGBOTTOM, 30));
        add_control_zone_reflection(HOBBIT, new LOTRControlZone(LOTRWaypoint.BREE, 15));
        add_control_zone_reflection(BREE, new LOTRControlZone(LOTRWaypoint.BREE, 25));
        add_control_zone_reflection(BREE, new LOTRControlZone(LOTRWaypoint.ARCHET, 20));
        add_control_zone_reflection(BREE, new LOTRControlZone(LOTRWaypoint.FORSAKEN_INN, 15));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.BYWATER, 110));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.SARN_FORD, 60));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.LAST_BRIDGE, 110));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.BREE, 100));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.ANNUMINAS, 50));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.FORNOST, 50));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.MOUNT_GRAM, 100));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.CARN_DUM, 60));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.GREENWAY_CROSSROADS, 60));
        add_control_zone_reflection(RANGER_NORTH, new LOTRControlZone(LOTRWaypoint.THARBAD, 50));
        add_control_zone_reflection(BLUE_MOUNTAINS, new LOTRControlZone(LOTRWaypoint.BELEGOST, 40));
        add_control_zone_reflection(BLUE_MOUNTAINS, new LOTRControlZone(LOTRWaypoint.NOGROD, 40));
        add_control_zone_reflection(BLUE_MOUNTAINS, new LOTRControlZone(LOTRWaypoint.THORIN_HALLS, 50));
        add_control_zone_reflection(BLUE_MOUNTAINS, new LOTRControlZone(695.0D, 820.0D, 80));
        add_control_zone_reflection(HIGH_ELF, new LOTRControlZone(LOTRWaypoint.MITHLOND_SOUTH, 60));
        add_control_zone_reflection(HIGH_ELF, new LOTRControlZone(LOTRWaypoint.FORLOND, 80));
        add_control_zone_reflection(HIGH_ELF, new LOTRControlZone(LOTRWaypoint.HARLOND, 80));
        add_control_zone_reflection(HIGH_ELF, new LOTRControlZone(LOTRWaypoint.FORD_BRUINEN, 50));
        add_control_zone_reflection(GUNDABAD, new LOTRControlZone(LOTRWaypoint.MOUNT_GUNDABAD, 200));
        add_control_zone_reflection(GUNDABAD, new LOTRControlZone(LOTRWaypoint.MOUNT_GRAM, 200));
        add_control_zone_reflection(GUNDABAD, new LOTRControlZone(LOTRWaypoint.GOBLIN_TOWN, 150));
        add_control_zone_reflection(GUNDABAD, new LOTRControlZone(LOTRWaypoint.MOUNT_CARADHRAS, 100));
        add_control_zone_reflection(ANGMAR, new LOTRControlZone(LOTRWaypoint.CARN_DUM, 75));
        add_control_zone_reflection(ANGMAR, new LOTRControlZone(LOTRWaypoint.MOUNT_GRAM, 125));
        add_control_zone_reflection(ANGMAR, new LOTRControlZone(LOTRWaypoint.THE_TROLLSHAWS, 50));
        add_control_zone_reflection(WOOD_ELF, new LOTRControlZone(LOTRWaypoint.ENCHANTED_RIVER, 75));
        add_control_zone_reflection(WOOD_ELF, new LOTRControlZone(LOTRWaypoint.FOREST_GATE, 20));
        add_control_zone_reflection(WOOD_ELF, new LOTRControlZone(LOTRWaypoint.DOL_GULDUR, 30));
        add_control_zone_reflection(DOL_GULDUR, new LOTRControlZone(LOTRWaypoint.DOL_GULDUR, 125));
        add_control_zone_reflection(DOL_GULDUR, new LOTRControlZone(LOTRWaypoint.ENCHANTED_RIVER, 75));
        add_control_zone_reflection(DALE, new LOTRControlZone(LOTRWaypoint.DALE_CROSSROADS, 175));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.EREBOR, 75));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.WEST_PEAK, 100));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.EAST_PEAK, 75));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.REDWATER_FORD, 75));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.MOUNT_CARADHRAS, 100));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.MOUNT_GUNDABAD, 100));
        add_control_zone_reflection(DURINS_FOLK, new LOTRControlZone(LOTRWaypoint.DAINS_HALLS, 50));
        add_control_zone_reflection(LOTHLORIEN, new LOTRControlZone(LOTRWaypoint.CARAS_GALADHON, 100));
        add_control_zone_reflection(DUNLAND, new LOTRControlZone(LOTRWaypoint.SOUTH_DUNLAND, 125));
        add_control_zone_reflection(ISENGARD, new LOTRControlZone(LOTRWaypoint.ISENGARD, 100));
        add_control_zone_reflection(ISENGARD, new LOTRControlZone(LOTRWaypoint.EDORAS, 50));
        add_control_zone_reflection(FANGORN, new LOTRControlZone(1180.0D, 1005.0D, 70));
        add_control_zone_reflection(ROHAN, new LOTRControlZone(LOTRWaypoint.ENTWADE, 150));
        add_control_zone_reflection(ROHAN, new LOTRControlZone(LOTRWaypoint.ISENGARD, 100));
        add_control_zone_reflection(GONDOR, new LOTRControlZone(LOTRWaypoint.MINAS_TIRITH, 200));
        add_control_zone_reflection(GONDOR, new LOTRControlZone(LOTRWaypoint.EDHELLOND, 125));
        add_control_zone_reflection(GONDOR, new LOTRControlZone(LOTRWaypoint.GREEN_HILLS, 100));
        add_control_zone_reflection(GONDOR, new LOTRControlZone(LOTRWaypoint.CROSSINGS_OF_POROS, 150));
        add_control_zone_reflection(GONDOR, new LOTRControlZone(LOTRWaypoint.CROSSINGS_OF_HARAD, 75));
        add_control_zone_reflection(GONDOR, new LOTRControlZone(LOTRWaypoint.UMBAR_CITY, 150));
        add_control_zone_reflection(MORDOR, new LOTRControlZone(LOTRWaypoint.BARAD_DUR, 500));
        add_control_zone_reflection(DORWINION, new LOTRControlZone(LOTRWaypoint.DORWINION_COURT, 175));
        add_control_zone_reflection(DORWINION, new LOTRControlZone(LOTRWaypoint.DALE_PORT, 30));
        add_control_zone_reflection(RHUDEL, new LOTRControlZone(LOTRWaypoint.RHUN_CAPITAL, 175));
        add_control_zone_reflection(RHUDEL, new LOTRControlZone(LOTRWaypoint.MINAS_TIRITH, 100));
        add_control_zone_reflection(RHUDEL, new LOTRControlZone(LOTRWaypoint.DALE_CITY, 50));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.UMBAR_CITY, 200));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.FERTILE_VALLEY, 150));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.HARNEN_SEA_TOWN, 60));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.HARNEN_RIVER_TOWN, 60));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.DESERT_TOWN, 50));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.SOUTH_DESERT_TOWN, 50));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.GULF_CITY, 150));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.CROSSINGS_OF_HARAD, 75));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.CROSSINGS_OF_POROS, 50));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.MINAS_TIRITH, 50));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(1210.0D, 1340.0D, 75));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.PELARGIR, 75));
        add_control_zone_reflection(NEAR_HARAD, new LOTRControlZone(LOTRWaypoint.LINHIR, 75));
        add_control_zone_reflection(MORWAITH, new LOTRControlZone(LOTRWaypoint.GREAT_PLAINS_SOUTH, 350));
        add_control_zone_reflection(MORWAITH, new LOTRControlZone(LOTRWaypoint.GREAT_PLAINS_WEST, 170));
        add_control_zone_reflection(MORWAITH, new LOTRControlZone(LOTRWaypoint.GREAT_PLAINS_EAST, 200));
        add_control_zone_reflection(MORWAITH, new LOTRControlZone(LOTRWaypoint.GREAT_PLAINS_NORTH, 75));
        add_control_zone_reflection(TAURETHRIM, new LOTRControlZone(LOTRWaypoint.JUNGLE_CITY_CAPITAL, 400));
        add_control_zone_reflection(TAURETHRIM, new LOTRControlZone(LOTRWaypoint.OLD_JUNGLE_RUIN, 75));
        add_control_zone_reflection(HALF_TROLL, new LOTRControlZone(LOTRWaypoint.TROLL_ISLAND, 100));
        add_control_zone_reflection(HALF_TROLL, new LOTRControlZone(LOTRWaypoint.BLOOD_RIVER, 200));
        add_control_zone_reflection(HALF_TROLL, new LOTRControlZone(LOTRWaypoint.SHADOW_POINT, 100));
        add_control_zone_reflection(HALF_TROLL, new LOTRControlZone(LOTRWaypoint.CROSSINGS_OF_POROS, 40));
        add_control_zone_reflection(HALF_TROLL, new LOTRControlZone(LOTRWaypoint.HARADUIN_BRIDGE, 100));

    }
    private static void register_legacy_aliases() {
        add_alias_reflection(DURINS_FOLK, "DWARF");
        add_alias_reflection(LOTHLORIEN, "GALADHRIM");
        add_alias_reflection(ISENGARD, "URUK_HAI");
        add_alias_reflection(RHUDEL, "RHUN");
        add_alias_reflection(MORWAITH, "MOREDAIN");
        add_alias_reflection(TAURETHRIM, "TAUREDAIN");
    }
    private static void register_achievement_categories() {
        set_achievement_category_reflection(HOBBIT, LOTRAchievement.Category.SHIRE);
        set_achievement_category_reflection(BREE, LOTRAchievement.Category.BREE_LAND);
        set_achievement_category_reflection(RANGER_NORTH, LOTRAchievement.Category.ERIADOR);
        set_achievement_category_reflection(BLUE_MOUNTAINS, LOTRAchievement.Category.BLUE_MOUNTAINS);
        set_achievement_category_reflection(HIGH_ELF, LOTRAchievement.Category.LINDON);
        set_achievement_category_reflection(GUNDABAD, LOTRAchievement.Category.ERIADOR);
        set_achievement_category_reflection(ANGMAR, LOTRAchievement.Category.ANGMAR);
        set_achievement_category_reflection(WOOD_ELF, LOTRAchievement.Category.MIRKWOOD);
        set_achievement_category_reflection(DOL_GULDUR, LOTRAchievement.Category.MIRKWOOD);
        set_achievement_category_reflection(DALE, LOTRAchievement.Category.DALE);
        set_achievement_category_reflection(DURINS_FOLK, LOTRAchievement.Category.IRON_HILLS);
        set_achievement_category_reflection(LOTHLORIEN, LOTRAchievement.Category.LOTHLORIEN);
        set_achievement_category_reflection(DUNLAND, LOTRAchievement.Category.DUNLAND);
        set_achievement_category_reflection(ISENGARD, LOTRAchievement.Category.ROHAN);
        set_achievement_category_reflection(FANGORN, LOTRAchievement.Category.FANGORN);
        set_achievement_category_reflection(ROHAN, LOTRAchievement.Category.ROHAN);
        set_achievement_category_reflection(GONDOR, LOTRAchievement.Category.GONDOR);
        set_achievement_category_reflection(MORDOR, LOTRAchievement.Category.MORDOR);
        set_achievement_category_reflection(DORWINION, LOTRAchievement.Category.DORWINION);
        set_achievement_category_reflection(RHUDEL, LOTRAchievement.Category.RHUN);
        set_achievement_category_reflection(NEAR_HARAD, LOTRAchievement.Category.NEAR_HARAD);
        set_achievement_category_reflection(MORWAITH, LOTRAchievement.Category.FAR_HARAD_SAVANNAH);
        set_achievement_category_reflection(TAURETHRIM, LOTRAchievement.Category.FAR_HARAD_JUNGLE);
        set_achievement_category_reflection(HALF_TROLL, LOTRAchievement.Category.PERDOROGWAITH);
    }
    private static void register_achievement_ranks() {
        add_rank_reflection(HOBBIT, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(HOBBIT, 100.0F, "friend", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(HOBBIT, 250.0F, "hayward", false).makeAchievement().makeTitle();
        add_rank_reflection(HOBBIT, 500.0F, "bounder", false).makeAchievement().makeTitle();
        add_rank_reflection(HOBBIT, 1000.0F, "shirriff", false).makeAchievement().makeTitle();
        add_rank_reflection(HOBBIT, 2000.0F, "chief", false).makeAchievement().makeTitle();
        add_rank_reflection(HOBBIT, 3000.0F, "thain", false).makeAchievement().makeTitle();
        add_rank_reflection(BREE, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(BREE, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(BREE, 100.0F, "townsman", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(BREE, 200.0F, "trustee", false).makeAchievement().makeTitle();
        add_rank_reflection(BREE, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(BREE, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(BREE, 2000.0F, "master", false).makeAchievement().makeTitle();
        add_rank_reflection(RANGER_NORTH, 10.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(RANGER_NORTH, 50.0F, "warden", false).makeAchievement().makeTitle();
        add_rank_reflection(RANGER_NORTH, 100.0F, "ranger", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(RANGER_NORTH, 200.0F, "ohtar", false).makeAchievement().makeTitle();
        add_rank_reflection(RANGER_NORTH, 500.0F, "roquen", false).makeAchievement().makeTitle();
        add_rank_reflection(RANGER_NORTH, 1000.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(RANGER_NORTH, 2000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 100.0F, "warden", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(BLUE_MOUNTAINS, 200.0F, "axebearer", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 1500.0F, "noble", false).makeAchievement().makeTitle();
        add_rank_reflection(BLUE_MOUNTAINS, 3000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 100.0F, "warrior", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(HIGH_ELF, 200.0F, "herald", false).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 500.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 1000.0F, "noble", false).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 2000.0F, "commander", false).makeAchievement().makeTitle();
        add_rank_reflection(HIGH_ELF, 3000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(GUNDABAD, 10.0F, "thrall", false).makeAchievement().makeTitle();
        add_rank_reflection(GUNDABAD, 50.0F, "snaga", false).makeAchievement().makeTitle();
        add_rank_reflection(GUNDABAD, 100.0F, "raider", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(GUNDABAD, 200.0F, "ravager", false).makeAchievement().makeTitle();
        add_rank_reflection(GUNDABAD, 500.0F, "scourge", false).makeAchievement().makeTitle();
        add_rank_reflection(GUNDABAD, 1000.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(GUNDABAD, 2000.0F, "chieftain", false).makeAchievement().makeTitle();
        add_rank_reflection(ANGMAR, 10.0F, "thrall", false).makeAchievement().makeTitle();
        add_rank_reflection(ANGMAR, 50.0F, "servant", false).makeAchievement().makeTitle();
        add_rank_reflection(ANGMAR, 100.0F, "kinsman", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(ANGMAR, 200.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(ANGMAR, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(ANGMAR, 1000.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(ANGMAR, 2000.0F, "chieftain", false).makeAchievement().makeTitle();
        add_rank_reflection(WOOD_ELF, 50.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(WOOD_ELF, 100.0F, "friend", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(WOOD_ELF, 200.0F, "guard", false).makeAchievement().makeTitle();
        add_rank_reflection(WOOD_ELF, 500.0F, "herald", false).makeAchievement().makeTitle();
        add_rank_reflection(WOOD_ELF, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(WOOD_ELF, 2000.0F, "noble", false).makeAchievement().makeTitle();
        add_rank_reflection(WOOD_ELF, 3000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(DOL_GULDUR, 10.0F, "thrall", false).makeAchievement().makeTitle();
        add_rank_reflection(DOL_GULDUR, 50.0F, "servant", false).makeAchievement().makeTitle();
        add_rank_reflection(DOL_GULDUR, 100.0F, "brigand", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(DOL_GULDUR, 200.0F, "torchbearer", false).makeAchievement().makeTitle();
        add_rank_reflection(DOL_GULDUR, 500.0F, "despoiler", false).makeAchievement().makeTitle();
        add_rank_reflection(DOL_GULDUR, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(DOL_GULDUR, 2000.0F, "lieutenant", false).makeAchievement().makeTitle();
        add_rank_reflection(DALE, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(DALE, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(DALE, 100.0F, "soldier", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(DALE, 200.0F, "herald", false).makeAchievement().makeTitle();
        add_rank_reflection(DALE, 500.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(DALE, 1000.0F, "marshal", false).makeAchievement().makeTitle();
        add_rank_reflection(DALE, 2000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 100.0F, "oathfriend", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(DURINS_FOLK, 200.0F, "axebearer", false).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 1000.0F, "commander", false).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 1500.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(DURINS_FOLK, 3000.0F, "uzbad", true).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 100.0F, "warden", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(LOTHLORIEN, 200.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 500.0F, "herald", true).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 2000.0F, "noble", false).makeAchievement().makeTitle();
        add_rank_reflection(LOTHLORIEN, 3000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(DUNLAND, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(DUNLAND, 50.0F, "kinsman", false).makeAchievement().makeTitle();
        add_rank_reflection(DUNLAND, 100.0F, "warrior", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(DUNLAND, 200.0F, "bearer", false).makeAchievement().makeTitle();
        add_rank_reflection(DUNLAND, 500.0F, "avenger", false).makeAchievement().makeTitle();
        add_rank_reflection(DUNLAND, 1000.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(DUNLAND, 2000.0F, "chieftain", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 10.0F, "thrall", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 50.0F, "snaga", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 100.0F, "soldier", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(ISENGARD, 200.0F, "treefeller", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 500.0F, "berserker", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 1000.0F, "corporal", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 1500.0F, "hand", false).makeAchievement().makeTitle();
        add_rank_reflection(ISENGARD, 3000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(FANGORN, 10.0F, "newcomer", false).makeAchievement().makeTitle();
        add_rank_reflection(FANGORN, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(FANGORN, 100.0F, "treeherd", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(FANGORN, 250.0F, "master", false).makeAchievement().makeTitle();
        add_rank_reflection(FANGORN, 500.0F, "elder", false).makeAchievement().makeTitle();
        add_rank_reflection(ROHAN, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(ROHAN, 50.0F, "footman", false).makeAchievement().makeTitle();
        add_rank_reflection(ROHAN, 100.0F, "atarms", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(ROHAN, 250.0F, "rider", false).makeAchievement().makeTitle();
        add_rank_reflection(ROHAN, 500.0F, "esquire", false).makeAchievement().makeTitle();
        add_rank_reflection(ROHAN, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(ROHAN, 2000.0F, "marshal", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 100.0F, "atarms", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(GONDOR, 200.0F, "soldier", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 500.0F, "knight", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 1000.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 1500.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(GONDOR, 3000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 10.0F, "thrall", false).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 50.0F, "snaga", false).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 100.0F, "brigand", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(MORDOR, 200.0F, "slavedriver", false).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 500.0F, "despoiler", false).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 1000.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 1500.0F, "lieutenant", false).makeAchievement().makeTitle();
        add_rank_reflection(MORDOR, 3000.0F, "commander", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 50.0F, "vinehand", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 100.0F, "merchant", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(DORWINION, 200.0F, "guard", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 500.0F, "captain", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 1000.0F, "master", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 1500.0F, "chief", false).makeAchievement().makeTitle();
        add_rank_reflection(DORWINION, 3000.0F, "lord", true).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 10.0F, "bondsman", false).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 50.0F, "levyman", false).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 100.0F, "clansman", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(RHUDEL, 200.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 1000.0F, "golden", false).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 1500.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(RHUDEL, 3000.0F, "chieftain", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 100.0F, "kinsman", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(NEAR_HARAD, 200.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 1000.0F, "serpentguard", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 1500.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(NEAR_HARAD, 3000.0F, "prince", true).makeAchievement().makeTitle();
        add_rank_reflection(MORWAITH, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(MORWAITH, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(MORWAITH, 100.0F, "kinsman", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(MORWAITH, 250.0F, "hunter", false).makeAchievement().makeTitle();
        add_rank_reflection(MORWAITH, 500.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(MORWAITH, 1000.0F, "chief", false).makeAchievement().makeTitle();
        add_rank_reflection(MORWAITH, 3000.0F, "greatchief", false).makeAchievement().makeTitle();
        add_rank_reflection(TAURETHRIM, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(TAURETHRIM, 50.0F, "friend", false).makeAchievement().makeTitle();
        add_rank_reflection(TAURETHRIM, 100.0F, "forestman", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(TAURETHRIM, 200.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(TAURETHRIM, 500.0F, "champion", false).makeAchievement().makeTitle();
        add_rank_reflection(TAURETHRIM, 1000.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(TAURETHRIM, 3000.0F, "splendour", false).makeAchievement().makeTitle();
        add_rank_reflection(HALF_TROLL, 10.0F, "guest", false).makeAchievement().makeTitle();
        add_rank_reflection(HALF_TROLL, 50.0F, "scavenger", false).makeAchievement().makeTitle();
        add_rank_reflection(HALF_TROLL, 100.0F, "kin", false).makeAchievement().makeTitle().setPledgeRank();
        add_rank_reflection(HALF_TROLL, 200.0F, "warrior", false).makeAchievement().makeTitle();
        add_rank_reflection(HALF_TROLL, 500.0F, "raider", false).makeAchievement().makeTitle();
        add_rank_reflection(HALF_TROLL, 1000.0F, "warlord", false).makeAchievement().makeTitle();
        add_rank_reflection(HALF_TROLL, 2000.0F, "chieftain", false).makeAchievement().makeTitle();
    }

    private static LOTRFactionRank add_rank_reflection(LOTRFaction faction, float alignment, String name, boolean gendered) {
        LOTRFactionRank rank = new LOTRFactionRank(faction, alignment, name, gendered);
        List<LOTRFactionRank> ranksSortedDescending;
        try {
            Field ranksSortedField = faction.getClass().getDeclaredField("ranksSortedDescending");
            ranksSortedField.setAccessible(true);
            ranksSortedDescending = (List)ranksSortedField.get(faction);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        ranksSortedDescending.add(rank);
        Collections.sort(ranksSortedDescending);
        return rank;
    }

    private static void add_alias_reflection(LOTRFaction faction, String alias) {
        List<String> legacyAliases;
        try {
            Field legacyAliasesField = faction.getClass().getDeclaredField("legacyAliases");
            legacyAliasesField.setAccessible(true);
            legacyAliases = (List)legacyAliasesField.get(faction);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        legacyAliases.add(alias);
    }

    private static void set_achievement_category_reflection(LOTRFaction faction, LOTRAchievement.Category category) {
        try {
            Field achieveCategory = faction.getClass().getDeclaredField("achieveCategory");
            achieveCategory.setAccessible(true);
            achieveCategory.set(faction, category);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
    }

    private static void add_control_zone_reflection(LOTRFaction faction, LOTRControlZone zone) {
        List<LOTRControlZone> controlZones;
        try {
            Field controlZonesField = faction.getClass().getDeclaredField("controlZones");
            controlZonesField.setAccessible(true);
            controlZones = (List)controlZonesField.get(faction);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        controlZones.add(zone);
    }
}
