package net.glowstone.constants;

import org.apache.commons.lang3.Validate;
import org.bukkit.Achievement;

import static org.bukkit.Achievement.*;

/**
 * Name mappings for Bukkit Achievements.
 */
public final class GlowAchievement {

    private GlowAchievement() {}

    private static final String[] names = new String[Achievement.values().length];
    private static final String[] fancyNames = new String[Achievement.values().length];

    /**
     * Get the achievement name for a specified Achievement.
     * @param achievement the Achievement.
     * @return the achievement name.
     */
    public static String getName(Achievement achievement) {
        Validate.notNull(achievement, "Achievement cannot be null");
        return names[achievement.ordinal()];
    }

    public static String getFancyName(Achievement achievement) {
        Validate.notNull(achievement, "Achievement cannot be null");
        return fancyNames[achievement.ordinal()];
    }

    private static void set(Achievement achievement, String key) {
        names[achievement.ordinal()] = "achievement." + key;
    }

    private static void set(Achievement achievement, String key, String fancyName) {
        names[achievement.ordinal()] = "achievement." + key;
        fancyNames[achievement.ordinal()] = fancyName;
    }

    static {
        set(OPEN_INVENTORY, "openInventory", "Taking Inventory");
        set(MINE_WOOD, "mineWood", "Getting Wood");
        set(BUILD_WORKBENCH, "buildWorkBench", "Benchmarking");
        set(BUILD_PICKAXE, "buildPickaxe", "Time to Mine!");
        set(BUILD_FURNACE, "buildFurnace", "Hot Topic!");
        set(ACQUIRE_IRON, "acquireIron", "Acquire Hardware");
        set(BUILD_HOE, "buildHoe", "Time to Farm!");
        set(MAKE_BREAD, "makeBread", "Bake Bread");
        set(BAKE_CAKE, "bakeCake", "The Lie");
        set(BUILD_BETTER_PICKAXE, "buildBetterPickaxe", "Getting an Upgrade");
        set(COOK_FISH, "cookFish", "Delicious Fish");
        set(ON_A_RAIL, "onARail", "On a Rail");
        set(BUILD_SWORD, "buildSword", "Time to Strike!");
        set(KILL_ENEMY, "killEnemy", "Monster Hunter");
        set(KILL_COW, "killCow", "Cow Tipper");
        set(FLY_PIG, "flyPig", "When Pigs Fly");
        set(SNIPE_SKELETON, "snipeSkeleton", "Sniper Duel");
        set(GET_DIAMONDS, "diamonds", "DIAMONDS!");
        set(DIAMONDS_TO_YOU, "diamondsToYou", "Diamonds to you!");
        set(NETHER_PORTAL, "portal", "");
        set(GHAST_RETURN, "ghast", "Return to Sender");
        set(GET_BLAZE_ROD, "blazeRod", "Into Fire");
        set(BREW_POTION, "potion", "Local Brewery");
        set(END_PORTAL, "theEnd", "The End?");
        set(THE_END, "theEnd2", "The End.");
        set(ENCHANTMENTS, "enchantments", "Enchanter");
        set(OVERKILL, "overkill", "Overkill");
        set(BOOKCASE, "bookcase", "Librarian");
        set(BREED_COW, "breedCow", "Repopulation");
        set(SPAWN_WITHER, "spawnWither", "");
        set(KILL_WITHER, "killWither", "The Beginning.");
        set(FULL_BEACON, "fullBeacon", "Beaconator");
        set(EXPLORE_ALL_BIOMES, "exploreAllBiomes", "Adventuring Time");
        set(SPAWN_WITHER, "spawnWither");
        set(KILL_WITHER, "killWither", "The Beginning.");
        set(FULL_BEACON, "fullBeacon", "Beaconator");
        set(BREED_COW, "breedCow", "Repopulation");
        set(DIAMONDS_TO_YOU, "diamondsToYou", "Diamonds to you!");
        set(OVERPOWERED, "overpowered", "OVERPOWERED!");
    }

}

@@ -1617,21 +1617,20 @@
 ot Topic
-!
 %22);%0A
+
         
@@ -2345,75 +2345,8 @@
 %22);%0A
-        set(DIAMONDS_TO_YOU, %22diamondsToYou%22, %22Diamonds to you!%22);%0A
     
@@ -2375,24 +2375,44 @@
  %22portal%22, %22
+We Need to Go Deeper
 %22);%0A        
@@ -2812,218 +2812,8 @@
 %22);%0A
-        set(BREED_COW, %22breedCow%22, %22Repopulation%22);%0A        set(SPAWN_WITHER, %22spawnWither%22, %22%22);%0A        set(KILL_WITHER, %22killWither%22, %22The Beginning.%22);%0A        set(FULL_BEACON, %22fullBeacon%22, %22Beaconator%22);%0A
     
@@ -2920,16 +2920,34 @@
 nWither%22
+, %22The Beginning?%22
 );%0A     
@@ -3218,19 +3218,18 @@
 , %22O
-VERPOWERED!
+verpowered
 %22);%0A

Complete GlowAchievement fancy names