@Test public void jungleWoodPlanksCanCreateCraftingTableAndJungleWoodStairs() { Tree planks = new Tree(Material.WOOD); planks.setSpecies(TreeSpecies.JUNGLE); MaterialRecipes materialRecipes = recipeSnapshot.getMaterialRecipes(planks); boolean foundWorkBench = false; boolean foundJungleWoodPlanks = false; for (Recipe recipe : materialRecipes.getUsages()) { ItemStack result = recipe.getResult(); if (Material.WORKBENCH.equals(result.getType())) { foundWorkBench = true; } else if (Material.JUNGLE_WOOD_STAIRS.equals(result.getType())) { foundJungleWoodPlanks = true; } } assertEqual(true, foundWorkBench); assertEqual(true, foundJungleWoodPlanks); }
/** * Finds a jungle log around this crop block. * @param crop The block to check around. * @return The rotation for which a jungle log was found, null otherwise. */ private BlockRotation findJungleLog(BlockLocation crop) { for (BlockRotation r : BlockRotation.values()) { Block block = crop.getRelative(r.getYawFace()).getBlock(); if (block.getType() == Material.LOG) { BlockState state = block.getState(); try { Tree tree = (Tree) state.getData(); if (tree.getSpecies() == TreeSpecies.JUNGLE) { return r; } } catch (ClassCastException e) { } } } return null; }
/** * Checks for double drops * * @param blockState Block being broken */ protected static void checkForDoubleDrop(BlockState blockState) { if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) { Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); } else { //TODO Remove this workaround when casting to Tree works again TreeSpecies species = TreeSpecies.GENERIC; if (blockState.getData() instanceof Tree) { species = ((Tree) blockState.getData()).getSpecies(); } if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) { Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); } } }
public static TreeSpecies getTreeSpecies(EntityBoat.EnumBoatType boatType) { switch (boatType) { case SPRUCE: return TreeSpecies.REDWOOD; case BIRCH: return TreeSpecies.BIRCH; case JUNGLE: return TreeSpecies.JUNGLE; case ACACIA: return TreeSpecies.ACACIA; case DARK_OAK: return TreeSpecies.DARK_OAK; case OAK: default: return TreeSpecies.GENERIC; } }
public static EntityBoat.EnumBoatType getBoatType(TreeSpecies species) { switch (species) { case REDWOOD: return EntityBoat.EnumBoatType.SPRUCE; case BIRCH: return EntityBoat.EnumBoatType.BIRCH; case JUNGLE: return EntityBoat.EnumBoatType.JUNGLE; case ACACIA: return EntityBoat.EnumBoatType.ACACIA; case DARK_OAK: return EntityBoat.EnumBoatType.DARK_OAK; case GENERIC: default: return EntityBoat.EnumBoatType.OAK; } }
/** * Get the material in the flower pot * * @return material MaterialData for the block currently in the flower pot * or null if empty */ public MaterialData getContents() { switch (getData()) { case 1: return new MaterialData(Material.RED_ROSE); case 2: return new MaterialData(Material.YELLOW_FLOWER); case 3: return new Tree(TreeSpecies.GENERIC); case 4: return new Tree(TreeSpecies.REDWOOD); case 5: return new Tree(TreeSpecies.BIRCH); case 6: return new Tree(TreeSpecies.JUNGLE); case 7: return new MaterialData(Material.RED_MUSHROOM); case 8: return new MaterialData(Material.BROWN_MUSHROOM); case 9: return new MaterialData(Material.CACTUS); case 10: return new MaterialData(Material.DEAD_BUSH); case 11: return new LongGrass(GrassSpecies.FERN_LIKE); default: return null; } }
/** * Retrieves the experience reward from a log * * @param blockState Log being broken * @param experienceGainMethod How the log is being broken * @return Amount of experience */ protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) { // Mushrooms aren't trees so we could never get species data from them switch (blockState.getType()) { case HUGE_MUSHROOM_1: return ExperienceConfig.getInstance().getWoodcuttingXPHugeBrownMushroom(); case HUGE_MUSHROOM_2: return ExperienceConfig.getInstance().getWoodcuttingXPHugeRedMushroom(); default: break; } if (mcMMO.getModManager().isCustomLog(blockState)) { return mcMMO.getModManager().getBlock(blockState).getXpGain(); } //TODO Remove this workaround when casting to Tree works again TreeSpecies species = TreeSpecies.GENERIC; if (blockState.getData() instanceof Tree) { species = ((Tree) blockState.getData()).getSpecies(); } int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species); if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) { xp *= 0.5; } return xp; }
/** * Get the material in the flower pot * * @return material MaterialData for the block currently in the flower pot or null if empty */ public MaterialData getContents() { switch (getData()) { case 1: return new MaterialData(Material.RED_ROSE); case 2: return new MaterialData(Material.YELLOW_FLOWER); case 3: return new Tree(TreeSpecies.GENERIC); case 4: return new Tree(TreeSpecies.REDWOOD); case 5: return new Tree(TreeSpecies.BIRCH); case 6: return new Tree(TreeSpecies.JUNGLE); case 7: return new MaterialData(Material.RED_MUSHROOM); case 8: return new MaterialData(Material.BROWN_MUSHROOM); case 9: return new MaterialData(Material.CACTUS); case 10: return new MaterialData(Material.DEAD_BUSH); case 11: return new LongGrass(GrassSpecies.FERN_LIKE); default: return null; } }
@Override public void addCustomRecipes(CustomRecipeManager crm) { for (TreeSpecies species : TreeSpecies.values()) { crm.addCustomRecipe(new SimpleCustomRecipe(this, STBUtil.makeLog(species).toItemStack(1), STBUtil.makePlank(species).toItemStack(6), 60)); } crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.WOOD_DOOR), new ItemStack(Material.WOOD, 6), 40)); crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.TRAP_DOOR), new ItemStack(Material.WOOD, 3), 40)); crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.WOOD_PLATE), new ItemStack(Material.WOOD, 2), 40)); crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.WOOD_BUTTON), new ItemStack(Material.WOOD, 1), 40)); crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.WORKBENCH), new ItemStack(Material.WOOD, 4), 40)); crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.SIGN), new ItemStack(Material.WOOD, 2), 40)); crm.addCustomRecipe(new SimpleCustomRecipe(this, new ItemStack(Material.CHEST), new ItemStack(Material.WOOD, 8), 40)); }
@SuppressWarnings("deprecation") public static ItemStack wood(TreeSpecies type, String name, String... lores) { return setNameAndLores(new ItemStack(Material.WOOD, 1, type.getData()), name, lores); }
public Leaves(TreeSpecies species) { this(); setSpecies(species); }
public Tree(TreeSpecies species) { this(); setSpecies(species); }
public Tree(TreeSpecies species, BlockFace dir) { this(); setSpecies(species); setDirection(dir); }
public WoodenStep(TreeSpecies species) { this(); setSpecies(species); }
public WoodenStep(TreeSpecies species, boolean inv) { this(); setSpecies(species); setInverted(inv); }
public LumberjackSkill() { File configFile = new File(QuestManagerPlugin.questManagerPlugin.getDataFolder(), QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getSkillPath() + CONFIG_NAME); YamlConfiguration config = createConfig(configFile); if (!config.getBoolean("enabled", true)) { return; } this.startingLevel = config.getInt("startingLevel", 0); this.timingBase = config.getDouble("timingBase", .3); this.timingRate = config.getDouble("timingRate", .002); this.baseDelay = config.getDouble("baseTime", 1.5); this.delayDeviation = config.getDouble("delayDeviation", .25); this.baseHits = config.getInt("baseHits", 5); this.hitRate = config.getDouble("hitRate", .1); this.hitBonus = config.getDouble("hitBonus", .005); this.extraWoodPerLevel = config.getDouble("extraWoodPerLevel", 0.05); this.maxDifficultyRange = config.getInt("maxDifficultyRange", 20); this.qualityRate = config.getDouble("qualityRate", 0.01); this.millingEnabled = config.getBoolean("millingEnabled", true); this.millPenalty = config.getDouble("millPenalty", 0.05); this.restrictLower = config.getBoolean("restrictLower", false); this.activeSessions = new HashMap<>(); this.lastLocations = new HashMap<>(); this.treeRecords = new LinkedList<>(); if (!config.contains("trees")) { QuestManagerPlugin.logger.warning("Didn't find any tree table" + "for LumberjackSkill even though it's enabled!"); return; } else { /* * trees: * Elm: * difficulty: 40 * ... * Witchwood: * difficulty: 85 * ... */ ConfigurationSection sex = config.getConfigurationSection("trees"), subsex; RegionManager rManager = QuestManagerPlugin.questManagerPlugin.getEnemyManager(); for (String key : sex.getKeys(false)) { if (key.startsWith("==")) { continue; } subsex = sex.getConfigurationSection(key); try { Wood wood = new Wood(Material.LOG, TreeSpecies.valueOf(subsex.getString("treeType").toUpperCase())); treeRecords.add(new TreeRecord( subsex.getInt("difficulty"), key, subsex.getItemStack("reward"), subsex.getInt("woodCount"), wood, rManager.getRegion(subsex.contains("region") ? (subsex.get("region") == null ? null : ((LocationState) subsex.get("region")).getLocation()) : null) )); } catch (Exception e) { e.printStackTrace(); QuestManagerPlugin.logger.warning("Skipping that one! ^"); } } } LumberjackSequence.setSkillLink(this); Bukkit.getPluginManager().registerEvents(this, QuestManagerPlugin.questManagerPlugin); }
private YamlConfiguration createConfig(File configFile) { if (!configFile.exists()) { YamlWriter writer = new YamlWriter(); writer.addLine("enabled", true, Lists.newArrayList("Whether or not this skill is allowed to be used.", "true | false")) .addLine("startingLevel", 0, Lists.newArrayList("The level given to players who don't have this skill yet", "[int]")) .addLine("timingBase", .3, Lists.newArrayList("Base time a player can be early or late", "and still count as having hit", "[double] number of seconds")) .addLine("timingRate", .002, Lists.newArrayList("How many fewer seconds per difficulty", "that a player can hit and have it count", "[double] number of seconds")) .addLine("baseDelay", 1.5, Lists.newArrayList("Average time it takes to wind up a good", "swing. Shorter times are harder", "[double] number of seconds")) .addLine("delayDeviation", .25, Lists.newArrayList("Standard deviation on time for a", "full swing. Google [Std Deviation] for info", "[double] number of seconds")) .addLine("baseHits", 5, Lists.newArrayList("Base number of hits a player must make", "to fell the tree and get the wood.", "Larger numbers mean longer cutting times", "[int] larger than 0")) .addLine("hitRate", 0.1, Lists.newArrayList("Hits added to total hit count per", "difficulty of the wood", "[double] number of hits")) .addLine("hitBonus", .25, Lists.newArrayList("How much of the hits to subtract per", "skill level", "[double] .01 is 1%")) .addLine("extraWoodPerLevel", 0.05, Lists.newArrayList("Extra pieces of wood given to a player", "per level over difficulty level", "[double] 1.0 is a whole extra log")) .addLine("maxDifficultyRange", 20, Lists.newArrayList("Biggest gap between player and ore difficulty", "that will be allowed through RANDOM ore", "algorithm", "[int] larger than 0")) .addLine("qualityRate", 0.01, Lists.newArrayList("Bonus to quality per mining skill level", "[double] .01 is 1%")) .addLine("millingEnabled", true, Lists.newArrayList("Can players use logs on crafting tables", "and get a single item stack of average quality", "[true|false]")) .addLine("millPenalty", 0.05, Lists.newArrayList("If milling two items, how much of the sum quality", "is lost in the process?", "[double] .01 is 1%")) .addLine("restrictLower", false, Lists.newArrayList("Prevent players from getting wood with level too much lower than theirs")); Map<String, Map<String, Object>> map = new HashMap<>(); Map<String, Object> sub = new HashMap<>(); sub.put("difficulty", 10); ItemStack item = (new Wood(Material.LOG, TreeSpecies.GENERIC)).toItemStack(); ItemMeta meta = item.getItemMeta(); meta.setDisplayName("Oak Wood"); meta.setLore(Lists.newArrayList("Common wood of common", "quality. Very useful")); item.setItemMeta(meta); sub.put("reward", item); sub.put("treeType", TreeSpecies.GENERIC.name()); sub.put("woodCount", 2); sub.put("region", null); map.put("Oak", sub); sub = new HashMap<>(); sub.put("difficulty", 15); item = (new Wood(Material.LOG, TreeSpecies.GENERIC)).toItemStack(); meta = item.getItemMeta(); meta.setDisplayName("WarmOak Wood"); meta.setLore(Lists.newArrayList("Specialty oak prized over", "regular oak for it's color")); item.setItemMeta(meta); sub.put("reward", item); sub.put("treeType", TreeSpecies.GENERIC.name()); sub.put("woodCount", 1); sub.put("region", new Location(Bukkit.getWorld("QuestWorld"), -400, 55, -855)); map.put("WarmOak", sub); sub = new HashMap<>(); sub.put("difficulty", 20); item = (new Wood(Material.LOG, TreeSpecies.BIRCH)).toItemStack(); meta = item.getItemMeta(); meta.setDisplayName("Birch Wood"); meta.setLore(Lists.newArrayList("Light, eyed wood with little", "strength. It's value comes from", "it's color")); item.setItemMeta(meta); sub.put("reward", item); sub.put("treeType", TreeSpecies.BIRCH.name()); sub.put("woodCount", 2); sub.put("region", null); map.put("Birch", sub); writer.addLine("trees", map, Lists.newArrayList("List of wood types and trees/regions", "they can be found at. If region is", "null, only the wood type", "and player level is taken into account.", "Plan difficulties carefully, as players that are", "at a level with no wood in range (maxDifficultyRange)", "are stuck forever!", "name: {difficulty: [int], reward: [itemstack], woodCount: [int], treeType: [TreeSpecies], region: [null or Location]}")); try { writer.save(configFile); } catch (Exception e) { e.printStackTrace(); } return writer.buildYaml(); } YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); return config; }