From 4669e3e54dd177e5c6d4c243f5b7a37bdf6ef1e1 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 3 Jan 2019 03:42:11 -0800 Subject: [PATCH] Starting to convert existing subskills to be JSON friendly So far only a few have been converted --- Changelog.txt | 14 ++++--- .../gmail/nossr50/config/AdvancedConfig.java | 11 ++---- .../nossr50/datatypes/skills/SubSkill.java | 38 +++++++++++++------ .../datatypes/skills/SubSkillFlags.java | 11 ++++++ .../skills/archery/ArcheryManager.java | 11 +++++- .../util/SkillTextComponentFactory.java | 2 + src/main/resources/advanced.yml | 34 ++++++++++++++--- 7 files changed, 90 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillFlags.java diff --git a/Changelog.txt b/Changelog.txt index b854822f8..4f57087e7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,7 +9,7 @@ Key: Version 2.1.0 + Added JSON support to Woodcutting command - + Added config setting to enable or disable classic mcMMO mode + + Added config setting to enable or disable classic mcMMO skill scaling + (Config) Added rank settings for the new Woodcutting skill + (Config) Added configurable parameters for the new Tree Feller + (Config) Added classic toggle for Tree Feller @@ -17,8 +17,12 @@ Version 2.1.0 + (Commands) Added toggle command /mcchatspy + (Permissions) Added permission node mcmmo.commands.mcchatspy & mcmmo.commands.mcchatspy.others + (Permissions) Added permission nodes for Harvest Lumber, Splinter, Nature's Bounty, and Bark Surgeon - ! Woodcutting's Double Drop subskill is now named Harvest Lumber - ! Replaced the old Double Drop permission node for woodcutting with a new Harvest Lumber permission node + - (Config) Removed Skills.Archery.SkillShot.IncreaseLevel & Skills.Archery.SkillShot.IncreasePercentage + ! (Skills) Woodcutting's Double Drop subskill is now named Harvest Lumber + ! (Skills) Archery's Skill Shot now uses a rank system + ! (Config) Archery's Skill Shot now uses IncreaseDamage for its damage bonus + ! (Config) Archery's Skill shot now uses IncreaseDamageMaxBonus instead of MaxDamage + ! (Permissions) Replaced the old Double Drop permission node for woodcutting with a new Harvest Lumber permission node ! (Locale) Super Abilities no longer have (ABILITY) in their Skill.Effect strings ! (API) mcMMO is now built against Spigot-API instead of Bukkit ! (API) SkillType is now PrimarySkill @@ -28,8 +32,8 @@ Version 2.1.0 ! (API) SecondarySkill ENUM is being updated to have the parent skill as a prefix and a getter method for grabbing the parent skill ! (API) GREEN_THUMB_PLANT & GREEN_THUMB_BLOCK are replaced by GREEN_THUMB ! Skill Super Powers (Tree Feller, etc...) will now require level 10+ to use - ! mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (I'll be explaining this in a write-up) - ! Refactored some unreadable code relating to SecondaryAbility activation in SkillUtils + ! (Skills) mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (for existing mcMMO installs this is opt-in and off by default) + ! (Code) Refactored some unreadable code relating to SecondaryAbility activation in SkillUtils Version 2.0.0 diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index efdf198c2..4fb59e244 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -118,16 +118,13 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { } /* ARCHERY */ - if (getSkillShotIncreaseLevel() < 1) { - reason.add("Skills.Archery.SkillShot.IncreaseLevel should be at least 1!"); - } if (getSkillShotIncreasePercentage() <= 0) { - reason.add("Skills.Archery.SkillShot.IncreasePercentage should be greater than 0!"); + reason.add("Skills.Archery.SkillShot.IncreaseDamage should be greater than 0!"); } if (getSkillShotBonusMax() < 0) { - reason.add("Skills.Archery.SkillShot.MaxBonus should be at least 0!"); + reason.add("Skills.Archery.SkillShot.IncreaseDamageMaxBonus should be at least 0!"); } if (getMaxChance(SubSkill.ARCHERY_DAZE) < 1) { @@ -739,8 +736,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { /* ARCHERY */ public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot.IncreaseLevel", 50); } - public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot.IncreasePercentage", 0.1D); } - public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); } + public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot.IncreaseDamage", 10.0D); } + public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.IncreaseDamageMaxBonus", 200.0D); } public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); } public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkill.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkill.java index f709f15ef..b7d08a82f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkill.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkill.java @@ -2,23 +2,27 @@ package com.gmail.nossr50.datatypes.skills; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.StringUtils; +import static com.gmail.nossr50.datatypes.skills.SubSkillFlags.ACTIVE; +import static com.gmail.nossr50.datatypes.skills.SubSkillFlags.SUPERABILITY; +import static com.gmail.nossr50.datatypes.skills.SubSkillFlags.RNG; + public enum SubSkill { /* !! Warning -- Do not let subskills share a name with any existing PrimarySkill as it will clash with the static import !! */ /* ACROBATICS */ - ACROBATICS_DODGE, - ACROBATICS_GRACEFUL_ROLL, - ACROBATICS_ROLL, + ACROBATICS_DODGE(0, RNG), + ACROBATICS_GRACEFUL_ROLL(0, ACTIVE | RNG), + ACROBATICS_ROLL(0, RNG), /* ALCHEMY */ ALCHEMY_CATALYSIS, - ALCHEMY_CONCOCTIONS, + ALCHEMY_CONCOCTIONS(8), /* ARCHERY */ ARCHERY_DAZE, ARCHERY_RETRIEVE, - ARCHERY_SKILL_SHOT, + ARCHERY_SKILL_SHOT(20), /* Axes */ AXES_ARMOR_IMPACT, @@ -85,33 +89,43 @@ public enum SubSkill { UNARMED_IRON_GRIP, /* Woodcutting */ - WOODCUTTING_TREE_FELLER(5), + WOODCUTTING_TREE_FELLER(5, ACTIVE | SUPERABILITY), WOODCUTTING_LEAF_BLOWER(3), - WOODCUTTING_BARK_SURGEON(3), + WOODCUTTING_BARK_SURGEON(3, ACTIVE), WOODCUTTING_NATURES_BOUNTY(3), WOODCUTTING_SPLINTER(3), - WOODCUTTING_HARVEST_LUMBER(3); + WOODCUTTING_HARVEST_LUMBER(3, RNG); private final int numRanks; + private final int flags; /** * If our SubSkill has more than 1 rank define it * @param numRanks The number of ranks our SubSkill has */ + SubSkill(int numRanks, int flags) + { + this.numRanks = numRanks; + this.flags = flags; + } + SubSkill(int numRanks) { this.numRanks = numRanks; + this.flags = 0x00; } - /** - * SubSkills will default to having 0 ranks if not defined - */ SubSkill() { this.numRanks = 0; + this.flags = 0x00; } - + /** + * Get the bit flags for this subskill + * @return The bit flags for this subskill + */ + public final int getFlags() { return flags; } public int getNumRanks() { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillFlags.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillFlags.java new file mode 100644 index 000000000..e5c90c7c6 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillFlags.java @@ -0,0 +1,11 @@ +package com.gmail.nossr50.datatypes.skills; + +public class SubSkillFlags { + /* + * Bitwise Flags + * These are so I can establish properties of each subskill quite easily + */ + public static final byte ACTIVE = 0x01; //Active subskills are ones that aren't passive + public static final byte SUPERABILITY = 0x02; //If the subskill is a super ability + public static final byte RNG = 0x04; //If the subskill makes use of RNG +} diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index ea8ffa112..450b6c5d3 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.skills.archery; import com.gmail.nossr50.datatypes.skills.SubSkill; +import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SubSkillActivationType; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -101,8 +102,14 @@ public class ArcheryManager extends SkillManager { return damage; } - double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage); - + /* + * Archery + * Skill Shot + * + * Every rank we increase Skill Shot's bonus damage % by the IncreaseDamage percentage value from advanced.yml + * Divide end result by 100.0D to get proper scale + */ + double damageBonusPercent = (Math.min(((RankUtils.getRank(getPlayer(), SubSkill.ARCHERY_SKILL_SHOT)) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage) / 100.0D); return Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage); } } diff --git a/src/main/java/com/gmail/nossr50/util/SkillTextComponentFactory.java b/src/main/java/com/gmail/nossr50/util/SkillTextComponentFactory.java index f35d91d2e..c7291d30b 100644 --- a/src/main/java/com/gmail/nossr50/util/SkillTextComponentFactory.java +++ b/src/main/java/com/gmail/nossr50/util/SkillTextComponentFactory.java @@ -81,4 +81,6 @@ public class SkillTextComponentFactory { subSkillHoverComponents.put(subSkill, newComponents); return subSkillHoverComponents.get(subSkill); } + + } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 70b767e7f..410d8adb0 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -76,12 +76,36 @@ Skills: ### Archery: SkillShot: - # IncreaseLevel: Every the skillshot bonus will go up by - # IncreasePercentage: This is a percentage value, 0.1 = 10% + Rank_Levels: + Rank_1: 5 + Rank_2: 10 + Rank_3: 15 + Rank_4: 20 + Rank_5: 25 + Rank_6: 30 + Rank_7: 35 + Rank_8: 40 + Rank_9: 45 + Rank_10: 50 + Rank_11: 55 + Rank_12: 60 + Rank_13: 65 + Rank_14: 70 + Rank_15: 75 + Rank_16: 80 + Rank_17: 85 + Rank_18: 90 + Rank_19: 95 + Rank_20: 100 + # IncreaseDamage: Every rank of the skill will add this much additional damage in percentage form, rank 1 = 10% bonus, rank 20 = 200% bonus (with default settings) + # IncreaseDamage is a percentage + IncreaseDamage: 10.0 + # IncreaseDamageMax: When the has been reached, the bonus percentage will not go up anymore. 200.0 = 200% + IncreaseDamageMaxBonus: 200.0 + # --OLD SYSTEM -- IncreaseLevel: 5 + # --OLD SYSTEM -- IncreasePercentage: 0.1 # MaxBonus: When the has been reached, the bonus percentage will not go up anymore. 2.0 = 200% - IncreaseLevel: 5 - IncreasePercentage: 0.1 - MaxBonus: 2.0 + # --OLD SYSTEM -- MaxBonus: 2.0 MaxDamage: 9.0 Daze: