Add back and deprecate most of the members of PrimarySkillType

This commit is contained in:
nossr50 2021-04-09 10:46:12 -07:00
parent c1c32cb1fd
commit 29613bc324
4 changed files with 226 additions and 33 deletions

View File

@ -8,7 +8,8 @@ Version 2.1.189
Fixed an IllegalPluginAccessException error that could happen during server shutdown Fixed an IllegalPluginAccessException error that could happen during server shutdown
Minor performance optimizations to FlatFile database Minor performance optimizations to FlatFile database
Refactored a lot of code Refactored a lot of code
(API) PrimarySkillType is now just an enum with nothing special going on, SkillTools will facilitate what it used to do - see mcMMO::getSkillTools (API) PrimarySkillType will soon be just an enum with nothing special going on
(API) Deprecated the members of PrimarySkillType use mcMMO::getSkillTools instead, deprecated members will be removed in Tridents & Crossbows (due soon)
Added unit tests for FlatFileDatabaseManager Added unit tests for FlatFileDatabaseManager
NOTES: NOTES:

View File

@ -1,5 +1,15 @@
package com.gmail.nossr50.datatypes.skills; package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.config.GeneralConfig;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public enum PrimarySkillType { public enum PrimarySkillType {
ACROBATICS, ACROBATICS,
ALCHEMY, ALCHEMY,
@ -15,5 +25,209 @@ public enum PrimarySkillType {
SWORDS, SWORDS,
TAMING, TAMING,
UNARMED, UNARMED,
WOODCUTTING WOODCUTTING;
/*
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
*/
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getLevelCap(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public int getMaxLevel() {
return mcMMO.p.getSkillTools().getLevelCap(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#isSuperAbilityUnlocked(com.gmail.nossr50.datatypes.skills.PrimarySkillType, org.bukkit.entity.Player)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean isSuperAbilityUnlocked(@NotNull Player player) { return mcMMO.p.getSkillTools().isSuperAbilityUnlocked(this, player); }
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getPVPEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean getPVPEnabled() {
return mcMMO.p.getSkillTools().getPVPEnabled(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getPVEEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean getPVEEnabled() {
return mcMMO.p.getSkillTools().getPVEEnabled(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see GeneralConfig#getDoubleDropsDisabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean getDoubleDropsDisabled() {
return mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getHardcoreStatLossEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean getHardcoreStatLossEnabled() {
return mcMMO.p.getSkillTools().getHardcoreStatLossEnabled(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getHardcoreVampirismEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean getHardcoreVampirismEnabled() {
return mcMMO.p.getSkillTools().getHardcoreVampirismEnabled(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getPrimarySkillToolType(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public ToolType getTool() {
return mcMMO.p.getSkillTools().getPrimarySkillToolType(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getSubSkills(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public List<SubSkillType> getSkillAbilities() {
return mcMMO.p.getSkillTools().getSubSkills(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getXpModifier(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public double getXpModifier() {
return mcMMO.p.getSkillTools().getXpModifier(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#matchSkill(java.lang.String)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public static PrimarySkillType getSkill(String skillName) {
return mcMMO.p.getSkillTools().matchSkill(skillName);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#isChildSkill(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean isChildSkill() {
return mcMMO.p.getSkillTools().isChildSkill(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getPrimarySkillBySubSkill(com.gmail.nossr50.datatypes.skills.SubSkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public static PrimarySkillType bySecondaryAbility(SubSkillType subSkillType) {
return mcMMO.p.getSkillTools().getPrimarySkillBySubSkill(subSkillType);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getPrimarySkillBySuperAbility(com.gmail.nossr50.datatypes.skills.SuperAbilityType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public static PrimarySkillType byAbility(SuperAbilityType superAbilityType) {
return mcMMO.p.getSkillTools().getPrimarySkillBySuperAbility(superAbilityType);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getLocalizedSkillName(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public String getName() {
return mcMMO.p.getSkillTools().getLocalizedSkillName(this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see Permissions#skillEnabled(org.bukkit.permissions.Permissible, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update
*/
@Deprecated
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#canCombatSkillsTrigger(com.gmail.nossr50.datatypes.skills.PrimarySkillType, org.bukkit.entity.Entity)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public boolean shouldProcess(Entity target) {
return mcMMO.p.getSkillTools().canCombatSkillsTrigger(this, target);
}
} }

View File

@ -350,7 +350,8 @@ public class BlockListener implements Listener {
} }
/* WOOD CUTTING */ /* WOOD CUTTING */
else if (BlockUtils.hasWoodcuttingXP(blockState) && ItemUtils.isAxe(heldItem) && Permissions.skillEnabled(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.hasWoodcuttingXP(blockState) && ItemUtils.isAxe(heldItem)
&& Permissions.skillEnabled(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) { if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState); woodcuttingManager.processTreeFeller(blockState);

View File

@ -267,7 +267,9 @@ public class SkillTools {
} }
public boolean isSuperAbilityUnlocked(PrimarySkillType primarySkillType, Player player) { public boolean isSuperAbilityUnlocked(PrimarySkillType primarySkillType, Player player) {
return RankUtils.getRank(player, getSuperAbility(primarySkillType).getSubSkillTypeDefinition()) >= 1; SuperAbilityType superAbilityType = mcMMO.p.getSkillTools().getSuperAbility(primarySkillType);
SubSkillType subSkillType = superAbilityType.getSubSkillTypeDefinition();
return RankUtils.hasUnlockedSubskill(player, subSkillType);
} }
public boolean getPVPEnabled(PrimarySkillType primarySkillType) { public boolean getPVPEnabled(PrimarySkillType primarySkillType) {
@ -361,6 +363,10 @@ public class SkillTools {
return "SuperAbility." + StringUtils.getPrettyCamelCaseName(superAbilityType) + ".Refresh"; return "SuperAbility." + StringUtils.getPrettyCamelCaseName(superAbilityType) + ".Refresh";
} }
public int getLevelCap(@NotNull PrimarySkillType primarySkillType) {
return mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType);
}
/** /**
* Get the permissions for this ability. * Get the permissions for this ability.
* *
@ -418,33 +424,4 @@ public class SkillTools {
public @NotNull ImmutableList<PrimarySkillType> getMiscSkills() { public @NotNull ImmutableList<PrimarySkillType> getMiscSkills() {
return MISC_SKILLS; return MISC_SKILLS;
} }
// /**
// * Check if a block is affected by this ability.
// *
// * @param blockState the block to check
// * @param superAbilityType target super ability
// * @return true if the block is affected by this ability, false otherwise
// */
// public boolean superAbilityBlockCheck(SuperAbilityType superAbilityType, BlockState blockState) {
// switch (superAbilityType) {
// case BERSERK:
// return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
//
// case GIGA_DRILL_BREAKER:
// return BlockUtils.affectedByGigaDrillBreaker(blockState);
//
// case GREEN_TERRA:
// return BlockUtils.canMakeMossy(blockState);
//
// case SUPER_BREAKER:
// return BlockUtils.affectedBySuperBreaker(blockState);
//
// case TREE_FELLER:
// dfss
//
// default:
// return false;
// }
// }
} }