@Override public void onEnable() { if (loaded) { MessageSender.getInstance().info(ChatColor.RED + "Plugin is already enabled"); return; } plugin = this; Locale.setDefault(Locale.ENGLISH); // avoid needless complications PluginManager pm = getServer().getPluginManager(); FurnaceData.init(); // dummy caller BrewingStandData.init(); Furnaces.load(); // load saved furnaces... BrewingStands.load(); events = new Events(); recipes = new Recipes(); setupVault(pm); Vanilla.init(); // get initial recipes... Args.init(); // dummy method to avoid errors on 'reload' with updating ArgBuilder.init(); flagLoader = new FlagLoader(); // wait for all plugins to load then enable this new BukkitRunnable() { public void run() { onEnablePost(); } }.runTask(this); }
@Test public void onRecipeParse() { File file = new File("src/test/resources/recipes/flagModMoney/"); RecipeProcessor.reload(null, true, file.getPath(), workDir.getPath()); Map<BaseRecipe, RMCRecipeInfo> queued = RecipeProcessor.getRegistrator().getQueuedRecipes(); assertEquals(6, queued.size()); for (Map.Entry<BaseRecipe, RMCRecipeInfo> entry : queued.entrySet()) { CraftRecipe recipe = (CraftRecipe) entry.getKey(); Args a = ArgBuilder.create().recipe(recipe).player(testUUID).build(); ItemResult result = recipe.getResult(a); FlagModMoney flag = (FlagModMoney) result.getFlag(FlagType.MOD_MONEY); Material resultType = result.getType(); if (resultType == Material.DIRT) { assertEquals(.5, flag.getAmount(), .001); assertEquals('+', flag.getModifier()); } else if (resultType == Material.STONE_SWORD) { assertEquals(2.5, flag.getAmount(), .001); assertEquals('-', flag.getModifier()); assertEquals("<red>You lost {money}!", flag.getFailMessage()); } else if (resultType == Material.IRON_SWORD) { assertEquals(0, flag.getAmount(), .001); assertEquals('=', flag.getModifier()); assertEquals("<red>You lost all your money!", flag.getFailMessage()); } else if (resultType == Material.GOLD_SWORD) { assertEquals(2.5, flag.getAmount(), .001); assertEquals('-', flag.getModifier()); } } }