Gutting out new Skill API and putting it on hold

This commit is contained in:
nossr50 2021-03-16 14:43:31 -07:00
parent 31904ef181
commit a6276bded8
3 changed files with 532 additions and 543 deletions

View File

@ -1,341 +1,341 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
import com.gmail.nossr50.skills.axes.AxesManager;
import com.gmail.nossr50.skills.crossbows.CrossbowsManager;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.tridents.TridentsManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.google.common.collect.ImmutableSet;
import com.neetgames.mcmmo.skill.RootSkill;
import com.neetgames.mcmmo.skill.SkillIdentity;
import com.neetgames.mcmmo.skill.SuperSkill;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class CoreSkills {
//TODO: Should these be immutable?
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_ROOT_SKILLS;
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_CHILD_SKILLS;
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_NON_CHILD_SKILLS;
private static final @NotNull ImmutableSet<CoreSkill> CORE_SUB_SKILLS;
private static final @NotNull ImmutableSet<SuperSkill> CORE_SUPER_SKILLS;
//TODO: Use annotations instead
public static final @NotNull CoreRootSkill ACROBATICS, ALCHEMY, ARCHERY, AXES, EXCAVATION,
FISHING, HERBALISM, MINING, REPAIR, SALVAGE, SMELTING, SWORDS, TAMING, UNARMED,
WOODCUTTING, TRIDENTS, CROSSBOWS;
//TODO: Needed?
public static final @NotNull SkillIdentity ACROBATICS_ID, ALCHEMY_ID, ARCHERY_ID, AXES_ID, EXCAVATION_ID,
FISHING_ID, HERBALISM_ID, MINING_ID, REPAIR_ID, SALVAGE_ID, SMELTING_ID, SWORDS_ID, TAMING_ID, UNARMED_ID,
WOODCUTTING_ID, TRIDENTS_ID, CROSSBOWS_ID;
// public static final @NotNull SuperSkill SKULL_SPLITTER, GIGA_DRILL_BREAKER, GREEN_TERRA, SUPER_BREAKER,
// BLAST_MINING, SERRATED_STRIKES, CALL_OF_THE_WILD, BERSERK, TREE_FELLER, TRIDENTS_SUPER, SUPER_SHOT_GUN;
// public static @NotNull CoreSkill
// /* Acrobatics */
// DODGE, ROLL,
//package com.gmail.nossr50.datatypes.skills;
//
// /* Alchemy */
// CATALYSIS, CONCOCTIONS,
//import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
//import com.gmail.nossr50.skills.alchemy.AlchemyManager;
//import com.gmail.nossr50.skills.archery.ArcheryManager;
//import com.gmail.nossr50.skills.axes.AxesManager;
//import com.gmail.nossr50.skills.crossbows.CrossbowsManager;
//import com.gmail.nossr50.skills.excavation.ExcavationManager;
//import com.gmail.nossr50.skills.fishing.FishingManager;
//import com.gmail.nossr50.skills.herbalism.HerbalismManager;
//import com.gmail.nossr50.skills.mining.MiningManager;
//import com.gmail.nossr50.skills.repair.RepairManager;
//import com.gmail.nossr50.skills.salvage.SalvageManager;
//import com.gmail.nossr50.skills.smelting.SmeltingManager;
//import com.gmail.nossr50.skills.swords.SwordsManager;
//import com.gmail.nossr50.skills.taming.TamingManager;
//import com.gmail.nossr50.skills.tridents.TridentsManager;
//import com.gmail.nossr50.skills.unarmed.UnarmedManager;
//import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
//import com.google.common.collect.ImmutableSet;
//import com.neetgames.mcmmo.skill.RootSkill;
//import com.neetgames.mcmmo.skill.SkillIdentity;
//import com.neetgames.mcmmo.skill.SuperSkill;
//import org.jetbrains.annotations.NotNull;
//import org.jetbrains.annotations.Nullable;
//
// /* Archery */
// ARROW_RETRIEVAL, DAZE, SKILLSHOT, LIMIT_BREAK_ARCHERY,
//import java.util.HashMap;
//import java.util.HashSet;
//import java.util.Map;
//import java.util.Set;
//import java.util.stream.Collectors;
//
// /* Axes */
// ARMOR_IMPACT, AXE_MASTERY, LIMIT_BREAK_AXES, CRITICAL_STRIKES, GREATER_IMPACT, SKULL_SPLITTER,
//public class CoreSkills {
//
// /* Excavation */
// ARCHAEOLOGY, GIGA_DRILL_BREAKER,
// //TODO: Should these be immutable?
// private static final @NotNull ImmutableSet<CoreRootSkill> CORE_ROOT_SKILLS;
// private static final @NotNull ImmutableSet<CoreRootSkill> CORE_CHILD_SKILLS;
// private static final @NotNull ImmutableSet<CoreRootSkill> CORE_NON_CHILD_SKILLS;
// private static final @NotNull ImmutableSet<CoreSkill> CORE_SUB_SKILLS;
// private static final @NotNull ImmutableSet<SuperSkill> CORE_SUPER_SKILLS;
//
// /* Fishing */
// FISHERMANS_DIET, ICE_FISHING, MAGIC_HUNTER, MASTER_ANGLER, TREASURE_HUNTER, SHAKE,
// //TODO: Use annotations instead
// public static final @NotNull CoreRootSkill ACROBATICS, ALCHEMY, ARCHERY, AXES, EXCAVATION,
// FISHING, HERBALISM, MINING, REPAIR, SALVAGE, SMELTING, SWORDS, TAMING, UNARMED,
// WOODCUTTING, TRIDENTS, CROSSBOWS;
//
// /* Herbalism */
// DOUBLE_DROPS_HERBALISM, FARMERS_DIET, GREEN_TERRA, GREEN_THUMB, HYLIAN_LUCK, SHROOM_THUMB,
// //TODO: Needed?
// public static final @NotNull SkillIdentity ACROBATICS_ID, ALCHEMY_ID, ARCHERY_ID, AXES_ID, EXCAVATION_ID,
// FISHING_ID, HERBALISM_ID, MINING_ID, REPAIR_ID, SALVAGE_ID, SMELTING_ID, SWORDS_ID, TAMING_ID, UNARMED_ID,
// WOODCUTTING_ID, TRIDENTS_ID, CROSSBOWS_ID;
//
// /* Mining */
// BIGGER_BOMBS, BLAST_MINING, DEMOLITIONS_EXPERTISE, DOUBLE_DROPS, SUPER_BREAKER,
//// public static final @NotNull SuperSkill SKULL_SPLITTER, GIGA_DRILL_BREAKER, GREEN_TERRA, SUPER_BREAKER,
//// BLAST_MINING, SERRATED_STRIKES, CALL_OF_THE_WILD, BERSERK, TREE_FELLER, TRIDENTS_SUPER, SUPER_SHOT_GUN;
//
// /* Repair */
// ARCANE_FORGING, REPAIR_MASTERY, SUPER_REPAIR,
//// public static @NotNull CoreSkill
//// /* Acrobatics */
//// DODGE, ROLL,
////
//// /* Alchemy */
//// CATALYSIS, CONCOCTIONS,
////
//// /* Archery */
//// ARROW_RETRIEVAL, DAZE, SKILLSHOT, LIMIT_BREAK_ARCHERY,
////
//// /* Axes */
//// ARMOR_IMPACT, AXE_MASTERY, LIMIT_BREAK_AXES, CRITICAL_STRIKES, GREATER_IMPACT, SKULL_SPLITTER,
////
//// /* Excavation */
//// ARCHAEOLOGY, GIGA_DRILL_BREAKER,
////
//// /* Fishing */
//// FISHERMANS_DIET, ICE_FISHING, MAGIC_HUNTER, MASTER_ANGLER, TREASURE_HUNTER, SHAKE,
////
//// /* Herbalism */
//// DOUBLE_DROPS_HERBALISM, FARMERS_DIET, GREEN_TERRA, GREEN_THUMB, HYLIAN_LUCK, SHROOM_THUMB,
////
//// /* Mining */
//// BIGGER_BOMBS, BLAST_MINING, DEMOLITIONS_EXPERTISE, DOUBLE_DROPS, SUPER_BREAKER,
////
//// /* Repair */
//// ARCANE_FORGING, REPAIR_MASTERY, SUPER_REPAIR,
////
//// /* Salvage */
//// SCRAP_COLLECTOR, ARCANE_SALVAGE,
////
//// /* Smelting */
//// FUEL_EFFICIENCY, SECOND_SMELT, UNDERSTANDING_THE_ART,
////
//// /* Swords */
//// COUNTER_ATTACK, RUPTURE, SERRATED_STRIKES, STAB, LIMIT_BREAK_SWORDS,
////
//// /* Taming */
//// BEAST_LORE, CALL_OF_THE_WILD, ENVIRONMENTALLY_AWARE, FAST_FOOD_SERVICE, GORE, HOLY_HOUND, PUMMEL, SHARPENED_CLAWS, SHOCK_PROOF, THICK_FUR,
////
//// /* Archery */
//// ARROW_DEFLECT, BERSERK, BLOCK_CRACKER, DISARM, STEEL_ARM_STYLE, IRON_GRIP, LIMIT_BREAK_UNARMED,
////
//// /* Woodcutting */
//// KNOCK_ON_WOOD, HARVEST_LUMBER, LEAF_BLOWER, TREE_FELLER,
////
//// /* Tridents */
//// MULTI_TASKING, LIMIT_BREAK_TRIDENTS,
////
//// /* Crossbows */
//// SUPER_SHOTGUN, LIMIT_BREAK_CROSSBOWS;
//
// /* Salvage */
// SCRAP_COLLECTOR, ARCANE_SALVAGE,
// private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
//
// /* Smelting */
// FUEL_EFFICIENCY, SECOND_SMELT, UNDERSTANDING_THE_ART,
// static {
// HashSet<CoreRootSkill> rootSkillSet = new HashSet<>();
// HashSet<CoreRootSkill> childSkillSet = new HashSet<>();
// HashSet<CoreSkill> subSkillSet = new HashSet<>();
// HashSet<SuperSkill> superSkillSet = new HashSet<>();
//
// /* Swords */
// COUNTER_ATTACK, RUPTURE, SERRATED_STRIKES, STAB, LIMIT_BREAK_SWORDS,
// ACROBATICS = new CoreRootSkill("acrobatics", AcrobaticsManager.class);
// ACROBATICS_ID = ACROBATICS.getSkillIdentity();
//
// /* Taming */
// BEAST_LORE, CALL_OF_THE_WILD, ENVIRONMENTALLY_AWARE, FAST_FOOD_SERVICE, GORE, HOLY_HOUND, PUMMEL, SHARPENED_CLAWS, SHOCK_PROOF, THICK_FUR,
// ALCHEMY = new CoreRootSkill("alchemy", AlchemyManager.class);
// ALCHEMY_ID = ALCHEMY.getSkillIdentity();
//
// /* Archery */
// ARROW_DEFLECT, BERSERK, BLOCK_CRACKER, DISARM, STEEL_ARM_STYLE, IRON_GRIP, LIMIT_BREAK_UNARMED,
// ARCHERY = new CoreRootSkill("archery", ArcheryManager.class);
// ARCHERY_ID = ARCHERY.getSkillIdentity();
//
// /* Woodcutting */
// KNOCK_ON_WOOD, HARVEST_LUMBER, LEAF_BLOWER, TREE_FELLER,
// AXES = new CoreRootSkill("axes", AxesManager.class);
// AXES_ID = AXES.getSkillIdentity();
//
// /* Tridents */
// MULTI_TASKING, LIMIT_BREAK_TRIDENTS,
// EXCAVATION = new CoreRootSkill("excavation", ExcavationManager.class);
// EXCAVATION_ID = EXCAVATION.getSkillIdentity();
//
// /* Crossbows */
// SUPER_SHOTGUN, LIMIT_BREAK_CROSSBOWS;
private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
static {
HashSet<CoreRootSkill> rootSkillSet = new HashSet<>();
HashSet<CoreRootSkill> childSkillSet = new HashSet<>();
HashSet<CoreSkill> subSkillSet = new HashSet<>();
HashSet<SuperSkill> superSkillSet = new HashSet<>();
ACROBATICS = new CoreRootSkill("acrobatics", AcrobaticsManager.class);
ACROBATICS_ID = ACROBATICS.getSkillIdentity();
ALCHEMY = new CoreRootSkill("alchemy", AlchemyManager.class);
ALCHEMY_ID = ALCHEMY.getSkillIdentity();
ARCHERY = new CoreRootSkill("archery", ArcheryManager.class);
ARCHERY_ID = ARCHERY.getSkillIdentity();
AXES = new CoreRootSkill("axes", AxesManager.class);
AXES_ID = AXES.getSkillIdentity();
EXCAVATION = new CoreRootSkill("excavation", ExcavationManager.class);
EXCAVATION_ID = EXCAVATION.getSkillIdentity();
FISHING = new CoreRootSkill("fishing", FishingManager.class);
FISHING_ID = FISHING.getSkillIdentity();
HERBALISM = new CoreRootSkill("herbalism", HerbalismManager.class);
HERBALISM_ID = HERBALISM.getSkillIdentity();
MINING = new CoreRootSkill("mining", MiningManager.class);
MINING_ID = MINING.getSkillIdentity();
REPAIR = new CoreRootSkill("repair", RepairManager.class);
REPAIR_ID = REPAIR.getSkillIdentity();
SALVAGE = new CoreRootSkill("salvage", SalvageManager.class);
SALVAGE_ID = SALVAGE.getSkillIdentity();
SMELTING = new CoreRootSkill("smelting", SmeltingManager.class);
SMELTING_ID = SMELTING.getSkillIdentity();
SWORDS = new CoreRootSkill("swords", SwordsManager.class);
SWORDS_ID = SWORDS.getSkillIdentity();
TAMING = new CoreRootSkill("taming", TamingManager.class);
TAMING_ID = TAMING.getSkillIdentity();
UNARMED = new CoreRootSkill("unarmed", UnarmedManager.class);
UNARMED_ID = UNARMED.getSkillIdentity();
WOODCUTTING = new CoreRootSkill("woodcutting", WoodcuttingManager.class);
WOODCUTTING_ID = WOODCUTTING.getSkillIdentity();
TRIDENTS = new CoreRootSkill("tridents", TridentsManager.class);
TRIDENTS_ID = TRIDENTS.getSkillIdentity();
CROSSBOWS = new CoreRootSkill("crossbows", CrossbowsManager.class);
CROSSBOWS_ID = CROSSBOWS.getSkillIdentity();
//Child skills (soon to be removed)
childSkillSet.add(SMELTING);
childSkillSet.add(SALVAGE);
rootSkillSet.add(ACROBATICS);
rootSkillSet.add(ALCHEMY);
rootSkillSet.add(ARCHERY);
rootSkillSet.add(AXES);
rootSkillSet.add(EXCAVATION);
rootSkillSet.add(FISHING);
rootSkillSet.add(HERBALISM);
rootSkillSet.add(MINING);
rootSkillSet.add(REPAIR);
rootSkillSet.add(SALVAGE);
rootSkillSet.add(SMELTING);
rootSkillSet.add(SWORDS);
rootSkillSet.add(TAMING);
rootSkillSet.add(UNARMED);
rootSkillSet.add(WOODCUTTING);
rootSkillSet.add(TRIDENTS);
rootSkillSet.add(CROSSBOWS);
CORE_ROOT_SKILLS = ImmutableSet.copyOf(rootSkillSet);
CORE_CHILD_SKILLS = ImmutableSet.copyOf(childSkillSet);
CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
CORE_SUPER_SKILLS = ImmutableSet.copyOf(superSkillSet);
/*
* Init core skills
*/
}
/**
* Returns a set of built in {@link RootSkill}s for mcMMO
* No guarantees for whether or not the skills are registered or active or inactive
*
* @return a set of all {@link RootSkill} built into mcMMO
*/
public static @NotNull Set<CoreRootSkill> getCoreRootSkills() {
return CORE_ROOT_SKILLS;
}
/**
* Returns a set of built in {@link CoreSkill}s for mcMMO
* No guarantees for whether or not the skills are registered or active or inactive
*
* @return a set of all {@link CoreSkill} built into mcMMO
*/
public static @NotNull Set<CoreSkill> getCoreSkills() {
return CORE_SUB_SKILLS;
}
/**
* Returns a set of built in {@link SuperSkill}s for mcMMO
* No guarantees for whether or not the skills are registered or active or inactive
*
* @return a set of all {@link SuperSkill} built into mcMMO
*/
public static @NotNull Set<SuperSkill> getCoreSuperSkills() {
return CORE_SUPER_SKILLS;
}
/**
* Returns a set of built in skills for mcMMO which are child skills
* No guarantees for whether or not the skills are registered or active or inactive
*
* @return a set of all "child" root skills for mcMMO
* @deprecated child skills will be removed in an upcoming update
*/
@Deprecated
public static @NotNull Set<CoreRootSkill> getChildSkills() {
return CORE_CHILD_SKILLS;
}
/**
* Whether or not a skill is considered a child skill
* @param rootSkill target skill
* @return true if the skill identity belongs to a core "child" root skill
*/
public static boolean isChildSkill(@NotNull RootSkill rootSkill) {
return CORE_CHILD_SKILLS.contains(rootSkill);
}
@Deprecated
public static @NotNull RootSkill getSkill(@NotNull PrimarySkillType primarySkillType) {
if(!hackySkillMappings.init) {
hackySkillMappings.initMappings();
}
return hackySkillMappings.primaryToRootMap.get(primarySkillType);
}
@Deprecated
public static @NotNull PrimarySkillType getSkill(@NotNull RootSkill rootSkill) {
if(!hackySkillMappings.init) {
hackySkillMappings.initMappings();
}
return hackySkillMappings.rootToPrimaryMap.get(rootSkill);
}
@Deprecated
private static @NotNull Set<CoreRootSkill> generateNonChildSkillSet() {
return getCoreRootSkills().stream().filter((x) -> !isChildSkill(x)).collect(Collectors.toSet());
}
public static @NotNull Set<CoreRootSkill> getNonChildSkills() {
return CORE_NON_CHILD_SKILLS;
}
protected static class HackySkillMappings {
@NotNull Map<PrimarySkillType, CoreRootSkill> primaryToRootMap = new HashMap<>();
@NotNull Map<CoreRootSkill, PrimarySkillType> rootToPrimaryMap = new HashMap<>();
boolean init = false;
protected void initMappings() {
//TODO: add tests
//Can't init these from the get go as PrimarySkillType does some stuff and it would be race condition hell
primaryToRootMap.put(PrimarySkillType.ACROBATICS, ACROBATICS);
rootToPrimaryMap.put(ACROBATICS, PrimarySkillType.ACROBATICS);
primaryToRootMap.put(PrimarySkillType.ALCHEMY, ALCHEMY);
rootToPrimaryMap.put(ALCHEMY, PrimarySkillType.ALCHEMY);
primaryToRootMap.put(PrimarySkillType.ARCHERY, ARCHERY);
rootToPrimaryMap.put(ARCHERY, PrimarySkillType.ARCHERY);
primaryToRootMap.put(PrimarySkillType.AXES, AXES);
rootToPrimaryMap.put(AXES, PrimarySkillType.AXES);
primaryToRootMap.put(PrimarySkillType.EXCAVATION, EXCAVATION);
rootToPrimaryMap.put(EXCAVATION, PrimarySkillType.EXCAVATION);
primaryToRootMap.put(PrimarySkillType.FISHING, FISHING);
rootToPrimaryMap.put(FISHING, PrimarySkillType.FISHING);
primaryToRootMap.put(PrimarySkillType.HERBALISM, HERBALISM);
rootToPrimaryMap.put(HERBALISM, PrimarySkillType.HERBALISM);
primaryToRootMap.put(PrimarySkillType.MINING, MINING);
rootToPrimaryMap.put(MINING, PrimarySkillType.MINING);
primaryToRootMap.put(PrimarySkillType.REPAIR, REPAIR);
rootToPrimaryMap.put(REPAIR, PrimarySkillType.REPAIR);
primaryToRootMap.put(PrimarySkillType.SALVAGE, SALVAGE);
rootToPrimaryMap.put(SALVAGE, PrimarySkillType.SALVAGE);
primaryToRootMap.put(PrimarySkillType.SMELTING, SMELTING);
rootToPrimaryMap.put(SMELTING, PrimarySkillType.SMELTING);
primaryToRootMap.put(PrimarySkillType.SWORDS, SWORDS);
rootToPrimaryMap.put(SWORDS, PrimarySkillType.SWORDS);
primaryToRootMap.put(PrimarySkillType.TAMING, TAMING);
rootToPrimaryMap.put(TAMING, PrimarySkillType.TAMING);
primaryToRootMap.put(PrimarySkillType.UNARMED, UNARMED);
rootToPrimaryMap.put(UNARMED, PrimarySkillType.UNARMED);
primaryToRootMap.put(PrimarySkillType.WOODCUTTING, WOODCUTTING);
rootToPrimaryMap.put(WOODCUTTING, PrimarySkillType.WOODCUTTING);
primaryToRootMap.put(PrimarySkillType.TRIDENTS, TRIDENTS);
rootToPrimaryMap.put(TRIDENTS, PrimarySkillType.TRIDENTS);
primaryToRootMap.put(PrimarySkillType.CROSSBOWS, CROSSBOWS);
rootToPrimaryMap.put(CROSSBOWS, PrimarySkillType.CROSSBOWS);
init = true;
}
}
}
// FISHING = new CoreRootSkill("fishing", FishingManager.class);
// FISHING_ID = FISHING.getSkillIdentity();
//
// HERBALISM = new CoreRootSkill("herbalism", HerbalismManager.class);
// HERBALISM_ID = HERBALISM.getSkillIdentity();
//
// MINING = new CoreRootSkill("mining", MiningManager.class);
// MINING_ID = MINING.getSkillIdentity();
//
// REPAIR = new CoreRootSkill("repair", RepairManager.class);
// REPAIR_ID = REPAIR.getSkillIdentity();
//
// SALVAGE = new CoreRootSkill("salvage", SalvageManager.class);
// SALVAGE_ID = SALVAGE.getSkillIdentity();
//
// SMELTING = new CoreRootSkill("smelting", SmeltingManager.class);
// SMELTING_ID = SMELTING.getSkillIdentity();
//
// SWORDS = new CoreRootSkill("swords", SwordsManager.class);
// SWORDS_ID = SWORDS.getSkillIdentity();
//
// TAMING = new CoreRootSkill("taming", TamingManager.class);
// TAMING_ID = TAMING.getSkillIdentity();
//
// UNARMED = new CoreRootSkill("unarmed", UnarmedManager.class);
// UNARMED_ID = UNARMED.getSkillIdentity();
//
// WOODCUTTING = new CoreRootSkill("woodcutting", WoodcuttingManager.class);
// WOODCUTTING_ID = WOODCUTTING.getSkillIdentity();
//
// TRIDENTS = new CoreRootSkill("tridents", TridentsManager.class);
// TRIDENTS_ID = TRIDENTS.getSkillIdentity();
//
// CROSSBOWS = new CoreRootSkill("crossbows", CrossbowsManager.class);
// CROSSBOWS_ID = CROSSBOWS.getSkillIdentity();
//
// //Child skills (soon to be removed)
// childSkillSet.add(SMELTING);
// childSkillSet.add(SALVAGE);
//
// rootSkillSet.add(ACROBATICS);
// rootSkillSet.add(ALCHEMY);
// rootSkillSet.add(ARCHERY);
// rootSkillSet.add(AXES);
// rootSkillSet.add(EXCAVATION);
// rootSkillSet.add(FISHING);
// rootSkillSet.add(HERBALISM);
// rootSkillSet.add(MINING);
// rootSkillSet.add(REPAIR);
// rootSkillSet.add(SALVAGE);
// rootSkillSet.add(SMELTING);
// rootSkillSet.add(SWORDS);
// rootSkillSet.add(TAMING);
// rootSkillSet.add(UNARMED);
// rootSkillSet.add(WOODCUTTING);
// rootSkillSet.add(TRIDENTS);
// rootSkillSet.add(CROSSBOWS);
//
// CORE_ROOT_SKILLS = ImmutableSet.copyOf(rootSkillSet);
// CORE_CHILD_SKILLS = ImmutableSet.copyOf(childSkillSet);
// CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
// CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
// CORE_SUPER_SKILLS = ImmutableSet.copyOf(superSkillSet);
//
// /*
// * Init core skills
// */
//
//
// }
//
// /**
// * Returns a set of built in {@link RootSkill}s for mcMMO
// * No guarantees for whether or not the skills are registered or active or inactive
// *
// * @return a set of all {@link RootSkill} built into mcMMO
// */
// public static @NotNull Set<CoreRootSkill> getCoreRootSkills() {
// return CORE_ROOT_SKILLS;
// }
//
// /**
// * Returns a set of built in {@link CoreSkill}s for mcMMO
// * No guarantees for whether or not the skills are registered or active or inactive
// *
// * @return a set of all {@link CoreSkill} built into mcMMO
// */
// public static @NotNull Set<CoreSkill> getCoreSkills() {
// return CORE_SUB_SKILLS;
// }
//
// /**
// * Returns a set of built in {@link SuperSkill}s for mcMMO
// * No guarantees for whether or not the skills are registered or active or inactive
// *
// * @return a set of all {@link SuperSkill} built into mcMMO
// */
// public static @NotNull Set<SuperSkill> getCoreSuperSkills() {
// return CORE_SUPER_SKILLS;
// }
//
// /**
// * Returns a set of built in skills for mcMMO which are child skills
// * No guarantees for whether or not the skills are registered or active or inactive
// *
// * @return a set of all "child" root skills for mcMMO
// * @deprecated child skills will be removed in an upcoming update
// */
// @Deprecated
// public static @NotNull Set<CoreRootSkill> getChildSkills() {
// return CORE_CHILD_SKILLS;
// }
//
// /**
// * Whether or not a skill is considered a child skill
// * @param rootSkill target skill
// * @return true if the skill identity belongs to a core "child" root skill
// */
// public static boolean isChildSkill(@NotNull RootSkill rootSkill) {
// return CORE_CHILD_SKILLS.contains(rootSkill);
// }
//
// @Deprecated
// public static @NotNull RootSkill getSkill(@NotNull PrimarySkillType primarySkillType) {
// if(!hackySkillMappings.init) {
// hackySkillMappings.initMappings();
// }
//
// return hackySkillMappings.primaryToRootMap.get(primarySkillType);
// }
//
// @Deprecated
// public static @NotNull PrimarySkillType getSkill(@NotNull RootSkill rootSkill) {
// if(!hackySkillMappings.init) {
// hackySkillMappings.initMappings();
// }
//
// return hackySkillMappings.rootToPrimaryMap.get(rootSkill);
// }
//
// @Deprecated
// private static @NotNull Set<CoreRootSkill> generateNonChildSkillSet() {
// return getCoreRootSkills().stream().filter((x) -> !isChildSkill(x)).collect(Collectors.toSet());
// }
//
// public static @NotNull Set<CoreRootSkill> getNonChildSkills() {
// return CORE_NON_CHILD_SKILLS;
// }
//
// protected static class HackySkillMappings {
// @NotNull Map<PrimarySkillType, CoreRootSkill> primaryToRootMap = new HashMap<>();
// @NotNull Map<CoreRootSkill, PrimarySkillType> rootToPrimaryMap = new HashMap<>();
// boolean init = false;
//
// protected void initMappings() {
// //TODO: add tests
// //Can't init these from the get go as PrimarySkillType does some stuff and it would be race condition hell
// primaryToRootMap.put(PrimarySkillType.ACROBATICS, ACROBATICS);
// rootToPrimaryMap.put(ACROBATICS, PrimarySkillType.ACROBATICS);
//
// primaryToRootMap.put(PrimarySkillType.ALCHEMY, ALCHEMY);
// rootToPrimaryMap.put(ALCHEMY, PrimarySkillType.ALCHEMY);
//
// primaryToRootMap.put(PrimarySkillType.ARCHERY, ARCHERY);
// rootToPrimaryMap.put(ARCHERY, PrimarySkillType.ARCHERY);
//
// primaryToRootMap.put(PrimarySkillType.AXES, AXES);
// rootToPrimaryMap.put(AXES, PrimarySkillType.AXES);
//
// primaryToRootMap.put(PrimarySkillType.EXCAVATION, EXCAVATION);
// rootToPrimaryMap.put(EXCAVATION, PrimarySkillType.EXCAVATION);
//
// primaryToRootMap.put(PrimarySkillType.FISHING, FISHING);
// rootToPrimaryMap.put(FISHING, PrimarySkillType.FISHING);
//
// primaryToRootMap.put(PrimarySkillType.HERBALISM, HERBALISM);
// rootToPrimaryMap.put(HERBALISM, PrimarySkillType.HERBALISM);
//
// primaryToRootMap.put(PrimarySkillType.MINING, MINING);
// rootToPrimaryMap.put(MINING, PrimarySkillType.MINING);
//
// primaryToRootMap.put(PrimarySkillType.REPAIR, REPAIR);
// rootToPrimaryMap.put(REPAIR, PrimarySkillType.REPAIR);
//
// primaryToRootMap.put(PrimarySkillType.SALVAGE, SALVAGE);
// rootToPrimaryMap.put(SALVAGE, PrimarySkillType.SALVAGE);
//
// primaryToRootMap.put(PrimarySkillType.SMELTING, SMELTING);
// rootToPrimaryMap.put(SMELTING, PrimarySkillType.SMELTING);
//
// primaryToRootMap.put(PrimarySkillType.SWORDS, SWORDS);
// rootToPrimaryMap.put(SWORDS, PrimarySkillType.SWORDS);
//
// primaryToRootMap.put(PrimarySkillType.TAMING, TAMING);
// rootToPrimaryMap.put(TAMING, PrimarySkillType.TAMING);
//
// primaryToRootMap.put(PrimarySkillType.UNARMED, UNARMED);
// rootToPrimaryMap.put(UNARMED, PrimarySkillType.UNARMED);
//
// primaryToRootMap.put(PrimarySkillType.WOODCUTTING, WOODCUTTING);
// rootToPrimaryMap.put(WOODCUTTING, PrimarySkillType.WOODCUTTING);
//
// primaryToRootMap.put(PrimarySkillType.TRIDENTS, TRIDENTS);
// rootToPrimaryMap.put(TRIDENTS, PrimarySkillType.TRIDENTS);
//
// primaryToRootMap.put(PrimarySkillType.CROSSBOWS, CROSSBOWS);
// rootToPrimaryMap.put(CROSSBOWS, PrimarySkillType.CROSSBOWS);
//
// init = true;
// }
// }
//}

View File

@ -1,207 +1,207 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils;
import com.neetgames.mcmmo.api.SkillRegister;
import com.neetgames.mcmmo.skill.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
/**
* Skills mcMMO is aware of are registered here
* The skill register will be used for a few things in mcMMO
* Removing a skill from the register doesn't mean it isn't doing anything as the register is simply for mcMMO's own awareness
* When a player uses certain commands, such as checking their skill levels, if the skill isn't registered it won't be added to the resulting output of that command
*/
public class SkillRegisterImpl implements SkillRegister {
//TODO: Move maps and collections to their own container
private final @NotNull HashMap<String, Skill> skillNameMap;
private final @NotNull Set<Skill> registeredSkills;
private final @NotNull Set<SuperSkill> superSkills;
private final @NotNull Set<RankedSkill> rankedSkills;
private final @NotNull Set<RootSkill> rootSkills; //Can include not-official root skills
private final @NotNull Set<CoreRootSkill> coreRootSkills; //Only includes official root skills
private final @NotNull Set<CoreSkill> coreSkills; //Only includes official core skills
public SkillRegisterImpl() {
skillNameMap = new HashMap<>();
registeredSkills = new HashSet<>();
rootSkills = new HashSet<>();
superSkills = new HashSet<>();
rankedSkills = new HashSet<>();
coreRootSkills = new HashSet<>();
coreSkills = new HashSet<>();
//TODO: allow config to turn off certain core skills
registerCoreSkills();
}
private void registerCoreSkills() {
for(CoreRootSkill coreRootSkill : CoreSkills.getCoreRootSkills()) {
mcMMO.p.getLogger().info("Registering core skill: " + coreRootSkill.getRawSkillName());
registerSkill(coreRootSkill);
}
for(CoreSkill coreSkill : CoreSkills.)
}
@Override
public @Nullable Skill getSkill(@NotNull String fullyQualifiedName) {
return skillNameMap.get(fullyQualifiedName);
}
@Override
public @Nullable Skill getSkill(@NotNull SkillIdentity skillIdentity) {
return skillNameMap.get(skillIdentity.getFullyQualifiedName());
}
@Override
public @NotNull Set<SuperSkill> getSuperSkills() {
return superSkills;
}
@Override
public @NotNull Set<RankedSkill> getRankedSkills() {
return rankedSkills;
}
@Override
public @NotNull Set<RootSkill> getRootSkills() {
return rootSkills;
}
@Override
public boolean isSkillRegistered(@NotNull Skill skill) {
return registeredSkills.contains(skill);
}
@Override
public void registerSkill(@NotNull Skill skill) {
registeredSkills.add(skill);
addedSkillRegisterProcessing(skill);
}
@Override
public void registerSkill(@NotNull Skill skill, boolean override) {
if(isSkillRegistered(skill) && override) {
registeredSkills.remove(skill);
}
registeredSkills.add(skill);
addedSkillRegisterProcessing(skill);
}
@Override
public @NotNull Set<Skill> getRegisteredSkills() {
return registeredSkills;
}
private void postRemovalSkillRegisterProcessing(@NotNull Skill skill) {
removeSkillNameLookup(skill);
removeCollectionCache(skill);
}
private void removeCollectionCache(@NotNull Skill skill) {
//Remove from register cache(s)
if(skill instanceof CoreRootSkill) {
coreRootSkills.remove(skill);
}
if(skill instanceof CoreSkill) {
coreSkills.remove(skill);
}
if(skill instanceof RootSkill) {
rootSkills.remove(skill);
}
if (skill instanceof SuperSkill) {
superSkills.remove(skill);
}
if(skill instanceof RankedSkill) {
rankedSkills.remove( skill);
}
}
private void removeSkillNameLookup(@NotNull Skill skill) {
skillNameMap.remove(skill.getSkillIdentity().getFullyQualifiedName());
}
private void addedSkillRegisterProcessing(@NotNull Skill skill) {
addSkillNameLookup(skill);
addCollectionCache(skill);
}
private void addCollectionCache(@NotNull Skill skill) {
//Add to various collections for cached lookups
if(skill instanceof CoreSkill) {
coreSkills.add((CoreSkill) skill);
}
if(skill instanceof CoreRootSkill) {
coreRootSkills.add((CoreRootSkill) skill);
}
if(skill instanceof RootSkill) {
rootSkills.add((RootSkill) skill);
}
if (skill instanceof SuperSkill) {
superSkills.add((SuperSkill) skill);
}
if(skill instanceof RankedSkill) {
rankedSkills.add((RankedSkill) skill);
}
}
private void addSkillNameLookup(@NotNull Skill skill) {
skillNameMap.put(skill.getSkillIdentity().getFullyQualifiedName(), skill);
}
@Override
public void unregisterSkill(@NotNull Skill skill) {
mcMMO.p.getLogger().info("Skill "+skill.toString()+" has been removed from the skill register.");
registeredSkills.remove(skill);
skillNameMap.remove(skill.getSkillIdentity().getFullyQualifiedName());
//Collection cache cleanup
postRemovalSkillRegisterProcessing(skill);
}
@Override
public @NotNull Set<CoreRootSkill> getCoreRootSkills() {
return coreRootSkills;
}
/**
* Used to match skill by a "skill name"
* This is NOT case sensitive
*
* Will match against any registered root skill if one of the following is true
* 1) The skills localized name is equal to the provided {@link String skillName}
* 2) The provided {@link String skillName} matches a root skill's fully qualified name
* 3) The provided {@link String skillName} matches the name of the default name of the skill (the en_US not localized name, this name is never overridden by locale)
*
* @param skillName skill name or skill identity
* @return The matching {@link RootSkill} if it exists
* @see SkillIdentity#getFullyQualifiedName()
*/
public @Nullable RootSkill matchRootSkill(@NotNull String skillName) {
for (RootSkill rootSkill : rootSkills) {
if (rootSkill.getSkillIdentity().getFullyQualifiedName().equalsIgnoreCase(skillName)
|| skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(rootSkill.getRawSkillName()) + ".SkillName"))
|| rootSkill.getRawSkillName().equalsIgnoreCase(skillName)) {
return rootSkill;
}
}
return null;
}
}
//package com.gmail.nossr50.datatypes.skills;
//
//import com.gmail.nossr50.locale.LocaleLoader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.text.StringUtils;
//import com.neetgames.mcmmo.api.SkillRegister;
//import com.neetgames.mcmmo.skill.*;
//import org.jetbrains.annotations.NotNull;
//import org.jetbrains.annotations.Nullable;
//
//import java.util.HashMap;
//import java.util.HashSet;
//import java.util.Set;
//
///**
// * Skills mcMMO is aware of are registered here
// * The skill register will be used for a few things in mcMMO
// * Removing a skill from the register doesn't mean it isn't doing anything as the register is simply for mcMMO's own awareness
// * When a player uses certain commands, such as checking their skill levels, if the skill isn't registered it won't be added to the resulting output of that command
// */
//public class SkillRegisterImpl implements SkillRegister {
// //TODO: Move maps and collections to their own container
// private final @NotNull HashMap<String, Skill> skillNameMap;
// private final @NotNull Set<Skill> registeredSkills;
// private final @NotNull Set<SuperSkill> superSkills;
// private final @NotNull Set<RankedSkill> rankedSkills;
// private final @NotNull Set<RootSkill> rootSkills; //Can include not-official root skills
// private final @NotNull Set<CoreRootSkill> coreRootSkills; //Only includes official root skills
// private final @NotNull Set<CoreSkill> coreSkills; //Only includes official core skills
//
// public SkillRegisterImpl() {
// skillNameMap = new HashMap<>();
// registeredSkills = new HashSet<>();
// rootSkills = new HashSet<>();
// superSkills = new HashSet<>();
// rankedSkills = new HashSet<>();
// coreRootSkills = new HashSet<>();
// coreSkills = new HashSet<>();
//
// //TODO: allow config to turn off certain core skills
// registerCoreSkills();
// }
//
// private void registerCoreSkills() {
// for(CoreRootSkill coreRootSkill : CoreSkills.getCoreRootSkills()) {
// mcMMO.p.getLogger().info("Registering core skill: " + coreRootSkill.getRawSkillName());
// registerSkill(coreRootSkill);
// }
//
// for(CoreSkill coreSkill : CoreSkills.)
// }
//
// @Override
// public @Nullable Skill getSkill(@NotNull String fullyQualifiedName) {
// return skillNameMap.get(fullyQualifiedName);
// }
//
// @Override
// public @Nullable Skill getSkill(@NotNull SkillIdentity skillIdentity) {
// return skillNameMap.get(skillIdentity.getFullyQualifiedName());
// }
//
// @Override
// public @NotNull Set<SuperSkill> getSuperSkills() {
// return superSkills;
// }
//
// @Override
// public @NotNull Set<RankedSkill> getRankedSkills() {
// return rankedSkills;
// }
//
// @Override
// public @NotNull Set<RootSkill> getRootSkills() {
// return rootSkills;
// }
//
// @Override
// public boolean isSkillRegistered(@NotNull Skill skill) {
// return registeredSkills.contains(skill);
// }
//
// @Override
// public void registerSkill(@NotNull Skill skill) {
// registeredSkills.add(skill);
// addedSkillRegisterProcessing(skill);
// }
//
// @Override
// public void registerSkill(@NotNull Skill skill, boolean override) {
// if(isSkillRegistered(skill) && override) {
// registeredSkills.remove(skill);
// }
//
// registeredSkills.add(skill);
// addedSkillRegisterProcessing(skill);
// }
//
// @Override
// public @NotNull Set<Skill> getRegisteredSkills() {
// return registeredSkills;
// }
//
// private void postRemovalSkillRegisterProcessing(@NotNull Skill skill) {
// removeSkillNameLookup(skill);
// removeCollectionCache(skill);
// }
//
// private void removeCollectionCache(@NotNull Skill skill) {
// //Remove from register cache(s)
// if(skill instanceof CoreRootSkill) {
// coreRootSkills.remove(skill);
// }
//
// if(skill instanceof CoreSkill) {
// coreSkills.remove(skill);
// }
//
// if(skill instanceof RootSkill) {
// rootSkills.remove(skill);
// }
//
// if (skill instanceof SuperSkill) {
// superSkills.remove(skill);
// }
//
// if(skill instanceof RankedSkill) {
// rankedSkills.remove( skill);
// }
// }
//
// private void removeSkillNameLookup(@NotNull Skill skill) {
// skillNameMap.remove(skill.getSkillIdentity().getFullyQualifiedName());
// }
//
// private void addedSkillRegisterProcessing(@NotNull Skill skill) {
// addSkillNameLookup(skill);
// addCollectionCache(skill);
// }
//
// private void addCollectionCache(@NotNull Skill skill) {
// //Add to various collections for cached lookups
// if(skill instanceof CoreSkill) {
// coreSkills.add((CoreSkill) skill);
// }
//
// if(skill instanceof CoreRootSkill) {
// coreRootSkills.add((CoreRootSkill) skill);
// }
//
// if(skill instanceof RootSkill) {
// rootSkills.add((RootSkill) skill);
// }
//
// if (skill instanceof SuperSkill) {
// superSkills.add((SuperSkill) skill);
// }
//
// if(skill instanceof RankedSkill) {
// rankedSkills.add((RankedSkill) skill);
// }
// }
//
// private void addSkillNameLookup(@NotNull Skill skill) {
// skillNameMap.put(skill.getSkillIdentity().getFullyQualifiedName(), skill);
// }
//
// @Override
// public void unregisterSkill(@NotNull Skill skill) {
// mcMMO.p.getLogger().info("Skill "+skill.toString()+" has been removed from the skill register.");
// registeredSkills.remove(skill);
// skillNameMap.remove(skill.getSkillIdentity().getFullyQualifiedName());
//
// //Collection cache cleanup
// postRemovalSkillRegisterProcessing(skill);
// }
//
// @Override
// public @NotNull Set<CoreRootSkill> getCoreRootSkills() {
// return coreRootSkills;
// }
//
// /**
// * Used to match skill by a "skill name"
// * This is NOT case sensitive
// *
// * Will match against any registered root skill if one of the following is true
// * 1) The skills localized name is equal to the provided {@link String skillName}
// * 2) The provided {@link String skillName} matches a root skill's fully qualified name
// * 3) The provided {@link String skillName} matches the name of the default name of the skill (the en_US not localized name, this name is never overridden by locale)
// *
// * @param skillName skill name or skill identity
// * @return The matching {@link RootSkill} if it exists
// * @see SkillIdentity#getFullyQualifiedName()
// */
// public @Nullable RootSkill matchRootSkill(@NotNull String skillName) {
// for (RootSkill rootSkill : rootSkills) {
// if (rootSkill.getSkillIdentity().getFullyQualifiedName().equalsIgnoreCase(skillName)
// || skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(rootSkill.getRawSkillName()) + ".SkillName"))
// || rootSkill.getRawSkillName().equalsIgnoreCase(skillName)) {
// return rootSkill;
// }
// }
//
// return null;
// }
//}

View File

@ -12,10 +12,8 @@ import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SkillRegisterImpl;
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.party.PartyManagerImpl;
import com.gmail.nossr50.runnables.CheckDateTask;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
@ -49,8 +47,6 @@ import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SmeltingTracker;
import com.gmail.nossr50.util.upgrade.UpgradeManager;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.google.common.base.Charsets;
import com.neetgames.mcmmo.api.SkillRegister;
import com.neetgames.mcmmo.party.PartyManager;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.shatteredlands.shatt.backup.ZipLibrary;
@ -93,7 +89,6 @@ public class mcMMO extends JavaPlugin {
private static TransientMetadataTools transientMetadataTools;
private static ChatManager chatManager;
private static CommandManager commandManager; //ACF
private static SkillRegister skillRegister;
private static TransientEntityTracker transientEntityTracker;
private static boolean serverShutdownExecuted = false;
@ -164,9 +159,6 @@ public class mcMMO extends JavaPlugin {
@Override
public void onEnable() {
try {
//Skill Register
skillRegister = new SkillRegisterImpl();
//Platform Manager
platformManager = new PlatformManager();
@ -736,7 +728,4 @@ public class mcMMO extends JavaPlugin {
private static synchronized void setServerShutdown(boolean bool) {
serverShutdownExecuted = bool;
}
public @NotNull SkillRegister getSkillRegister() { return skillRegister; }
}