Not much work was done today because of testing & research

The real work begins soon
This commit is contained in:
nossr50 2018-12-28 06:29:08 -08:00
parent 55a4238030
commit a316bb7bd2
12 changed files with 210 additions and 62 deletions

View File

@ -36,7 +36,7 @@ public class WoodcuttingCommand extends SkillCommand {
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS, isLucky); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.WOODCUTTING_HARVEST, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
@ -45,8 +45,8 @@ public class WoodcuttingCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canTreeFell = Permissions.treeFeller(player); canTreeFell = Permissions.treeFeller(player);
canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled(); canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.WOODCUTTING_HARVEST) && !skill.getDoubleDropsDisabled();
canLeafBlow = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.LEAF_BLOWER); canLeafBlow = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.WOODCUTTING_LEAF_BLOWER);
} }
@Override @Override

View File

@ -654,11 +654,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
reason.add("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!"); reason.add("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
} }
if (getMaxChance(SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) < 1) { if (getMaxChance(SecondaryAbility.WOODCUTTING_HARVEST) < 1) {
reason.add("Skills.Woodcutting.DoubleDrops.ChanceMax should be at least 1!"); reason.add("Skills.Woodcutting.DoubleDrops.ChanceMax should be at least 1!");
} }
if (getMaxBonusLevel(SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) < 1) { if (getMaxBonusLevel(SecondaryAbility.WOODCUTTING_HARVEST) < 1) {
reason.add("Skills.Woodcutting.DoubleDrops.MaxBonusLevel should be at least 1!"); reason.add("Skills.Woodcutting.DoubleDrops.MaxBonusLevel should be at least 1!");
} }

View File

@ -1,86 +1,102 @@
package com.gmail.nossr50.datatypes.skills; package com.gmail.nossr50.datatypes.skills;
import static com.gmail.nossr50.datatypes.skills.SkillType.*;
public enum SecondaryAbility { public enum SecondaryAbility {
/* !! Warning -- Do not let subskills share a name with any existing SkillType as it will clash with the static import !! */
/* ACROBATICS */ /* ACROBATICS */
DODGE, DODGE(ACROBATICS),
GRACEFUL_ROLL, GRACEFUL_ROLL(ACROBATICS),
ROLL, ROLL(ACROBATICS),
/* ALCHEMY */ /* ALCHEMY */
CATALYSIS, CATALYSIS(ALCHEMY),
CONCOCTIONS, CONCOCTIONS(ALCHEMY),
/* ARCHERY */ /* ARCHERY */
DAZE, DAZE(ARCHERY),
RETRIEVE, RETRIEVE(ARCHERY),
SKILL_SHOT, SKILL_SHOT(ARCHERY),
/* Axes */ /* Axes */
ARMOR_IMPACT, ARMOR_IMPACT(AXES),
AXE_MASTERY, AXE_MASTERY(AXES),
CRITICAL_HIT, CRITICAL_HIT(AXES),
GREATER_IMPACT, GREATER_IMPACT(AXES),
/* Excavation */ /* Excavation */
EXCAVATION_TREASURE_HUNTER, EXCAVATION_TREASURE_HUNTER(EXCAVATION),
/* Fishing */ /* Fishing */
FISHERMANS_DIET, FISHERMANS_DIET(FISHING),
FISHING_TREASURE_HUNTER, FISHING_TREASURE_HUNTER(FISHING),
ICE_FISHING, ICE_FISHING(FISHING),
MAGIC_HUNTER, MAGIC_HUNTER(FISHING),
MASTER_ANGLER, MASTER_ANGLER(FISHING),
SHAKE, SHAKE(FISHING),
/* Herbalism */ /* Herbalism */
FARMERS_DIET, FARMERS_DIET(HERBALISM),
GREEN_THUMB_PLANT, GREEN_THUMB_PLANT(HERBALISM),
GREEN_THUMB_BLOCK, GREEN_THUMB_BLOCK(HERBALISM),
HERBALISM_DOUBLE_DROPS, HERBALISM_DOUBLE_DROPS(HERBALISM),
HYLIAN_LUCK, HYLIAN_LUCK(HERBALISM),
SHROOM_THUMB, SHROOM_THUMB(HERBALISM),
/* Mining */ /* Mining */
MINING_DOUBLE_DROPS, MINING_DOUBLE_DROPS(MINING),
/* Repair */ /* Repair */
ARCANE_FORGING, ARCANE_FORGING(REPAIR),
REPAIR_MASTERY, REPAIR_MASTERY(REPAIR),
SUPER_REPAIR, SUPER_REPAIR(REPAIR),
/* Salvage */ /* Salvage */
ADVANCED_SALVAGE, ADVANCED_SALVAGE(SALVAGE),
ARCANE_SALVAGE, ARCANE_SALVAGE(SALVAGE),
/* Smelting */ /* Smelting */
FLUX_MINING, FLUX_MINING(SMELTING),
FUEL_EFFICIENCY, FUEL_EFFICIENCY(SMELTING),
SECOND_SMELT, SECOND_SMELT(SMELTING),
/* Swords */ /* Swords */
BLEED, BLEED(SWORDS),
COUNTER, COUNTER(SWORDS),
/* Taming */ /* Taming */
BEAST_LORE, BEAST_LORE(TAMING),
CALL_OF_THE_WILD, CALL_OF_THE_WILD(TAMING),
ENVIRONMENTALLY_AWARE, ENVIRONMENTALLY_AWARE(TAMING),
FAST_FOOD, FAST_FOOD(TAMING),
GORE, GORE(TAMING),
HOLY_HOUND, HOLY_HOUND(TAMING),
SHARPENED_CLAWS, SHARPENED_CLAWS(TAMING),
SHOCK_PROOF, SHOCK_PROOF(TAMING),
THICK_FUR, THICK_FUR(TAMING),
PUMMEL, PUMMEL(TAMING),
/* Unarmed */ /* Unarmed */
BLOCK_CRACKER, BLOCK_CRACKER(UNARMED),
DEFLECT, DEFLECT(UNARMED),
DISARM, DISARM(UNARMED),
IRON_ARM, IRON_ARM(UNARMED),
IRON_GRIP, IRON_GRIP(UNARMED),
/* Woodcutting */ /* Woodcutting */
LEAF_BLOWER, WOODCUTTING_TREE_FELLER(WOODCUTTING),
WOODCUTTING_DOUBLE_DROPS; WOODCUTTING_LEAF_BLOWER(WOODCUTTING),
WOODCUTTING_SURGEON(WOODCUTTING),
WOODCUTTING_NATURES_BOUNTY(WOODCUTTING),
WOODCUTTING_SPLINTER(WOODCUTTING),
WOODCUTTING_HARVEST(WOODCUTTING);
private final SkillType parentSkill;
SecondaryAbility(SkillType parentSkill)
{
this.parentSkill = parentSkill;
}
public SkillType getParentSkill() { return parentSkill; }
} }

View File

@ -0,0 +1,39 @@
package com.gmail.nossr50.datatypes.skills;
/**
* This class represents a gated subskill
* A gated subskill is a subskill that requires a certain level to unlock
* This class is mostly to make it easier to grab information about subskills for a player
*/
public class SkillMilestone {
private int unlockLevel; //Level that grants access to this skill
private SecondaryAbility subskill; //Subskill that this milestone belongs to
private SkillMilestone childMilestone; //Next rank in the milestone
public SkillMilestone(SecondaryAbility subskill, int unlockLevel, SkillMilestone childMilestone)
{
this.subskill = subskill;
this.unlockLevel = unlockLevel;
//Assign a child subskill if it exists
if(childMilestone != null)
this.childMilestone = childMilestone;
}
public SkillMilestone(SecondaryAbility subskill, int unlockLevel)
{
this(subskill, unlockLevel, null);
}
public int getUnlockLevel() {
return unlockLevel;
}
public SecondaryAbility getSubskill() {
return subskill;
}
public SkillMilestone getChildMilestone() {
return childMilestone;
}
}

View File

@ -50,7 +50,7 @@ public enum SkillType {
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)), SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIRONMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR, SecondaryAbility.PUMMEL)), TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIRONMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR, SecondaryAbility.PUMMEL)),
UNARMED(UnarmedManager.class, Color.BLACK, AbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SecondaryAbility.BLOCK_CRACKER, SecondaryAbility.DEFLECT, SecondaryAbility.DISARM, SecondaryAbility.IRON_ARM, SecondaryAbility.IRON_GRIP)), UNARMED(UnarmedManager.class, Color.BLACK, AbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SecondaryAbility.BLOCK_CRACKER, SecondaryAbility.DEFLECT, SecondaryAbility.DISARM, SecondaryAbility.IRON_ARM, SecondaryAbility.IRON_GRIP)),
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, AbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SecondaryAbility.LEAF_BLOWER, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS)); WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, AbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SecondaryAbility.WOODCUTTING_LEAF_BLOWER, SecondaryAbility.WOODCUTTING_HARVEST));
private Class<? extends SkillManager> managerClass; private Class<? extends SkillManager> managerClass;
private Color runescapeColor; private Color runescapeColor;

View File

@ -31,7 +31,7 @@ public class WoodcuttingManager extends SkillManager {
} }
public boolean canUseLeafBlower(ItemStack heldItem) { public boolean canUseLeafBlower(ItemStack heldItem) {
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.LEAF_BLOWER) && getSkillLevel() >= Woodcutting.leafBlowerUnlockLevel && ItemUtils.isAxe(heldItem); return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.WOODCUTTING_LEAF_BLOWER) && getSkillLevel() >= Woodcutting.leafBlowerUnlockLevel && ItemUtils.isAxe(heldItem);
} }
public boolean canUseTreeFeller(ItemStack heldItem) { public boolean canUseTreeFeller(ItemStack heldItem) {
@ -39,7 +39,7 @@ public class WoodcuttingManager extends SkillManager {
} }
protected boolean canGetDoubleDrops() { protected boolean canGetDoubleDrops() {
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) && SkillUtils.isActivationSuccessful(SecondarySkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS, getPlayer(), this.skill, getSkillLevel(), activationChance); return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.WOODCUTTING_HARVEST) && SkillUtils.isActivationSuccessful(SecondarySkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SecondaryAbility.WOODCUTTING_HARVEST, getPlayer(), this.skill, getSkillLevel(), activationChance);
} }
/** /**

View File

@ -83,7 +83,7 @@ public class StringUtils {
switch (secondaryAbility) { switch (secondaryAbility) {
case HERBALISM_DOUBLE_DROPS : case HERBALISM_DOUBLE_DROPS :
case MINING_DOUBLE_DROPS : case MINING_DOUBLE_DROPS :
case WOODCUTTING_DOUBLE_DROPS : case WOODCUTTING_HARVEST:
return "Double Drops"; return "Double Drops";
case FISHING_TREASURE_HUNTER : case FISHING_TREASURE_HUNTER :
case EXCAVATION_TREASURE_HUNTER : case EXCAVATION_TREASURE_HUNTER :

View File

@ -0,0 +1,30 @@
package com.gmail.nossr50.util.player;
import org.bukkit.entity.Player;
/**
* This class will manage all types of feedback for a player done through mcMMO
* Including
* 1) Audio Feedback
* 2) Visual Feedback (Anything on the screen that we use to convey information)
*/
public class FeedbackManager {
/**
* Used for sending specific sound cues to a player
* @param player The player who will be receiving the sound cues
*/
public void sendAudioFeedback(Player player)
{
}
/**
* Used for sending specific visual aides to a player
* @param player The player who will be receiving the visual feedback
*/
public void sendVisualFeedback(Player player)
{
}
}

View File

@ -0,0 +1,7 @@
package com.gmail.nossr50.util.player;
public enum VisualFeedbackType {
ADVANCEMENT,
CHAT_MESSAGE,
CUSTOM_SCOREBOARD
}

View File

@ -26,6 +26,9 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
/**
* Manages the Scoreboards used to display a variety of mcMMO related information to the player
*/
public class ScoreboardManager { public class ScoreboardManager {
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>(); static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
@ -51,11 +54,22 @@ public class ScoreboardManager {
static final Map<AbilityType, String> abilityLabelsColored; static final Map<AbilityType, String> abilityLabelsColored;
static final Map<AbilityType, String> abilityLabelsSkill; static final Map<AbilityType, String> abilityLabelsSkill;
/*
* Initializes the static properties of this class
*/
static { static {
/*
* We need immutable objects for our Scoreboard's labels
*/
ImmutableMap.Builder<SkillType, String> skillLabelBuilder = ImmutableMap.builder(); ImmutableMap.Builder<SkillType, String> skillLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, String> abilityLabelBuilder = ImmutableMap.builder(); ImmutableMap.Builder<AbilityType, String> abilityLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder(); ImmutableMap.Builder<AbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder();
/*
* Builds the labels for our ScoreBoards
* Stylizes the scoreboard in a Rainbow Pattern
* This is off by default
*/
if (Config.getInstance().getScoreboardRainbows()) { if (Config.getInstance().getScoreboardRainbows()) {
// Everything but black, gray, gold // Everything but black, gray, gold
List<ChatColor> colors = Lists.newArrayList( List<ChatColor> colors = Lists.newArrayList(
@ -93,6 +107,10 @@ public class ScoreboardManager {
} }
} }
} }
/*
* Builds the labels for our ScoreBoards
* Stylizes the scoreboard using our normal color scheme
*/
else { else {
for (SkillType type : SkillType.values()) { for (SkillType type : SkillType.values()) {
// Include child skills // Include child skills

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.util.scoreboards;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import jdk.internal.jline.internal.Nullable;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -40,9 +41,13 @@ public class ScoreboardWrapper {
private Objective powerObjective; private Objective powerObjective;
// Parameter variables (May be null / invalid) // Parameter variables (May be null / invalid)
@Nullable
private Scoreboard oldBoard = null; private Scoreboard oldBoard = null;
@Nullable
public String targetPlayer = null; public String targetPlayer = null;
@Nullable
public SkillType targetSkill = null; public SkillType targetSkill = null;
@Nullable
private PlayerProfile targetProfile = null; private PlayerProfile targetProfile = null;
public int leaderboardPage = -1; public int leaderboardPage = -1;

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import java.util.HashMap;
/**
* This class will handle the following things
* 1) Informing the player of important milestones in a skill (Every 5 levels)
* 2) Getting lists of milestones (skill unlocks) a player has
* 3) Propagating events for milestones (API)
*
* By setting up a skill milestone system it will make managing the audio/visual feedback for progression a lot easier
*
*/
//TODO: Inform players of milestones
//TODO: Helper methods for getting milestones
//TODO: Propagate events when milestones are achieved
//TODO: Update existing parts of the codebase to use this where appropriate
public class SkillMilestoneManager {
public static final HashMap<SkillType, SecondaryAbility> subskillMilestones;
static {
//Init our maps
subskillMilestones = new HashMap<>();
for(SkillType skillType : SkillType.values())
{
//TODO: Setup these values
}
}
}