mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Update SkillTools
This commit is contained in:
parent
cfdcc9dee5
commit
be44c0e417
@ -802,7 +802,7 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getLevelCap(String skillType) {
|
||||
return mcMMO.p.getGeneralConfig().getLevelCap(getSkillType(skillType));
|
||||
return mcMMO.p.getSkillTools().getLevelCap(getSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -936,7 +936,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getTruncateSkills()) {
|
||||
for (PrimarySkillType skill : mcMMO.p.getSkillTools().NON_CHILD_SKILLS) {
|
||||
int cap = mcMMO.p.getGeneralConfig().getLevelCap(skill);
|
||||
int cap = mcMMO.p.getSkillTools().getLevelCap(skill);
|
||||
if (cap != Integer.MAX_VALUE) {
|
||||
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `" + skill.name().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
||||
statement.executeUpdate();
|
||||
|
@ -252,7 +252,7 @@ public class McMMOPlayer implements Identified {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.PowerLevel", String.valueOf(mcMMO.p.getGeneralConfig().getPowerLevelCap()));
|
||||
} else if(hasReachedLevelCap(primarySkillType)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.Skill",
|
||||
String.valueOf(mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType)),
|
||||
String.valueOf(mcMMO.p.getSkillTools().getLevelCap(primarySkillType)),
|
||||
mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ public class McMMOPlayer implements Identified {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (PrimarySkillType primarySkillType : mcMMO.p.getSkillTools().NON_CHILD_SKILLS) {
|
||||
if (Permissions.skillEnabled(player, primarySkillType)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, primarySkillType)) {
|
||||
powerLevel += getSkillLevel(primarySkillType);
|
||||
}
|
||||
}
|
||||
@ -588,7 +588,7 @@ public class McMMOPlayer implements Identified {
|
||||
if(hasReachedPowerLevelCap())
|
||||
return true;
|
||||
|
||||
return getSkillLevel(primarySkillType) >= mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType);
|
||||
return getSkillLevel(primarySkillType) >= mcMMO.p.getSkillTools().getLevelCap(primarySkillType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -616,7 +616,7 @@ public class McMMOPlayer implements Identified {
|
||||
float splitXp = xp / parentSkills.size();
|
||||
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
if (Permissions.skillEnabled(player, parentSkill)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, parentSkill)) {
|
||||
beginXpGain(parentSkill, splitXp, xpGainReason, xpGainSource);
|
||||
}
|
||||
}
|
||||
@ -660,7 +660,7 @@ public class McMMOPlayer implements Identified {
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(PrimarySkillType primarySkillType, float xp, XPGainReason xpGainReason, XPGainSource xpGainSource) {
|
||||
if (!Permissions.skillEnabled(player, primarySkillType)) {
|
||||
if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, primarySkillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ public class McMMOPlayer implements Identified {
|
||||
*/
|
||||
private float modifyXpGain(PrimarySkillType primarySkillType, float xp) {
|
||||
//TODO: A rare situation can occur where the default Power Level cap can prevent a player with one skill edited to something silly like Integer.MAX_VALUE from gaining XP in any skill, we may need to represent power level with another data type
|
||||
if ((mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType) <= getSkillLevel(primarySkillType))
|
||||
if ((mcMMO.p.getSkillTools().getLevelCap(primarySkillType) <= getSkillLevel(primarySkillType))
|
||||
|| (mcMMO.p.getGeneralConfig().getPowerLevelCap() <= getPowerLevel())) {
|
||||
return 0;
|
||||
}
|
||||
@ -953,7 +953,7 @@ public class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
|
||||
if (!Permissions.skillEnabled(getPlayer(), primarySkillType)) {
|
||||
if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(getPlayer(), primarySkillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ public class PlayerProfile {
|
||||
int sum = 0;
|
||||
|
||||
for (PrimarySkillType parent : parents) {
|
||||
sum += Math.min(getSkillLevel(parent), mcMMO.p.getGeneralConfig().getLevelCap(parent));
|
||||
sum += Math.min(getSkillLevel(parent), mcMMO.p.getSkillTools().getLevelCap(parent));
|
||||
}
|
||||
|
||||
return sum / parents.size();
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum PrimarySkillType {
|
||||
@ -140,7 +141,7 @@ public enum PrimarySkillType {
|
||||
*/
|
||||
@Deprecated
|
||||
public List<SubSkillType> getSkillAbilities() {
|
||||
return mcMMO.p.getSkillTools().getSubSkills(this);
|
||||
return new ArrayList<>(mcMMO.p.getSkillTools().getSubSkills(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +218,7 @@ public enum PrimarySkillType {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getPermissions(Player player) {
|
||||
return Permissions.skillEnabled(player, this);
|
||||
return mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,7 @@ public enum SuperAbilityType {
|
||||
}
|
||||
|
||||
public int getCooldown() {
|
||||
return mcMMO.p.getGeneralConfig().getCooldown(this);
|
||||
return mcMMO.p.getSkillTools().getSuperAbilityCooldown(this);
|
||||
}
|
||||
|
||||
public int getMaxLength() {
|
||||
|
@ -83,7 +83,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
entityDamageEvent.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
} else if(Permissions.skillEnabled(player, PrimarySkillType.ACROBATICS)) {
|
||||
} else if(mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.ACROBATICS)) {
|
||||
//Give XP Anyways
|
||||
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, ((EntityDamageEvent) event).getFinalDamage(), false), XPGainReason.PVE);
|
||||
}
|
||||
|
@ -228,10 +228,10 @@ public class BlockListener implements Listener {
|
||||
if(mcMMOPlayer == null)
|
||||
return;
|
||||
|
||||
if (blockState.getType() == Repair.anvilMaterial && Permissions.skillEnabled(player, PrimarySkillType.REPAIR)) {
|
||||
if (blockState.getType() == Repair.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.REPAIR)) {
|
||||
mcMMOPlayer.getRepairManager().placedAnvilCheck();
|
||||
}
|
||||
else if (blockState.getType() == Salvage.anvilMaterial && Permissions.skillEnabled(player, PrimarySkillType.SALVAGE)) {
|
||||
else if (blockState.getType() == Salvage.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SALVAGE)) {
|
||||
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
|
||||
}
|
||||
}
|
||||
@ -333,7 +333,7 @@ public class BlockListener implements Listener {
|
||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (Permissions.skillEnabled(player, PrimarySkillType.HERBALISM)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.HERBALISM)) {
|
||||
herbalismManager.processHerbalismBlockBreakEvent(event);
|
||||
}
|
||||
/*
|
||||
@ -344,14 +344,14 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, PrimarySkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockUtils.hasWoodcuttingXP(blockState) && ItemUtils.isAxe(heldItem)
|
||||
&& Permissions.skillEnabled(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||
woodcuttingManager.processTreeFeller(blockState);
|
||||
@ -366,7 +366,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, PrimarySkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
||||
excavationManager.excavationBlockCheck(blockState);
|
||||
|
||||
|
@ -296,7 +296,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !Permissions.skillEnabled(player, PrimarySkillType.FISHING)) {
|
||||
if (!UserManager.hasPlayerDataKey(player) || !mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.FISHING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !Permissions.skillEnabled(player, PrimarySkillType.FISHING)) {
|
||||
if (!UserManager.hasPlayerDataKey(player) || !mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.FISHING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -677,7 +677,7 @@ public class PlayerListener implements Listener {
|
||||
if (!mcMMO.p.getGeneralConfig().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||
/* REPAIR CHECKS */
|
||||
if (type == Repair.anvilMaterial
|
||||
&& Permissions.skillEnabled(player, PrimarySkillType.REPAIR)
|
||||
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.REPAIR)
|
||||
&& mcMMO.getRepairableManager().isRepairable(heldItem)
|
||||
&& heldItem.getAmount() <= 1) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
@ -691,7 +691,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (type == Salvage.anvilMaterial
|
||||
&& Permissions.skillEnabled(player, PrimarySkillType.SALVAGE)
|
||||
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SALVAGE)
|
||||
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
|
||||
&& mcMMO.getSalvageableManager().isSalvageable(heldItem)
|
||||
&& heldItem.getAmount() <= 1) {
|
||||
@ -724,7 +724,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if (!mcMMO.p.getGeneralConfig().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||
/* REPAIR CHECKS */
|
||||
if (type == Repair.anvilMaterial && Permissions.skillEnabled(player, PrimarySkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
if (type == Repair.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
// Cancel repairing an enchanted item
|
||||
@ -734,7 +734,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (type == Salvage.anvilMaterial && Permissions.skillEnabled(player, PrimarySkillType.SALVAGE) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
|
||||
else if (type == Salvage.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SALVAGE) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
|
||||
SalvageManager salvageManager = mcMMOPlayer.getSalvageManager();
|
||||
|
||||
// Cancel salvaging an enchanted item
|
||||
|
@ -47,7 +47,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (PrimarySkillType skill : mcMMO.p.getSkillTools().NON_CHILD_SKILLS) {
|
||||
// if (!Permissions.skillEnabled(player, skill)) {
|
||||
// if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, skill)) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
@ -209,7 +208,7 @@ public final class CommandUtils {
|
||||
if (mcMMO.p.getSkillTools().isChildSkill(skill)) {
|
||||
return LocaleLoader.getString("Skills.ChildStats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill));
|
||||
}
|
||||
if (profile.getSkillLevel(skill) == mcMMO.p.getGeneralConfig().getLevelCap(skill)){
|
||||
if (profile.getSkillLevel(skill) == mcMMO.p.getSkillTools().getLevelCap(skill)){
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), LocaleLoader.getString("Skills.MaxXP"));
|
||||
}
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill));
|
||||
@ -225,7 +224,7 @@ public final class CommandUtils {
|
||||
displayData.add(header);
|
||||
|
||||
for (PrimarySkillType primarySkillType : skillGroup) {
|
||||
if (Permissions.skillEnabled(inspectTarget, primarySkillType)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(inspectTarget, primarySkillType)) {
|
||||
displayData.add(displaySkill(profile, primarySkillType));
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class FormulaManager {
|
||||
public int[] calculateNewLevel(PrimarySkillType primarySkillType, int experience, FormulaType formulaType) {
|
||||
int newLevel = 0;
|
||||
int remainder = 0;
|
||||
int maxLevel = mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType);
|
||||
int maxLevel = mcMMO.p.getSkillTools().getLevelCap(primarySkillType);
|
||||
|
||||
while (experience > 0 && newLevel < maxLevel) {
|
||||
int experienceToNextLevel = getXPtoNextLevel(newLevel, formulaType);
|
||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
@ -580,7 +579,7 @@ public class ScoreboardWrapper {
|
||||
powerLevel += level;
|
||||
|
||||
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
||||
if (!Permissions.skillEnabled(player, skill)) {
|
||||
if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -608,7 +607,7 @@ public class ScoreboardWrapper {
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
for (PrimarySkillType skill : mcMMO.p.getSkillTools().NON_CHILD_SKILLS) {
|
||||
if (!Permissions.skillEnabled(player, skill)) {
|
||||
if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, PrimarySkillType.SWORDS)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SWORDS)) {
|
||||
processSwordCombat(target, player, event);
|
||||
|
||||
}
|
||||
@ -394,7 +394,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, PrimarySkillType.AXES)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.AXES)) {
|
||||
processAxeCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
@ -403,7 +403,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, PrimarySkillType.UNARMED)) {
|
||||
if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.UNARMED)) {
|
||||
processUnarmedCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
@ -416,7 +416,7 @@ public final class CombatUtils {
|
||||
if (tamer instanceof Player && mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) {
|
||||
Player master = (Player) tamer;
|
||||
|
||||
if (!Misc.isNPCEntityExcludingVillagers(master) && Permissions.skillEnabled(master, PrimarySkillType.TAMING)) {
|
||||
if (!Misc.isNPCEntityExcludingVillagers(master) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(master, PrimarySkillType.TAMING)) {
|
||||
processTamingCombat(target, master, wolf, event);
|
||||
}
|
||||
}
|
||||
@ -428,14 +428,14 @@ public final class CombatUtils {
|
||||
if (projectileSource instanceof Player && mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) {
|
||||
Player player = (Player) projectileSource;
|
||||
|
||||
if (!Misc.isNPCEntityExcludingVillagers(player) && Permissions.skillEnabled(player, PrimarySkillType.ARCHERY)) {
|
||||
if (!Misc.isNPCEntityExcludingVillagers(player) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.ARCHERY)) {
|
||||
processArcheryCombat(target, player, event, arrow);
|
||||
} else {
|
||||
//Cleanup Arrow
|
||||
cleanupArrowMetadata(arrow);
|
||||
}
|
||||
|
||||
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && Permissions.skillEnabled(player, PrimarySkillType.TAMING)) {
|
||||
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.TAMING)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mcMMOPlayer == null)
|
||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -27,19 +28,19 @@ public class SkillTools {
|
||||
public final ImmutableList<String> LOCALIZED_SKILL_NAMES;
|
||||
public final ImmutableList<String> FORMATTED_SUBSKILL_NAMES;
|
||||
public final ImmutableSet<String> EXACT_SUBSKILL_NAMES;
|
||||
public final List<PrimarySkillType> CHILD_SKILLS;
|
||||
public final ImmutableList<PrimarySkillType> CHILD_SKILLS;
|
||||
public final ImmutableList<PrimarySkillType> NON_CHILD_SKILLS;
|
||||
public final ImmutableList<PrimarySkillType> COMBAT_SKILLS;
|
||||
public final ImmutableList<PrimarySkillType> GATHERING_SKILLS;
|
||||
public final ImmutableList<PrimarySkillType> MISC_SKILLS;
|
||||
|
||||
private EnumMap<SubSkillType, PrimarySkillType> subSkillParentRelationshipMap; //TODO: This disgusts me, but it will have to do until the new skill system is in place
|
||||
private EnumMap<SuperAbilityType, PrimarySkillType> superAbilityParentRelationshipMap; //TODO: This disgusts me, but it will have to do until the new skill system is in place
|
||||
private EnumMap<PrimarySkillType, HashSet<SubSkillType>> primarySkillChildrenMap; //TODO: This disgusts me, but it will have to do until the new skill system is in place
|
||||
private ImmutableMap<SubSkillType, PrimarySkillType> subSkillParentRelationshipMap;
|
||||
private ImmutableMap<SuperAbilityType, PrimarySkillType> superAbilityParentRelationshipMap;
|
||||
private ImmutableMap<PrimarySkillType, Set<SubSkillType>> primarySkillChildrenMap;
|
||||
|
||||
// The map below is for the super abilities which require readying a tool, its everything except blast mining
|
||||
private EnumMap<PrimarySkillType, SuperAbilityType> mainActivatedAbilityChildMap; //TODO: This disgusts me, but it will have to do until the new skill system is in place
|
||||
private EnumMap<PrimarySkillType, ToolType> primarySkillToolMap; //TODO: Christ..
|
||||
private ImmutableMap<PrimarySkillType, SuperAbilityType> mainActivatedAbilityChildMap;
|
||||
private ImmutableMap<PrimarySkillType, ToolType> primarySkillToolMap;
|
||||
|
||||
public SkillTools(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
@ -72,39 +73,43 @@ public class SkillTools {
|
||||
NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
|
||||
}
|
||||
|
||||
//TODO: What is with this design?
|
||||
private void initPrimaryToolMap() {
|
||||
primarySkillToolMap = new EnumMap<PrimarySkillType, ToolType>(PrimarySkillType.class);
|
||||
EnumMap<PrimarySkillType, ToolType> tempToolMap = new EnumMap<PrimarySkillType, ToolType>(PrimarySkillType.class);
|
||||
|
||||
primarySkillToolMap.put(PrimarySkillType.AXES, ToolType.AXE);
|
||||
primarySkillToolMap.put(PrimarySkillType.WOODCUTTING, ToolType.AXE);
|
||||
primarySkillToolMap.put(PrimarySkillType.UNARMED, ToolType.FISTS);
|
||||
primarySkillToolMap.put(PrimarySkillType.SWORDS, ToolType.SWORD);
|
||||
primarySkillToolMap.put(PrimarySkillType.EXCAVATION, ToolType.SHOVEL);
|
||||
primarySkillToolMap.put(PrimarySkillType.HERBALISM, ToolType.HOE);
|
||||
primarySkillToolMap.put(PrimarySkillType.MINING, ToolType.PICKAXE);
|
||||
tempToolMap.put(PrimarySkillType.AXES, ToolType.AXE);
|
||||
tempToolMap.put(PrimarySkillType.WOODCUTTING, ToolType.AXE);
|
||||
tempToolMap.put(PrimarySkillType.UNARMED, ToolType.FISTS);
|
||||
tempToolMap.put(PrimarySkillType.SWORDS, ToolType.SWORD);
|
||||
tempToolMap.put(PrimarySkillType.EXCAVATION, ToolType.SHOVEL);
|
||||
tempToolMap.put(PrimarySkillType.HERBALISM, ToolType.HOE);
|
||||
tempToolMap.put(PrimarySkillType.MINING, ToolType.PICKAXE);
|
||||
|
||||
primarySkillToolMap = ImmutableMap.copyOf(tempToolMap);
|
||||
}
|
||||
|
||||
private void initSuperAbilityParentRelationships() {
|
||||
superAbilityParentRelationshipMap = new EnumMap<SuperAbilityType, PrimarySkillType>(SuperAbilityType.class);
|
||||
mainActivatedAbilityChildMap = new EnumMap<PrimarySkillType, SuperAbilityType>(PrimarySkillType.class);
|
||||
EnumMap<SuperAbilityType, PrimarySkillType> tempAbilityParentRelationshipMap = new EnumMap<SuperAbilityType, PrimarySkillType>(SuperAbilityType.class);
|
||||
EnumMap<PrimarySkillType, SuperAbilityType> tempMainActivatedAbilityChildMap = new EnumMap<PrimarySkillType, SuperAbilityType>(PrimarySkillType.class);
|
||||
|
||||
for(SuperAbilityType superAbilityType : SuperAbilityType.values()) {
|
||||
try {
|
||||
PrimarySkillType parent = getSuperAbilityParent(superAbilityType);
|
||||
superAbilityParentRelationshipMap.put(superAbilityType, parent);
|
||||
tempAbilityParentRelationshipMap.put(superAbilityType, parent);
|
||||
|
||||
if(superAbilityType != SuperAbilityType.BLAST_MINING) {
|
||||
//This map is used only for abilities that have a tool readying phase, so blast mining is ignored
|
||||
mainActivatedAbilityChildMap.put(parent, superAbilityType);
|
||||
tempMainActivatedAbilityChildMap.put(parent, superAbilityType);
|
||||
}
|
||||
} catch (InvalidSkillException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
superAbilityParentRelationshipMap = ImmutableMap.copyOf(tempAbilityParentRelationshipMap);
|
||||
mainActivatedAbilityChildMap = ImmutableMap.copyOf(tempMainActivatedAbilityChildMap);
|
||||
}
|
||||
|
||||
private PrimarySkillType getSuperAbilityParent(SuperAbilityType superAbilityType) throws InvalidSkillException {
|
||||
private @NotNull PrimarySkillType getSuperAbilityParent(SuperAbilityType superAbilityType) throws InvalidSkillException {
|
||||
switch(superAbilityType) {
|
||||
case BERSERK:
|
||||
return PrimarySkillType.UNARMED;
|
||||
@ -130,7 +135,7 @@ public class SkillTools {
|
||||
* Builds a list of localized {@link PrimarySkillType} names
|
||||
* @return list of localized {@link PrimarySkillType} names
|
||||
*/
|
||||
private ArrayList<String> buildLocalizedPrimarySkillNames() {
|
||||
private @NotNull ArrayList<String> buildLocalizedPrimarySkillNames() {
|
||||
ArrayList<String> localizedSkillNameList = new ArrayList<>();
|
||||
|
||||
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
@ -147,11 +152,11 @@ public class SkillTools {
|
||||
* Disgusting Hacky Fix until the new skill system is in place
|
||||
*/
|
||||
private void initPrimaryChildMap() {
|
||||
primarySkillChildrenMap = new EnumMap<PrimarySkillType, HashSet<SubSkillType>>(PrimarySkillType.class);
|
||||
EnumMap<PrimarySkillType, Set<SubSkillType>> tempPrimaryChildMap = new EnumMap<PrimarySkillType, Set<SubSkillType>>(PrimarySkillType.class);
|
||||
|
||||
//Init the empty Hash Sets
|
||||
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
primarySkillChildrenMap.put(primarySkillType, new HashSet<SubSkillType>());
|
||||
tempPrimaryChildMap.put(primarySkillType, new HashSet<>());
|
||||
}
|
||||
|
||||
//Fill in the hash sets
|
||||
@ -159,8 +164,10 @@ public class SkillTools {
|
||||
PrimarySkillType parentSkill = subSkillParentRelationshipMap.get(subSkillType);
|
||||
|
||||
//Add this subskill as a child
|
||||
primarySkillChildrenMap.get(parentSkill).add(subSkillType);
|
||||
tempPrimaryChildMap.get(parentSkill).add(subSkillType);
|
||||
}
|
||||
|
||||
primarySkillChildrenMap = ImmutableMap.copyOf(tempPrimaryChildMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +175,7 @@ public class SkillTools {
|
||||
* Used in tab completion mostly
|
||||
* @return a list of formatted sub skill names
|
||||
*/
|
||||
private ArrayList<String> buildFormattedSubSkillNameList() {
|
||||
private @NotNull ArrayList<String> buildFormattedSubSkillNameList() {
|
||||
ArrayList<String> subSkillNameList = new ArrayList<>();
|
||||
|
||||
for(SubSkillType subSkillType : SubSkillType.values()) {
|
||||
@ -178,7 +185,7 @@ public class SkillTools {
|
||||
return subSkillNameList;
|
||||
}
|
||||
|
||||
private HashSet<String> buildExactSubSkillNameList() {
|
||||
private @NotNull HashSet<String> buildExactSubSkillNameList() {
|
||||
HashSet<String> subSkillNameExactSet = new HashSet<>();
|
||||
|
||||
for(SubSkillType subSkillType : SubSkillType.values()) {
|
||||
@ -193,7 +200,7 @@ public class SkillTools {
|
||||
* Disgusting Hacky Fix until the new skill system is in place
|
||||
*/
|
||||
private void initSubSkillRelationshipMap() {
|
||||
subSkillParentRelationshipMap = new EnumMap<SubSkillType, PrimarySkillType>(SubSkillType.class);
|
||||
EnumMap<SubSkillType, PrimarySkillType> tempSubParentMap = new EnumMap<SubSkillType, PrimarySkillType>(SubSkillType.class);
|
||||
|
||||
//Super hacky and disgusting
|
||||
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
@ -202,10 +209,12 @@ public class SkillTools {
|
||||
|
||||
if(primarySkillType.toString().equalsIgnoreCase(splitSubSkillName[0])) {
|
||||
//Parent Skill Found
|
||||
subSkillParentRelationshipMap.put(subSkillType, primarySkillType);
|
||||
tempSubParentMap.put(subSkillType, primarySkillType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subSkillParentRelationshipMap = ImmutableMap.copyOf(tempSubParentMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,9 +301,9 @@ public class SkillTools {
|
||||
return primarySkillToolMap.get(primarySkillType);
|
||||
}
|
||||
|
||||
public List<SubSkillType> getSubSkills(PrimarySkillType primarySkillType) {
|
||||
public Set<SubSkillType> getSubSkills(PrimarySkillType primarySkillType) {
|
||||
//TODO: Cache this!
|
||||
return new ArrayList<>(primarySkillChildrenMap.get(primarySkillType));
|
||||
return primarySkillChildrenMap.get(primarySkillType);
|
||||
}
|
||||
|
||||
public double getXpModifier(PrimarySkillType primarySkillType) {
|
||||
@ -323,7 +332,7 @@ public class SkillTools {
|
||||
return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(primarySkillType.toString()) + ".SkillName"));
|
||||
}
|
||||
|
||||
public boolean doesPlayerHaveSkillPermission(PrimarySkillType primarySkillType, Player player) {
|
||||
public boolean doesPlayerHaveSkillPermission(Player player, PrimarySkillType primarySkillType) {
|
||||
return Permissions.skillEnabled(player, primarySkillType);
|
||||
}
|
||||
|
||||
@ -364,7 +373,7 @@ public class SkillTools {
|
||||
}
|
||||
|
||||
public int getLevelCap(@NotNull PrimarySkillType primarySkillType) {
|
||||
return mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType);
|
||||
return mcMMO.p.getSkillTools().getLevelCap(primarySkillType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.util.skills;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -89,7 +88,7 @@ public class SmeltingTracker {
|
||||
}
|
||||
|
||||
public void processFurnaceOwnership(Furnace furnace, Player player) {
|
||||
if(!Permissions.skillEnabled(player, PrimarySkillType.SMELTING))
|
||||
if(!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SMELTING))
|
||||
return;
|
||||
|
||||
//Don't swap ownership if its the same player
|
||||
|
Loading…
Reference in New Issue
Block a user