slowly refactoring stuff

This commit is contained in:
nossr50 2020-12-09 18:33:16 -08:00
parent 8491d0f4e5
commit 81d184c19e
18 changed files with 137 additions and 143 deletions

View File

@ -37,7 +37,7 @@ public class AcrobaticsCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE); canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE);
canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL); canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL);
} }

View File

@ -75,7 +75,7 @@ public class AlchemyCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS); canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS);
canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS); canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@ -9,6 +10,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,36 +31,36 @@ public class ArcheryCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// ARCHERY_ARROW_RETRIEVAL // ARCHERY_ARROW_RETRIEVAL
if (canRetrieve) { if (canRetrieve) {
String[] retrieveStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_ARROW_RETRIEVAL); String[] retrieveStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
retrieveChance = retrieveStrings[0]; retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1]; retrieveChanceLucky = retrieveStrings[1];
} }
// ARCHERY_DAZE // ARCHERY_DAZE
if (canDaze) { if (canDaze) {
String[] dazeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_DAZE); String[] dazeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.ARCHERY_DAZE);
dazeChance = dazeStrings[0]; dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1]; dazeChanceLucky = dazeStrings[1];
} }
// SKILL SHOT // SKILL SHOT
if (canSkillShot) { if (canSkillShot) {
skillShotBonus = percent.format(Archery.getDamageBonusPercent(player)); skillShotBonus = percent.format(Archery.getDamageBonusPercent(mmoPlayer));
} }
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canSkillShot = canUseSubskill(player, SubSkillType.ARCHERY_SKILL_SHOT); canSkillShot = canUseSubskill(mmoPlayer, SubSkillType.ARCHERY_SKILL_SHOT);
canDaze = canUseSubskill(player, SubSkillType.ARCHERY_DAZE); canDaze = canUseSubskill(mmoPlayer, SubSkillType.ARCHERY_DAZE);
canRetrieve = canUseSubskill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL); canRetrieve = canUseSubskill(mmoPlayer, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canRetrieve) { if (canRetrieve) {
@ -75,19 +77,19 @@ public class ArcheryCommand extends SkillCommand {
messages.add(getStatMessage(SubSkillType.ARCHERY_SKILL_SHOT, skillShotBonus)); messages.add(getStatMessage(SubSkillType.ARCHERY_SKILL_SHOT, skillShotBonus));
} }
if(canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) { if(canUseSubskill(mmoPlayer, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, 1000)))); String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(mmoPlayer, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, 1000))));
} }
return messages; return messages;
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY); TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.ARCHERY);
return textComponents; return textComponents;
} }

View File

@ -44,19 +44,19 @@ public class AxesCommand extends SkillCommand {
// AXE MASTERY // AXE MASTERY
if (canAxeMastery) { if (canAxeMastery) {
axeMasteryDamage = Axes.getAxeMasteryBonusDamage(player); axeMasteryDamage = Axes.getAxeMasteryBonusDamage(mmoPlayer.getPlayer());
} }
// CRITICAL HIT // CRITICAL HIT
if (canCritical) { if (canCritical) {
String[] criticalHitStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.AXES_CRITICAL_STRIKES); String[] criticalHitStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.AXES_CRITICAL_STRIKES);
critChance = criticalHitStrings[0]; critChance = criticalHitStrings[0];
critChanceLucky = criticalHitStrings[1]; critChanceLucky = criticalHitStrings[1];
} }
// SKULL SPLITTER // SKULL SPLITTER
if (canSkullSplitter) { if (canSkullSplitter) {
String[] skullSplitterStrings = calculateLengthDisplayValues(player, skillValue); String[] skullSplitterStrings = calculateLengthDisplayValues(mmoPlayer, skillValue);
skullSplitterLength = skullSplitterStrings[0]; skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1]; skullSplitterLengthEndurance = skullSplitterStrings[1];
} }
@ -72,7 +72,7 @@ public class AxesCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canImpact) { if (canImpact) {
@ -97,19 +97,19 @@ public class AxesCommand extends SkillCommand {
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : "")); + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
} }
if(canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) { if(canUseSubskill(mmoPlayer, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.AXES_AXES_LIMIT_BREAK, 1000)))); String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(mmoPlayer, SubSkillType.AXES_AXES_LIMIT_BREAK, 1000))));
} }
return messages; return messages;
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES); TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.AXES);
return textComponents; return textComponents;
} }

View File

@ -21,7 +21,7 @@ public class CrossbowsCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
} }

View File

@ -37,7 +37,7 @@ public class ExcavationCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER); canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY); canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@ -9,7 +10,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -41,64 +42,74 @@ public class HerbalismCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS); String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.HERBALISM_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
// FARMERS DIET // FARMERS DIET
if (canFarmersDiet) { if (canFarmersDiet) {
farmersDietRank = RankUtils.getRank(player, SubSkillType.HERBALISM_FARMERS_DIET); farmersDietRank = RankUtils.getRank(mmoPlayer, SubSkillType.HERBALISM_FARMERS_DIET);
} }
// GREEN TERRA // GREEN TERRA
if (canGreenTerra) { if (canGreenTerra) {
String[] greenTerraStrings = calculateLengthDisplayValues(player, skillValue); String[] greenTerraStrings = calculateLengthDisplayValues(mmoPlayer, skillValue);
greenTerraLength = greenTerraStrings[0]; greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1]; greenTerraLengthEndurance = greenTerraStrings[1];
} }
// GREEN THUMB // GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) { if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB); greenThumbStage = RankUtils.getRank(mmoPlayer, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_GREEN_THUMB); String[] greenThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.HERBALISM_GREEN_THUMB);
greenThumbChance = greenThumbStrings[0]; greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1]; greenThumbChanceLucky = greenThumbStrings[1];
} }
// HYLIAN LUCK // HYLIAN LUCK
if (hasHylianLuck) { if (hasHylianLuck) {
String[] hylianLuckStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_HYLIAN_LUCK); String[] hylianLuckStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.HERBALISM_HYLIAN_LUCK);
hylianLuckChance = hylianLuckStrings[0]; hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1]; hylianLuckChanceLucky = hylianLuckStrings[1];
} }
// SHROOM THUMB // SHROOM THUMB
if (canShroomThumb) { if (canShroomThumb) {
String[] shroomThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_SHROOM_THUMB); String[] shroomThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.HERBALISM_SHROOM_THUMB);
shroomThumbChance = shroomThumbStrings[0]; shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1]; shroomThumbChanceLucky = shroomThumbStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK); hasHylianLuck = canUseSubskill(mmoPlayer, SubSkillType.HERBALISM_HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player); canGreenTerra = Permissions.greenTerra(mmoPlayer.getPlayer());
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA)); canGreenThumbPlants = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.HERBALISM_GREEN_THUMB)
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS)); && (Permissions.greenThumbPlant(mmoPlayer.getPlayer(), Material.WHEAT)
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET); || Permissions.greenThumbPlant(mmoPlayer.getPlayer(), Material.CARROT)
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled(); || Permissions.greenThumbPlant(mmoPlayer.getPlayer(), Material.POTATO)
canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB); || Permissions.greenThumbPlant(mmoPlayer.getPlayer(), Material.BEETROOT)
|| Permissions.greenThumbPlant(mmoPlayer.getPlayer(), Material.NETHER_WART)
|| Permissions.greenThumbPlant(mmoPlayer.getPlayer(), Material.COCOA));
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.HERBALISM_GREEN_THUMB)
&& (Permissions.greenThumbBlock(mmoPlayer.getPlayer(), Material.DIRT)
|| Permissions.greenThumbBlock(mmoPlayer.getPlayer(), Material.COBBLESTONE)
|| Permissions.greenThumbBlock(mmoPlayer.getPlayer(), Material.COBBLESTONE_WALL)
|| Permissions.greenThumbBlock(mmoPlayer.getPlayer(), Material.STONE_BRICKS));
canFarmersDiet = canUseSubskill(mmoPlayer, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = canUseSubskill(mmoPlayer, SubSkillType.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canShroomThumb = canUseSubskill(mmoPlayer, SubSkillType.HERBALISM_SHROOM_THUMB);
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canDoubleDrop) { if (canDoubleDrop) {
@ -141,10 +152,10 @@ public class HerbalismCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.HERBALISM); TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.HERBALISM);
return textComponents; return textComponents;
} }

View File

@ -76,7 +76,7 @@ public class RepairCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canSuperRepair = canUseSubskill(player, SubSkillType.REPAIR_SUPER_REPAIR); canSuperRepair = canUseSubskill(player, SubSkillType.REPAIR_SUPER_REPAIR);
canMasterRepair = canUseSubskill(player, SubSkillType.REPAIR_REPAIR_MASTERY); canMasterRepair = canUseSubskill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
canArcaneForge = canUseSubskill(player, SubSkillType.REPAIR_ARCANE_FORGING); canArcaneForge = canUseSubskill(player, SubSkillType.REPAIR_ARCANE_FORGING);

View File

@ -82,7 +82,7 @@ public abstract class SkillCommand implements TabExecutor {
permissionsCheck(mmoPlayer); permissionsCheck(mmoPlayer);
dataCalculations(mmoPlayer, skillValue); dataCalculations(mmoPlayer, skillValue);
sendSkillCommandHeader(player, mmoPlayer, (int) skillValue); sendSkillCommandHeader(mmoPlayer, (int) skillValue);
//Make JSON text components //Make JSON text components
List<Component> subskillTextComponents = getTextComponents(mmoPlayer); List<Component> subskillTextComponents = getTextComponents(mmoPlayer);
@ -108,7 +108,7 @@ public abstract class SkillCommand implements TabExecutor {
//Link Header //Link Header
if (Config.getInstance().getUrlLinksEnabled()) { if (Config.getInstance().getUrlLinksEnabled()) {
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header")); player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player); TextComponentFactory.sendPlayerUrlHeader(mmoPlayer);
} }
@ -135,13 +135,13 @@ public abstract class SkillCommand implements TabExecutor {
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH)));
} }
private void sendSkillCommandHeader(Player player, McMMOPlayer mmoPlayer, int skillValue) { private void sendSkillCommandHeader(@NotNull McMMOPlayer mmoPlayer, int skillValue) {
ChatColor hd1 = ChatColor.DARK_AQUA; ChatColor hd1 = ChatColor.DARK_AQUA;
ChatColor c1 = ChatColor.GOLD; ChatColor c1 = ChatColor.GOLD;
ChatColor c2 = ChatColor.RED; ChatColor c2 = ChatColor.RED;
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName)); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
if(!skill.isChildSkill()) if(!skill.isChildSkill())
{ {
@ -150,10 +150,10 @@ public abstract class SkillCommand implements TabExecutor {
*/ */
//XP GAIN METHOD //XP GAIN METHOD
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
//LEVEL //LEVEL
player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mmoPlayer.getExperienceManager().getSkillXpValue(skill), mmoPlayer.getExperienceManager().getXpToLevel(skill))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mmoPlayer.getExperienceManager().getSkillXpValue(skill), mmoPlayer.getExperienceManager().getXpToLevel(skill)));
} else { } else {
/* /*
@ -181,31 +181,11 @@ public abstract class SkillCommand implements TabExecutor {
} }
//XP GAIN METHOD //XP GAIN METHOD
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain.Child"))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain.Child")));
player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage.toString())); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage.toString()));
//LEVEL
//player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, skillValue));
} }
/*
if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", skillValue, mmoPlayer.getSkillXpLevel(skill), mmoPlayer.getXpToLevel(skill)));
} else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
player.sendMessage(LocaleLoader.getString("Effects.Child", skillValue));
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents")));
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
for (PrimarySkillType parent : parents) {
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mmoPlayer.getSkillLevel(parent), mmoPlayer.getSkillXpLevel(parent), mmoPlayer.getXpToLevel(parent)));
}
}
*/
} }
@Override @Override

View File

@ -42,7 +42,7 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE); canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT); canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE); canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);

View File

@ -19,7 +19,7 @@ public class TridentsCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
} }

View File

@ -53,7 +53,7 @@ public class WoodcuttingCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player); canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && !skill.getDoubleDropsDisabled() && RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1; canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && !skill.getDoubleDropsDisabled() && RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER); canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);

View File

@ -51,7 +51,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class McMMOPlayer extends PlayerProfile implements Identified, Permissible { public class McMMOPlayer extends PlayerProfile implements Identified {
private final @NotNull Player player; private final @NotNull Player player;
private final @NotNull Identity identity; private final @NotNull Identity identity;
private @Nullable Party playerPartyRef; private @Nullable Party playerPartyRef;

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.api.ItemSpawnReason; import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
@ -64,14 +65,13 @@ public class Archery {
} }
} }
public static double getSkillShotBonusDamage(Player player, double oldDamage) public static double getSkillShotBonusDamage(@NotNull McMMOPlayer mmoPlayer, double oldDamage) {
{ double damageBonusPercent = getDamageBonusPercent(mmoPlayer);
double damageBonusPercent = getDamageBonusPercent(player);
double newDamage = oldDamage + (oldDamage * damageBonusPercent); double newDamage = oldDamage + (oldDamage * damageBonusPercent);
return Math.min(newDamage, (oldDamage + Archery.skillShotMaxBonusDamage)); return Math.min(newDamage, (oldDamage + Archery.skillShotMaxBonusDamage));
} }
public static double getDamageBonusPercent(Player player) { public static double getDamageBonusPercent(@NotNull McMMOPlayer mmoPlayer) {
return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * (AdvancedConfig.getInstance().getSkillShotRankDamageMultiplier()) / 100.0D); return ((RankUtils.getRank(mmoPlayer, SubSkillType.ARCHERY_SKILL_SHOT)) * (AdvancedConfig.getInstance().getSkillShotRankDamageMultiplier()) / 100.0D);
} }
} }

View File

@ -19,6 +19,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class ArcheryManager extends SkillManager { public class ArcheryManager extends SkillManager {
public ArcheryManager(McMMOPlayer mmoPlayer) { public ArcheryManager(McMMOPlayer mmoPlayer) {
@ -26,21 +27,21 @@ public class ArcheryManager extends SkillManager {
} }
public boolean canDaze(LivingEntity target) { public boolean canDaze(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.ARCHERY_DAZE))
return false; return false;
return target instanceof Player && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE); return target instanceof Player && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE);
} }
public boolean canSkillShot() { public boolean canSkillShot() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.ARCHERY_SKILL_SHOT))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT);
} }
public boolean canRetrieveArrows() { public boolean canRetrieveArrows() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.ARCHERY_ARROW_RETRIEVAL))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL);
@ -52,7 +53,7 @@ public class ArcheryManager extends SkillManager {
* @param target The {@link LivingEntity} damaged by the arrow * @param target The {@link LivingEntity} damaged by the arrow
* @param arrow The {@link Entity} who shot the arrow * @param arrow The {@link Entity} who shot the arrow
*/ */
public double distanceXpBonusMultiplier(LivingEntity target, Entity arrow) { public double distanceXpBonusMultiplier(@NotNull LivingEntity target, @NotNull Entity arrow) {
//Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
if(!arrow.hasMetadata(mcMMO.arrowDistanceKey)) if(!arrow.hasMetadata(mcMMO.arrowDistanceKey))
return arrow.getLocation().distance(target.getLocation()); return arrow.getLocation().distance(target.getLocation());
@ -76,7 +77,7 @@ public class ArcheryManager extends SkillManager {
* *
* @param target The {@link LivingEntity} damaged by the arrow * @param target The {@link LivingEntity} damaged by the arrow
*/ */
public void retrieveArrows(LivingEntity target, Projectile projectile) { public void retrieveArrows(@NotNull LivingEntity target, @NotNull Projectile projectile) {
if(projectile.hasMetadata(mcMMO.trackedArrow)) { if(projectile.hasMetadata(mcMMO.trackedArrow)) {
Archery.incrementTrackerValue(target); Archery.incrementTrackerValue(target);
projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile
@ -88,7 +89,7 @@ public class ArcheryManager extends SkillManager {
* *
* @param defender The {@link Player} being affected by the ability * @param defender The {@link Player} being affected by the ability
*/ */
public double daze(Player defender) { public double daze(@NotNull Player defender) {
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_DAZE, getPlayer())) { if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_DAZE, getPlayer())) {
return 0; return 0;
} }
@ -121,6 +122,6 @@ public class ArcheryManager extends SkillManager {
return oldDamage; return oldDamage;
} }
return Archery.getSkillShotBonusDamage(getPlayer(), oldDamage); return Archery.getSkillShotBonusDamage(mmoPlayer, oldDamage);
} }
} }

View File

@ -45,7 +45,7 @@ public class TamingManager extends SkillManager {
private HashMap<CallOfTheWildType, List<TrackedTamingEntity>> playerSummonedEntities; private HashMap<CallOfTheWildType, List<TrackedTamingEntity>> playerSummonedEntities;
public TamingManager(McMMOPlayer mmoPlayer) { public TamingManager(@NotNull McMMOPlayer mmoPlayer) {
super(mmoPlayer, PrimarySkillType.TAMING); super(mmoPlayer, PrimarySkillType.TAMING);
init(); init();
} }
@ -100,44 +100,44 @@ public class TamingManager extends SkillManager {
} }
public boolean canUseThickFur() { public boolean canUseThickFur() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR) return RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_THICK_FUR)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_THICK_FUR); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_THICK_FUR);
} }
public boolean canUseEnvironmentallyAware() { public boolean canUseEnvironmentallyAware() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE) return RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
} }
public boolean canUseShockProof() { public boolean canUseShockProof() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF) return RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_SHOCK_PROOF)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF);
} }
public boolean canUseHolyHound() { public boolean canUseHolyHound() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE) return RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_HOLY_HOUND); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_HOLY_HOUND);
} }
public boolean canUseFastFoodService() { public boolean canUseFastFoodService() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE) return RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_FAST_FOOD_SERVICE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE);
} }
public boolean canUseSharpenedClaws() { public boolean canUseSharpenedClaws() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS) return RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_SHARPENED_CLAWS)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS);
} }
public boolean canUseGore() { public boolean canUseGore() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_GORE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE);
} }
public boolean canUseBeastLore() { public boolean canUseBeastLore() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_BEAST_LORE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE);
@ -206,7 +206,7 @@ public class TamingManager extends SkillManager {
* Summon an ocelot to your side. * Summon an ocelot to your side.
*/ */
public void summonOcelot() { public void summonOcelot() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) { if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) {
@ -220,7 +220,7 @@ public class TamingManager extends SkillManager {
* Summon a wolf to your side. * Summon a wolf to your side.
*/ */
public void summonWolf() { public void summonWolf() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) { if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) {
@ -234,7 +234,7 @@ public class TamingManager extends SkillManager {
* Summon a horse to your side. * Summon a horse to your side.
*/ */
public void summonHorse() { public void summonHorse() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) { if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) {
@ -249,7 +249,7 @@ public class TamingManager extends SkillManager {
* *
* @param target The entity to examine * @param target The entity to examine
*/ */
public void beastLore(LivingEntity target) { public void beastLore(@NotNull LivingEntity target) {
Player player = getPlayer(); Player player = getPlayer();
Tameable beast = (Tameable) target; Tameable beast = (Tameable) target;
@ -273,7 +273,7 @@ public class TamingManager extends SkillManager {
player.sendMessage(message); player.sendMessage(message);
} }
public void processEnvironmentallyAware(Wolf wolf, double damage) { public void processEnvironmentallyAware(@NotNull Wolf wolf, double damage) {
if (damage > wolf.getHealth()) { if (damage > wolf.getHealth()) {
return; return;
} }
@ -284,8 +284,8 @@ public class TamingManager extends SkillManager {
NotificationManager.sendPlayerInformation(owner, NotificationType.SUBSKILL_MESSAGE, "Taming.Listener.Wolf"); NotificationManager.sendPlayerInformation(owner, NotificationType.SUBSKILL_MESSAGE, "Taming.Listener.Wolf");
} }
public void pummel(LivingEntity target, Wolf wolf) { public void pummel(@NotNull LivingEntity target, @NotNull Wolf wolf) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL)) if(!RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.TAMING_PUMMEL))
return; return;
if(!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL))) if(!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
@ -414,7 +414,7 @@ public class TamingManager extends SkillManager {
} }
} }
private void spawnWolf(Location spawnLocation) { private void spawnWolf(@NotNull Location spawnLocation) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, EntityType.WOLF); LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, EntityType.WOLF);
//This is used to prevent XP gains for damaging this entity //This is used to prevent XP gains for damaging this entity
@ -432,7 +432,7 @@ public class TamingManager extends SkillManager {
callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.WOLF))); callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.WOLF)));
} }
private void spawnCat(Location spawnLocation, EntityType entityType) { private void spawnCat(@NotNull Location spawnLocation, @NotNull EntityType entityType) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, entityType); LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, entityType);
//This is used to prevent XP gains for damaging this entity //This is used to prevent XP gains for damaging this entity
@ -459,7 +459,7 @@ public class TamingManager extends SkillManager {
ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity); ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity);
} }
private void spawnHorse(Location spawnLocation) { private void spawnHorse(@NotNull Location spawnLocation) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, EntityType.HORSE); LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
applyMetaDataToCOTWEntity(callOfWildEntity); applyMetaDataToCOTWEntity(callOfWildEntity);
@ -485,12 +485,12 @@ public class TamingManager extends SkillManager {
ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity); ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity);
} }
private void setBaseCOTWEntityProperties(LivingEntity callOfWildEntity) { private void setBaseCOTWEntityProperties(@NotNull LivingEntity callOfWildEntity) {
((Tameable) callOfWildEntity).setOwner(getPlayer()); ((Tameable) callOfWildEntity).setOwner(getPlayer());
callOfWildEntity.setRemoveWhenFarAway(false); callOfWildEntity.setRemoveWhenFarAway(false);
} }
private void applyMetaDataToCOTWEntity(LivingEntity summonedEntity) { private void applyMetaDataToCOTWEntity(@NotNull LivingEntity summonedEntity) {
//This helps identify the entity as being summoned by COTW //This helps identify the entity as being summoned by COTW
mcMMO.getCompatibilityManager().getPersistentDataLayer().flagMetadata(MobMetaFlagType.COTW_SUMMONED_MOB, summonedEntity); mcMMO.getCompatibilityManager().getPersistentDataLayer().flagMetadata(MobMetaFlagType.COTW_SUMMONED_MOB, summonedEntity);
} }
@ -500,7 +500,7 @@ public class TamingManager extends SkillManager {
* @param itemStack target ItemStack * @param itemStack target ItemStack
* @return true if it is used for any COTW * @return true if it is used for any COTW
*/ */
public boolean isCOTWItem(ItemStack itemStack) { public boolean isCOTWItem(@NotNull ItemStack itemStack) {
return summoningItems.containsKey(itemStack.getType()); return summoningItems.containsKey(itemStack.getType());
} }
@ -513,7 +513,7 @@ public class TamingManager extends SkillManager {
} }
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update //TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
private void addToTracker(LivingEntity livingEntity, CallOfTheWildType callOfTheWildType) { private void addToTracker(@NotNull LivingEntity livingEntity, @NotNull CallOfTheWildType callOfTheWildType) {
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity, callOfTheWildType, this); TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity, callOfTheWildType, this);
playerSummonedEntities.get(callOfTheWildType).add(trackedEntity); playerSummonedEntities.get(callOfTheWildType).add(trackedEntity);
@ -525,7 +525,7 @@ public class TamingManager extends SkillManager {
} }
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update //TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
public void removeFromTracker(TrackedTamingEntity trackedEntity) { public void removeFromTracker(@NotNull TrackedTamingEntity trackedEntity) {
playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).remove(trackedEntity); playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).remove(trackedEntity);
NotificationManager.sendPlayerInformationChatOnly(getPlayer(), "Taming.Summon.COTW.TimeExpired", StringUtils.getPrettyEntityTypeString(trackedEntity.getLivingEntity().getType())); NotificationManager.sendPlayerInformationChatOnly(getPlayer(), "Taming.Summon.COTW.TimeExpired", StringUtils.getPrettyEntityTypeString(trackedEntity.getLivingEntity().getType()));
@ -543,7 +543,7 @@ public class TamingManager extends SkillManager {
} }
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update //TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
private ArrayList<TrackedTamingEntity> getValidTrackedEntities(CallOfTheWildType callOfTheWildType) { private @NotNull ArrayList<TrackedTamingEntity> getValidTrackedEntities(@NotNull CallOfTheWildType callOfTheWildType) {
ArrayList<TrackedTamingEntity> validTrackedEntities = new ArrayList<>(); ArrayList<TrackedTamingEntity> validTrackedEntities = new ArrayList<>();
for(TrackedTamingEntity trackedTamingEntity : getTrackedEntities(callOfTheWildType)) { for(TrackedTamingEntity trackedTamingEntity : getTrackedEntities(callOfTheWildType)) {

View File

@ -138,7 +138,7 @@ public class UnarmedManager extends SkillManager {
* @param damage The amount of damage initially dealt by the event * @param damage The amount of damage initially dealt by the event
*/ */
public double berserkDamage(double damage) { public double berserkDamage(double damage) {
damage = ((damage * Unarmed.berserkDamageModifier) * mmoPlayer.getAttackStrength()) - damage; damage = ((damage * Unarmed.berserkDamageModifier)) - damage;
return damage; return damage;
} }

View File

@ -102,22 +102,22 @@ public final class CombatUtils {
//Add Stab Damage //Add Stab Damage
if(swordsManager.canUseStab()) if(swordsManager.canUseStab())
{ {
finalDamage+=(swordsManager.getStabDamage() * mmoPlayer.getAttackStrength()); finalDamage+=(swordsManager.getStabDamage());
} }
if (swordsManager.canUseSerratedStrike()) { if (swordsManager.canUseSerratedStrike()) {
swordsManager.serratedStrikes(target, initialDamage, modifiers); swordsManager.serratedStrikes(target, initialDamage, modifiers);
} }
if(canUseLimitBreak(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) if(canUseLimitBreak(mmoPlayer, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))
{ {
finalDamage+=(getLimitBreakDamage(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK) * mmoPlayer.getAttackStrength()); finalDamage+=(getLimitBreakDamage(mmoPlayer, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK));
} }
applyScaledModifiers(initialDamage, finalDamage, event); applyScaledModifiers(initialDamage, finalDamage, event);
processCombatXP(mmoPlayer, target, PrimarySkillType.SWORDS); processCombatXP(mmoPlayer, target, PrimarySkillType.SWORDS);
printFinalDamageDebug(player, event, mcMMOPlayer); printFinalDamageDebug(player, event, mmoPlayer);
} }
public static void processTridentCombat(LivingEntity target, Player player, EntityDamageByEntityEvent entityDamageByEntityEvent) { public static void processTridentCombat(LivingEntity target, Player player, EntityDamageByEntityEvent entityDamageByEntityEvent) {
@ -190,18 +190,18 @@ public final class CombatUtils {
} }
if (axesManager.canCriticalHit(target)) { if (axesManager.canCriticalHit(target)) {
finalDamage+=(axesManager.criticalHit(target, finalDamage) * mmoPlayer.getAttackStrength()); finalDamage+=(axesManager.criticalHit(target, finalDamage));
} }
if(canUseLimitBreak(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK)) if(canUseLimitBreak(mmoPlayer, target, SubSkillType.AXES_AXES_LIMIT_BREAK))
{ {
finalDamage+=(getLimitBreakDamage(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK) * mmoPlayer.getAttackStrength()); finalDamage+=(getLimitBreakDamage(mmoPlayer, target, SubSkillType.AXES_AXES_LIMIT_BREAK));
} }
applyScaledModifiers(initialDamage, finalDamage, event); applyScaledModifiers(initialDamage, finalDamage, event);
processCombatXP(mmoPlayer, target, PrimarySkillType.AXES); processCombatXP(mmoPlayer, target, PrimarySkillType.AXES);
printFinalDamageDebug(player, event, mcMMOPlayer); printFinalDamageDebug(player, event, mmoPlayer);
} }
private static void processUnarmedCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) { private static void processUnarmedCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
@ -226,20 +226,20 @@ public final class CombatUtils {
} }
if (unarmedManager.canUseSteelArm()) { if (unarmedManager.canUseSteelArm()) {
finalDamage+=(unarmedManager.calculateSteelArmStyleDamage() * mmoPlayer.getAttackStrength()); finalDamage+=(unarmedManager.calculateSteelArmStyleDamage());
} }
if (unarmedManager.canUseBerserk()) { if (unarmedManager.canUseBerserk()) {
finalDamage+=(unarmedManager.berserkDamage(finalDamage) * mmoPlayer.getAttackStrength()); finalDamage+=(unarmedManager.berserkDamage(finalDamage));
} }
if (unarmedManager.canDisarm(target)) { if (unarmedManager.canDisarm(target)) {
unarmedManager.disarmCheck((Player) target); unarmedManager.disarmCheck((Player) target);
} }
if(canUseLimitBreak(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) if(canUseLimitBreak(mmoPlayer, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))
{ {
finalDamage+=(getLimitBreakDamage(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK) * mmoPlayer.getAttackStrength()); finalDamage+=(getLimitBreakDamage(mmoPlayer, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK));
} }
applyScaledModifiers(initialDamage, finalDamage, event); applyScaledModifiers(initialDamage, finalDamage, event);
@ -309,16 +309,16 @@ public final class CombatUtils {
archeryManager.retrieveArrows(target, arrow); archeryManager.retrieveArrows(target, arrow);
} }
if(canUseLimitBreak(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) if(canUseLimitBreak(mmoPlayer, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))
{ {
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK); finalDamage+=getLimitBreakDamage(mmoPlayer, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
} }
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow); double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
// double forceMultiplier = 1.0; //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires double forceMultiplier = 1.0; //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
// if(arrow.hasMetadata(mcMMO.bowForceKey)) if(arrow.hasMetadata(mcMMO.bowForceKey))
// forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble(); forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
applyScaledModifiers(initialDamage, finalDamage, event); applyScaledModifiers(initialDamage, finalDamage, event);
@ -357,9 +357,9 @@ public final class CombatUtils {
} }
} }
if(canUseLimitBreak(player, target, SubSkillType.CROSSBOWS_CROSSBOWS_LIMIT_BREAK)) if(canUseLimitBreak(mmoPlayer, target, SubSkillType.CROSSBOWS_CROSSBOWS_LIMIT_BREAK))
{ {
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.CROSSBOWS_CROSSBOWS_LIMIT_BREAK); finalDamage+=getLimitBreakDamage(mmoPlayer, target, SubSkillType.CROSSBOWS_CROSSBOWS_LIMIT_BREAK);
} }
double distanceMultiplier = crossbowManager.distanceXpBonusMultiplier(target, arrow); double distanceMultiplier = crossbowManager.distanceXpBonusMultiplier(target, arrow);
@ -558,7 +558,7 @@ public final class CombatUtils {
* @param subSkillType the specific limit break skill for calculations * @param subSkillType the specific limit break skill for calculations
* @return the RAW damage bonus from Limit Break which is applied before reductions * @return the RAW damage bonus from Limit Break which is applied before reductions
*/ */
public static int getLimitBreakDamage(@NotNull Player attacker, @NotNull LivingEntity defender, @NotNull SubSkillType subSkillType) { public static int getLimitBreakDamage(@NotNull McMMOPlayer attacker, @NotNull LivingEntity defender, @NotNull SubSkillType subSkillType) {
if(defender instanceof Player) { if(defender instanceof Player) {
Player playerDefender = (Player) defender; Player playerDefender = (Player) defender;
return getLimitBreakDamageAgainstQuality(attacker, subSkillType, getArmorQualityLevel(playerDefender)); return getLimitBreakDamageAgainstQuality(attacker, subSkillType, getArmorQualityLevel(playerDefender));
@ -575,7 +575,7 @@ public final class CombatUtils {
* @param armorQualityLevel Armor quality level * @param armorQualityLevel Armor quality level
* @return the RAW damage boost after its been mutated by armor quality * @return the RAW damage boost after its been mutated by armor quality
*/ */
public static int getLimitBreakDamageAgainstQuality(@NotNull Player attacker, @NotNull SubSkillType subSkillType, int armorQualityLevel) { public static int getLimitBreakDamageAgainstQuality(@NotNull McMMOPlayer attacker, @NotNull SubSkillType subSkillType, int armorQualityLevel) {
int rawDamageBoost = RankUtils.getRank(attacker, subSkillType); int rawDamageBoost = RankUtils.getRank(attacker, subSkillType);
if(armorQualityLevel <= 4) { if(armorQualityLevel <= 4) {
@ -616,14 +616,14 @@ public final class CombatUtils {
} }
/** /**
* Checks if player has access to their weapons limit break * Checks if mmoPlayer has access to their weapons limit break
* @param player target entity * @param mmoPlayer target entity
* @return true if the player has access to the limit break * @return true if the mmoPlayer has access to the limit break
*/ */
public static boolean canUseLimitBreak(@NotNull Player player, LivingEntity target, @NotNull SubSkillType subSkillType) { public static boolean canUseLimitBreak(@NotNull McMMOPlayer mmoPlayer, LivingEntity target, @NotNull SubSkillType subSkillType) {
if(target instanceof Player || AdvancedConfig.getInstance().canApplyLimitBreakPVE()) { if(target instanceof Player || AdvancedConfig.getInstance().canApplyLimitBreakPVE()) {
return RankUtils.hasUnlockedSubskill(player, subSkillType) return RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType)
&& Permissions.isSubSkillEnabled(player, subSkillType); && Permissions.isSubSkillEnabled(mmoPlayer.getPlayer(), subSkillType);
} else { } else {
return false; return false;
} }