mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-02 12:35:27 +02:00
Update code style
This commit is contained in:
@@ -37,13 +37,14 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CombatUtils {
|
||||
private CombatUtils() {}
|
||||
private CombatUtils() {
|
||||
}
|
||||
|
||||
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
||||
if (event.getCause() == DamageCause.THORNS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||
double initialDamage = event.getDamage();
|
||||
@@ -55,26 +56,23 @@ public final class CombatUtils {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.SWORDS);
|
||||
}
|
||||
|
||||
if(target.getHealth() - event.getFinalDamage() >= 1)
|
||||
{
|
||||
if (target.getHealth() - event.getFinalDamage() >= 1) {
|
||||
if (swordsManager.canUseRupture()) {
|
||||
swordsManager.ruptureCheck(target);
|
||||
}
|
||||
}
|
||||
|
||||
//Add Stab Damage
|
||||
if(swordsManager.canUseStab())
|
||||
{
|
||||
finalDamage+=swordsManager.getStabDamage();
|
||||
if (swordsManager.canUseStab()) {
|
||||
finalDamage += swordsManager.getStabDamage();
|
||||
}
|
||||
|
||||
if (swordsManager.canUseSerratedStrike()) {
|
||||
swordsManager.serratedStrikes(target, initialDamage, modifiers);
|
||||
}
|
||||
|
||||
if(canUseLimitBreak(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK);
|
||||
if (canUseLimitBreak(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
@@ -85,7 +83,7 @@ public final class CombatUtils {
|
||||
if (event.getCause() == DamageCause.THORNS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
Map<DamageModifier, Double> modifiers = getModifiers(event);
|
||||
@@ -98,14 +96,13 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (axesManager.canUseAxeMastery()) {
|
||||
finalDamage+=axesManager.axeMastery();
|
||||
finalDamage += axesManager.axeMastery();
|
||||
}
|
||||
|
||||
if (axesManager.canImpact(target)) {
|
||||
axesManager.impactCheck(target);
|
||||
}
|
||||
else if (axesManager.canGreaterImpact(target)) {
|
||||
finalDamage+=axesManager.greaterImpact(target);
|
||||
} else if (axesManager.canGreaterImpact(target)) {
|
||||
finalDamage += axesManager.greaterImpact(target);
|
||||
}
|
||||
|
||||
if (axesManager.canUseSkullSplitter(target)) {
|
||||
@@ -113,12 +110,11 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (axesManager.canCriticalHit(target)) {
|
||||
finalDamage+=axesManager.criticalHit(target, finalDamage);
|
||||
finalDamage += axesManager.criticalHit(target, finalDamage);
|
||||
}
|
||||
|
||||
if(canUseLimitBreak(player, SubSkillType.AXES_AXES_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK);
|
||||
if (canUseLimitBreak(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
@@ -140,24 +136,22 @@ public final class CombatUtils {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
|
||||
}
|
||||
|
||||
if(unarmedManager.isPunchingCooldownOver())
|
||||
{
|
||||
if (unarmedManager.isPunchingCooldownOver()) {
|
||||
//Only execute bonuses if the player is not spamming
|
||||
if (unarmedManager.canUseIronArm()) {
|
||||
finalDamage+=unarmedManager.ironArm();
|
||||
finalDamage += unarmedManager.ironArm();
|
||||
}
|
||||
|
||||
if (unarmedManager.canUseBerserk()) {
|
||||
finalDamage+=unarmedManager.berserkDamage(finalDamage);
|
||||
finalDamage += unarmedManager.berserkDamage(finalDamage);
|
||||
}
|
||||
|
||||
if (unarmedManager.canDisarm(target)) {
|
||||
unarmedManager.disarmCheck((Player) target);
|
||||
}
|
||||
|
||||
if(canUseLimitBreak(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK);
|
||||
if (canUseLimitBreak(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,11 +174,11 @@ public final class CombatUtils {
|
||||
tamingManager.pummel(target, wolf);
|
||||
|
||||
if (tamingManager.canUseSharpenedClaws()) {
|
||||
finalDamage+=tamingManager.getSharpenedClawsDamage();
|
||||
finalDamage += tamingManager.getSharpenedClawsDamage();
|
||||
}
|
||||
|
||||
if (tamingManager.canUseGore()) {
|
||||
finalDamage+=tamingManager.gore(target, initialDamage);
|
||||
finalDamage += tamingManager.gore(target, initialDamage);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
@@ -196,7 +190,7 @@ public final class CombatUtils {
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||
|
||||
|
||||
double finalDamage = event.getDamage();
|
||||
|
||||
if (target instanceof Player && PrimarySkillType.UNARMED.getPVPEnabled()) {
|
||||
@@ -212,20 +206,19 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (archeryManager.canSkillShot()) {
|
||||
finalDamage+=archeryManager.skillShot(initialDamage);
|
||||
finalDamage += archeryManager.skillShot(initialDamage);
|
||||
}
|
||||
|
||||
if (archeryManager.canDaze(target)) {
|
||||
finalDamage+=archeryManager.daze((Player) target);
|
||||
finalDamage += archeryManager.daze((Player) target);
|
||||
}
|
||||
|
||||
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {
|
||||
archeryManager.retrieveArrows(target);
|
||||
}
|
||||
|
||||
if(canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
|
||||
if (canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
|
||||
@@ -305,8 +298,7 @@ public final class CombatUtils {
|
||||
if (PrimarySkillType.SWORDS.getPermissions(player)) {
|
||||
processSwordCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isAxe(heldItem)) {
|
||||
} else if (ItemUtils.isAxe(heldItem)) {
|
||||
if (!PrimarySkillType.AXES.shouldProcess(target)) {
|
||||
return;
|
||||
}
|
||||
@@ -314,8 +306,7 @@ public final class CombatUtils {
|
||||
if (PrimarySkillType.AXES.getPermissions(player)) {
|
||||
processAxeCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isUnarmed(heldItem)) {
|
||||
} else if (ItemUtils.isUnarmed(heldItem)) {
|
||||
if (!PrimarySkillType.UNARMED.shouldProcess(target)) {
|
||||
return;
|
||||
}
|
||||
@@ -324,9 +315,7 @@ public final class CombatUtils {
|
||||
processUnarmedCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (entityType == EntityType.WOLF) {
|
||||
} else if (entityType == EntityType.WOLF) {
|
||||
Wolf wolf = (Wolf) damager;
|
||||
AnimalTamer tamer = wolf.getOwner();
|
||||
|
||||
@@ -337,8 +326,7 @@ public final class CombatUtils {
|
||||
processTamingCombat(target, master, wolf, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (entityType == EntityType.ARROW) {
|
||||
} else if (entityType == EntityType.ARROW) {
|
||||
Arrow arrow = (Arrow) damager;
|
||||
ProjectileSource projectileSource = arrow.getShooter();
|
||||
|
||||
@@ -364,6 +352,7 @@ public final class CombatUtils {
|
||||
|
||||
/**
|
||||
* Checks if player has access to their weapons limit break
|
||||
*
|
||||
* @param player target player
|
||||
* @return true if the player has access to the limit break
|
||||
*/
|
||||
@@ -386,8 +375,8 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -398,8 +387,8 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
public static void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) {
|
||||
@@ -414,8 +403,8 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -424,7 +413,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if(canDamage(attacker, target, cause, damage))
|
||||
if (canDamage(attacker, target, cause, damage))
|
||||
target.damage(damage);
|
||||
}
|
||||
|
||||
@@ -437,11 +426,9 @@ public final class CombatUtils {
|
||||
|
||||
double newHealth = Math.max(0, target.getHealth() - incDmg);
|
||||
|
||||
if(newHealth == 0)
|
||||
{
|
||||
if (newHealth == 0) {
|
||||
target.damage(9999, attacker);
|
||||
}
|
||||
else
|
||||
} else
|
||||
target.setHealth(newHealth);
|
||||
}
|
||||
|
||||
@@ -487,9 +474,9 @@ public final class CombatUtils {
|
||||
* Apply Area-of-Effect ability actions.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param damage The initial damage amount
|
||||
* @param type The type of skill being used
|
||||
* @param target The defending entity
|
||||
* @param damage The initial damage amount
|
||||
* @param type The type of skill being used
|
||||
*/
|
||||
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, PrimarySkillType type) {
|
||||
int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
|
||||
@@ -510,7 +497,7 @@ public final class CombatUtils {
|
||||
switch (type) {
|
||||
case SWORDS:
|
||||
if (entity instanceof Player) {
|
||||
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
|
||||
NotificationManager.sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
|
||||
}
|
||||
|
||||
UserManager.getPlayer(attacker).getSwordsManager().ruptureCheck(target);
|
||||
@@ -518,7 +505,7 @@ public final class CombatUtils {
|
||||
|
||||
case AXES:
|
||||
if (entity instanceof Player) {
|
||||
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck");
|
||||
NotificationManager.sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck");
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -539,8 +526,8 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Start the task that gives combat XP.
|
||||
*
|
||||
* @param mcMMOPlayer The attacking player
|
||||
* @param target The defending entity
|
||||
* @param mcMMOPlayer The attacking player
|
||||
* @param target The defending entity
|
||||
* @param primarySkillType The skill being used
|
||||
*/
|
||||
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
|
||||
@@ -558,8 +545,7 @@ public final class CombatUtils {
|
||||
if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
baseXP = 20 * ExperienceConfig.getInstance().getPlayerVersusPlayerXP();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*if (mcMMO.getModManager().isCustomEntity(target)) {
|
||||
baseXP = mcMMO.getModManager().getEntity(target).getXpMultiplier();
|
||||
}*/
|
||||
@@ -567,29 +553,21 @@ public final class CombatUtils {
|
||||
if (target instanceof Animals) {
|
||||
EntityType type = target.getType();
|
||||
baseXP = ExperienceConfig.getInstance().getAnimalsXP(type);
|
||||
}
|
||||
else if (target instanceof Monster)
|
||||
{
|
||||
} else if (target instanceof Monster) {
|
||||
EntityType type = target.getType();
|
||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EntityType type = target.getType();
|
||||
|
||||
if (ExperienceConfig.getInstance().hasCombatXP(type)) {
|
||||
if (type == EntityType.IRON_GOLEM)
|
||||
{
|
||||
if (type == EntityType.IRON_GOLEM) {
|
||||
if (!((IronGolem) target).isPlayerCreated()) {
|
||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
baseXP = 1.0;
|
||||
//mcMMO.getModManager().addCustomEntity(target);
|
||||
}
|
||||
@@ -627,7 +605,7 @@ public final class CombatUtils {
|
||||
Player defender = (Player) entity;
|
||||
|
||||
//TODO: NPC Interaction?
|
||||
if(UserManager.getPlayer(defender) == null)
|
||||
if (UserManager.getPlayer(defender) == null)
|
||||
return true;
|
||||
|
||||
if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getGodMode()) {
|
||||
@@ -642,7 +620,7 @@ public final class CombatUtils {
|
||||
if (!player.canSee(defender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Spectators should not be affected
|
||||
if (defender.getGameMode() == GameMode.SPECTATOR) {
|
||||
return false;
|
||||
@@ -652,8 +630,7 @@ public final class CombatUtils {
|
||||
if (getFakeDamageFinalResult(player, entity, 1.0) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (entity instanceof Tameable) {
|
||||
} else if (entity instanceof Tameable) {
|
||||
if (isFriendlyPet(player, (Tameable) entity)) {
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
@@ -670,7 +647,7 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Checks to see if an entity is currently invincible.
|
||||
*
|
||||
* @param entity The {@link LivingEntity} to check
|
||||
* @param entity The {@link LivingEntity} to check
|
||||
* @param eventDamage The damage from the event the entity is involved in
|
||||
* @return true if the entity is invincible, false otherwise
|
||||
*/
|
||||
@@ -686,7 +663,7 @@ public final class CombatUtils {
|
||||
* Checks to see if an entity is currently friendly toward a given player.
|
||||
*
|
||||
* @param attacker The player to check.
|
||||
* @param pet The entity to check.
|
||||
* @param pet The entity to check.
|
||||
* @return true if the entity is friendly, false otherwise
|
||||
*/
|
||||
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
|
||||
@@ -810,17 +787,13 @@ public final class CombatUtils {
|
||||
|
||||
if (ItemUtils.isWoodTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(inHand)) {
|
||||
} else if (ItemUtils.isStoneTool(inHand)) {
|
||||
tier = 2;
|
||||
}
|
||||
else if (ItemUtils.isIronTool(inHand)) {
|
||||
} else if (ItemUtils.isIronTool(inHand)) {
|
||||
tier = 3;
|
||||
}
|
||||
else if (ItemUtils.isGoldTool(inHand)) {
|
||||
} else if (ItemUtils.isGoldTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if (ItemUtils.isDiamondTool(inHand)) {
|
||||
} else if (ItemUtils.isDiamondTool(inHand)) {
|
||||
tier = 4;
|
||||
}
|
||||
/*else if (mcMMO.getModManager().isCustomTool(inHand)) {
|
||||
|
@@ -12,7 +12,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public final class ParticleEffectUtils {
|
||||
|
||||
private ParticleEffectUtils() {}
|
||||
private ParticleEffectUtils() {
|
||||
}
|
||||
|
||||
public static void playBleedEffect(LivingEntity livingEntity) {
|
||||
if (!MainConfig.getInstance().getBleedEffectEnabled()) {
|
||||
|
@@ -9,16 +9,15 @@ public final class PerksUtils {
|
||||
private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
||||
private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
||||
|
||||
private PerksUtils() {}
|
||||
private PerksUtils() {
|
||||
}
|
||||
|
||||
public static int handleCooldownPerks(Player player, int cooldown) {
|
||||
if (Permissions.halvedCooldowns(player)) {
|
||||
cooldown *= 0.5;
|
||||
}
|
||||
else if (Permissions.thirdedCooldowns(player)) {
|
||||
} else if (Permissions.thirdedCooldowns(player)) {
|
||||
cooldown *= (2.0 / 3.0);
|
||||
}
|
||||
else if (Permissions.quarteredCooldowns(player)) {
|
||||
} else if (Permissions.quarteredCooldowns(player)) {
|
||||
cooldown *= 0.75;
|
||||
}
|
||||
|
||||
@@ -32,11 +31,9 @@ public final class PerksUtils {
|
||||
|
||||
if (Permissions.twelveSecondActivationBoost(player)) {
|
||||
ticks += 12;
|
||||
}
|
||||
else if (Permissions.eightSecondActivationBoost(player)) {
|
||||
} else if (Permissions.eightSecondActivationBoost(player)) {
|
||||
ticks += 8;
|
||||
}
|
||||
else if (Permissions.fourSecondActivationBoost(player)) {
|
||||
} else if (Permissions.fourSecondActivationBoost(player)) {
|
||||
ticks += 4;
|
||||
}
|
||||
|
||||
@@ -46,23 +43,17 @@ public final class PerksUtils {
|
||||
public static float handleXpPerks(Player player, float xp, PrimarySkillType skill) {
|
||||
if (Permissions.customXpBoost(player, skill)) {
|
||||
xp *= ExperienceConfig.getInstance().getCustomXpPerkBoost();
|
||||
}
|
||||
else if (Permissions.quadrupleXp(player, skill)) {
|
||||
} else if (Permissions.quadrupleXp(player, skill)) {
|
||||
xp *= 4;
|
||||
}
|
||||
else if (Permissions.tripleXp(player, skill)) {
|
||||
} else if (Permissions.tripleXp(player, skill)) {
|
||||
xp *= 3;
|
||||
}
|
||||
else if (Permissions.doubleAndOneHalfXp(player, skill)) {
|
||||
} else if (Permissions.doubleAndOneHalfXp(player, skill)) {
|
||||
xp *= 2.5;
|
||||
}
|
||||
else if (Permissions.doubleXp(player, skill)) {
|
||||
} else if (Permissions.doubleXp(player, skill)) {
|
||||
xp *= 2;
|
||||
}
|
||||
else if (Permissions.oneAndOneHalfXp(player, skill)) {
|
||||
} else if (Permissions.oneAndOneHalfXp(player, skill)) {
|
||||
xp *= 1.5;
|
||||
}
|
||||
else if (Permissions.oneAndOneTenthXp(player, skill)) {
|
||||
} else if (Permissions.oneAndOneTenthXp(player, skill)) {
|
||||
xp *= 1.1;
|
||||
}
|
||||
|
||||
@@ -73,7 +64,7 @@ public final class PerksUtils {
|
||||
* Calculate activation chance for a skill.
|
||||
*
|
||||
* @param player Player to check the activation chance for
|
||||
* @param skill PrimarySkillType to check the activation chance of
|
||||
* @param skill PrimarySkillType to check the activation chance of
|
||||
* @return the activation chance with "lucky perk" accounted for
|
||||
*/
|
||||
public static int handleLuckyPerks(Player player, PrimarySkillType skill) {
|
||||
|
@@ -19,27 +19,23 @@ public class RankUtils {
|
||||
private static int count = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin plugin instance ref
|
||||
* @param mcMMOPlayer target player
|
||||
* @param plugin plugin instance ref
|
||||
* @param mcMMOPlayer target player
|
||||
* @param primarySkillType
|
||||
* @param newLevel the new level of this skill
|
||||
* @param newLevel the new level of this skill
|
||||
*/
|
||||
public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel)
|
||||
{
|
||||
for(SubSkillType subSkillType : primarySkillType.getSkillAbilities())
|
||||
{
|
||||
public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel) {
|
||||
for (SubSkillType subSkillType : primarySkillType.getSkillAbilities()) {
|
||||
int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType);
|
||||
|
||||
HashMap<Integer, Integer> innerMap = subSkillRanks.get(subSkillType.toString());
|
||||
|
||||
//If the skill doesn't have registered ranks gtfo
|
||||
if(innerMap == null || innerMap.get(playerRankInSkill) == null)
|
||||
if (innerMap == null || innerMap.get(playerRankInSkill) == null)
|
||||
continue;
|
||||
|
||||
//The players level is the exact level requirement for this skill
|
||||
if(newLevel == innerMap.get(playerRankInSkill))
|
||||
{
|
||||
if (newLevel == innerMap.get(playerRankInSkill)) {
|
||||
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
|
||||
|
||||
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100));
|
||||
@@ -49,32 +45,27 @@ public class RankUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetUnlockDelayTimer()
|
||||
{
|
||||
public static void resetUnlockDelayTimer() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
/* NEW SYSTEM */
|
||||
private static void addRanks(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
private static void addRanks(AbstractSubSkill abstractSubSkill) {
|
||||
//Fill out the rank array
|
||||
for(int i = 0; i < abstractSubSkill.getNumRanks(); i++)
|
||||
{
|
||||
for (int i = 0; i < abstractSubSkill.getNumRanks(); i++) {
|
||||
//This adds the highest ranks first
|
||||
addRank(abstractSubSkill, abstractSubSkill.getNumRanks()-i);
|
||||
addRank(abstractSubSkill, abstractSubSkill.getNumRanks() - i);
|
||||
|
||||
//TODO: Remove debug code
|
||||
/*System.out.println("DEBUG: Adding rank "+(numRanks-i)+" to "+subSkillType.toString());*/
|
||||
}
|
||||
}
|
||||
|
||||
private static void addRanks(SubSkillType subSkillType)
|
||||
{
|
||||
private static void addRanks(SubSkillType subSkillType) {
|
||||
//Fill out the rank array
|
||||
for(int i = 0; i < subSkillType.getNumRanks(); i++)
|
||||
{
|
||||
for (int i = 0; i < subSkillType.getNumRanks(); i++) {
|
||||
//This adds the highest ranks first
|
||||
addRank(subSkillType, subSkillType.getNumRanks()-i);
|
||||
addRank(subSkillType, subSkillType.getNumRanks() - i);
|
||||
|
||||
//TODO: Remove debug code
|
||||
/*System.out.println("DEBUG: Adding rank "+(numRanks-i)+" to "+subSkillType.toString());*/
|
||||
@@ -84,27 +75,24 @@ public class RankUtils {
|
||||
/**
|
||||
* Populates the ranks for every skill we know about
|
||||
*/
|
||||
public static void populateRanks()
|
||||
{
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
public static void populateRanks() {
|
||||
for (SubSkillType subSkillType : SubSkillType.values()) {
|
||||
addRanks(subSkillType);
|
||||
}
|
||||
|
||||
for(AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList())
|
||||
{
|
||||
for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
|
||||
addRanks(abstractSubSkill);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the player has unlocked the first rank in target subskill
|
||||
* @param player the player
|
||||
*
|
||||
* @param player the player
|
||||
* @param subSkillType the target subskill
|
||||
* @return true if the player has at least one rank in the skill
|
||||
*/
|
||||
public static boolean hasUnlockedSubskill(Player player, SubSkillType subSkillType)
|
||||
{
|
||||
public static boolean hasUnlockedSubskill(Player player, SubSkillType subSkillType) {
|
||||
int curRank = getRank(player, subSkillType);
|
||||
|
||||
//-1 means the skill has no unlockable levels and is therefor unlocked
|
||||
@@ -113,12 +101,12 @@ public class RankUtils {
|
||||
|
||||
/**
|
||||
* Returns whether or not the player has unlocked the first rank in target subskill
|
||||
* @param player the player
|
||||
*
|
||||
* @param player the player
|
||||
* @param abstractSubSkill the target subskill
|
||||
* @return true if the player has at least one rank in the skill
|
||||
*/
|
||||
public static boolean hasUnlockedSubskill(Player player, AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public static boolean hasUnlockedSubskill(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
int curRank = getRank(player, abstractSubSkill);
|
||||
|
||||
//-1 means the skill has no unlockable levels and is therefor unlocked
|
||||
@@ -127,69 +115,68 @@ public class RankUtils {
|
||||
|
||||
/**
|
||||
* Returns whether or not the player has reached the specified rank in target subskill
|
||||
* @param rank the target rank
|
||||
* @param player the player
|
||||
*
|
||||
* @param rank the target rank
|
||||
* @param player the player
|
||||
* @param subSkillType the target subskill
|
||||
* @return true if the player is at least that rank in this subskill
|
||||
*/
|
||||
public static boolean hasReachedRank(int rank, Player player, SubSkillType subSkillType)
|
||||
{
|
||||
public static boolean hasReachedRank(int rank, Player player, SubSkillType subSkillType) {
|
||||
return getRank(player, subSkillType) >= rank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the player has reached the specified rank in target subskill
|
||||
* @param rank the target rank
|
||||
* @param player the player
|
||||
*
|
||||
* @param rank the target rank
|
||||
* @param player the player
|
||||
* @param abstractSubSkill the target subskill
|
||||
* @return true if the player is at least that rank in this subskill
|
||||
*/
|
||||
public static boolean hasReachedRank(int rank, Player player, AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public static boolean hasReachedRank(int rank, Player player, AbstractSubSkill abstractSubSkill) {
|
||||
return getRank(player, abstractSubSkill) >= rank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current rank of the subskill for the player
|
||||
* @param player The player in question
|
||||
*
|
||||
* @param player The player in question
|
||||
* @param subSkillType Target subskill
|
||||
* @return The rank the player currently has achieved in this skill. -1 for skills without ranks.
|
||||
*/
|
||||
public static int getRank(Player player, SubSkillType subSkillType)
|
||||
{
|
||||
public static int getRank(Player player, SubSkillType subSkillType) {
|
||||
String skillName = subSkillType.toString();
|
||||
int numRanks = subSkillType.getNumRanks();
|
||||
|
||||
if(subSkillRanks == null)
|
||||
if (subSkillRanks == null)
|
||||
subSkillRanks = new HashMap<>();
|
||||
|
||||
if(numRanks == 0)
|
||||
if (numRanks == 0)
|
||||
return -1; //-1 Means the skill doesn't have ranks
|
||||
|
||||
if(subSkillRanks.get(skillName) == null && numRanks > 0)
|
||||
if (subSkillRanks.get(skillName) == null && numRanks > 0)
|
||||
addRanks(subSkillType);
|
||||
|
||||
//Get our rank map
|
||||
HashMap<Integer, Integer> rankMap = subSkillRanks.get(skillName);
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if (UserManager.getPlayer(player) == null)
|
||||
return 0;
|
||||
|
||||
//Skill level of parent skill
|
||||
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(subSkillType.getParentSkill());
|
||||
|
||||
for(int i = 0; i < numRanks; i++)
|
||||
{
|
||||
for (int i = 0; i < numRanks; i++) {
|
||||
//Compare against the highest to lowest rank in that order
|
||||
int rank = numRanks-i;
|
||||
int rank = numRanks - i;
|
||||
int unlockLevel = getRankUnlockLevel(subSkillType, rank);
|
||||
|
||||
//If we check all ranks and still cannot unlock the skill, we return rank 0
|
||||
if(rank == 0)
|
||||
if (rank == 0)
|
||||
return 0;
|
||||
|
||||
//True if our skill level can unlock the current rank
|
||||
if(currentSkillLevel >= unlockLevel)
|
||||
if (currentSkillLevel >= unlockLevel)
|
||||
return rank;
|
||||
}
|
||||
|
||||
@@ -198,45 +185,44 @@ public class RankUtils {
|
||||
|
||||
/**
|
||||
* Gets the current rank of the subskill for the player
|
||||
* @param player The player in question
|
||||
*
|
||||
* @param player The player in question
|
||||
* @param abstractSubSkill Target subskill
|
||||
* @return The rank the player currently has achieved in this skill. -1 for skills without ranks.
|
||||
*/
|
||||
public static int getRank(Player player, AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public static int getRank(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
String skillName = abstractSubSkill.getConfigKeyName();
|
||||
int numRanks = abstractSubSkill.getNumRanks();
|
||||
|
||||
if(subSkillRanks == null)
|
||||
if (subSkillRanks == null)
|
||||
subSkillRanks = new HashMap<>();
|
||||
|
||||
if(numRanks == 0)
|
||||
if (numRanks == 0)
|
||||
return -1; //-1 Means the skill doesn't have ranks
|
||||
|
||||
if(subSkillRanks.get(skillName) == null && numRanks > 0)
|
||||
if (subSkillRanks.get(skillName) == null && numRanks > 0)
|
||||
addRanks(abstractSubSkill);
|
||||
|
||||
//Get our rank map
|
||||
HashMap<Integer, Integer> rankMap = subSkillRanks.get(skillName);
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if (UserManager.getPlayer(player) == null)
|
||||
return 0;
|
||||
|
||||
//Skill level of parent skill
|
||||
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill());
|
||||
|
||||
for(int i = 0; i < numRanks; i++)
|
||||
{
|
||||
for (int i = 0; i < numRanks; i++) {
|
||||
//Compare against the highest to lowest rank in that order
|
||||
int rank = numRanks-i;
|
||||
int rank = numRanks - i;
|
||||
int unlockLevel = getRankUnlockLevel(abstractSubSkill, rank);
|
||||
|
||||
//If we check all ranks and still cannot unlock the skill, we return rank 0
|
||||
if(rank == 0)
|
||||
if (rank == 0)
|
||||
return 0;
|
||||
|
||||
//True if our skill level can unlock the current rank
|
||||
if(currentSkillLevel >= unlockLevel)
|
||||
if (currentSkillLevel >= unlockLevel)
|
||||
return rank;
|
||||
}
|
||||
|
||||
@@ -245,11 +231,11 @@ public class RankUtils {
|
||||
|
||||
/**
|
||||
* Adds ranks to our map
|
||||
*
|
||||
* @param abstractSubSkill The subskill to add ranks for
|
||||
* @param rank The rank to add
|
||||
* @param rank The rank to add
|
||||
*/
|
||||
private static void addRank(AbstractSubSkill abstractSubSkill, int rank)
|
||||
{
|
||||
private static void addRank(AbstractSubSkill abstractSubSkill, int rank) {
|
||||
initMaps(abstractSubSkill.getConfigKeyName());
|
||||
|
||||
HashMap<Integer, Integer> rankMap = subSkillRanks.get(abstractSubSkill.getConfigKeyName());
|
||||
@@ -258,8 +244,7 @@ public class RankUtils {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void addRank(SubSkillType subSkillType, int rank)
|
||||
{
|
||||
private static void addRank(SubSkillType subSkillType, int rank) {
|
||||
initMaps(subSkillType.toString());
|
||||
|
||||
HashMap<Integer, Integer> rankMap = subSkillRanks.get(subSkillType.toString());
|
||||
@@ -293,68 +278,65 @@ public class RankUtils {
|
||||
|
||||
/**
|
||||
* Gets the unlock level for a specific rank in a subskill
|
||||
*
|
||||
* @param subSkillType The target subskill
|
||||
* @param rank The target rank
|
||||
* @param rank The target rank
|
||||
* @return The level at which this rank unlocks
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getRankUnlockLevel(SubSkillType subSkillType, int rank)
|
||||
{
|
||||
public static int getRankUnlockLevel(SubSkillType subSkillType, int rank) {
|
||||
return RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, rank);
|
||||
}
|
||||
|
||||
public static int getRankUnlockLevel(AbstractSubSkill abstractSubSkill, int rank)
|
||||
{
|
||||
public static int getRankUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) {
|
||||
return RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, rank);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level at which a skill is unlocked for a player (this is the first rank of a skill)
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @return The unlock requirements for rank 1 in this skill
|
||||
*/
|
||||
public static int getUnlockLevel(SubSkillType subSkillType)
|
||||
{
|
||||
public static int getUnlockLevel(SubSkillType subSkillType) {
|
||||
return RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level at which a skill is unlocked for a player (this is the first rank of a skill)
|
||||
*
|
||||
* @param abstractSubSkill target subskill
|
||||
* @return The unlock requirements for rank 1 in this skill
|
||||
*/
|
||||
public static int getUnlockLevel(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public static int getUnlockLevel(AbstractSubSkill abstractSubSkill) {
|
||||
return RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the highest rank of a subskill
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @return the last rank of a subskill
|
||||
*/
|
||||
public static int getHighestRank(SubSkillType subSkillType)
|
||||
{
|
||||
public static int getHighestRank(SubSkillType subSkillType) {
|
||||
return subSkillType.getNumRanks();
|
||||
}
|
||||
|
||||
public static String getHighestRankStr(SubSkillType subSkillType)
|
||||
{
|
||||
public static String getHighestRankStr(SubSkillType subSkillType) {
|
||||
return String.valueOf(subSkillType.getNumRanks());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the highest rank of a subskill
|
||||
*
|
||||
* @param abstractSubSkill target subskill
|
||||
* @return the last rank of a subskill
|
||||
*/
|
||||
public static int getHighestRank(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public static int getHighestRank(AbstractSubSkill abstractSubSkill) {
|
||||
return abstractSubSkill.getNumRanks();
|
||||
}
|
||||
|
||||
public static int getSuperAbilityUnlockRequirement(SuperAbilityType superAbilityType)
|
||||
{
|
||||
public static int getSuperAbilityUnlockRequirement(SuperAbilityType superAbilityType) {
|
||||
return getRankUnlockLevel(superAbilityType.getSubSkillTypeDefinition(), 1);
|
||||
}
|
||||
}
|
@@ -47,9 +47,8 @@ public class SkillUtils {
|
||||
|
||||
int length;
|
||||
|
||||
if(abilityLengthCap > 0)
|
||||
{
|
||||
length = (int) Math.min(abilityLengthCap, 2 + (skillValue / abilityLengthVar));
|
||||
if (abilityLengthCap > 0) {
|
||||
length = (int) Math.min(abilityLengthCap, 2 + (skillValue / abilityLengthVar));
|
||||
} else {
|
||||
length = 2 + (int) (skillValue / abilityLengthVar);
|
||||
}
|
||||
@@ -60,7 +59,7 @@ public class SkillUtils {
|
||||
length = Math.min(length, maxLength);
|
||||
}
|
||||
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -73,7 +72,7 @@ public class SkillUtils {
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int foodChange = eventFoodLevel - currentFoodLevel;
|
||||
|
||||
foodChange+=curRank;
|
||||
foodChange += curRank;
|
||||
|
||||
return currentFoodLevel + foodChange;
|
||||
}
|
||||
@@ -82,9 +81,8 @@ public class SkillUtils {
|
||||
* Calculate the time remaining until the cooldown expires.
|
||||
*
|
||||
* @param deactivatedTimeStamp Time of deactivation
|
||||
* @param cooldown The length of the cooldown
|
||||
* @param player The Player to check for cooldown perks
|
||||
*
|
||||
* @param cooldown The length of the cooldown
|
||||
* @param player The Player to check for cooldown perks
|
||||
* @return the number of seconds remaining before the cooldown expires
|
||||
*/
|
||||
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
|
||||
@@ -96,8 +94,7 @@ public class SkillUtils {
|
||||
* This does NOT account for cooldown perks!
|
||||
*
|
||||
* @param deactivatedTimeStamp Time of deactivation in seconds
|
||||
* @param cooldown The length of the cooldown in seconds
|
||||
*
|
||||
* @param cooldown The length of the cooldown in seconds
|
||||
* @return true if the cooldown is expired
|
||||
*/
|
||||
public static boolean cooldownExpired(long deactivatedTimeStamp, int cooldown) {
|
||||
@@ -207,8 +204,7 @@ public class SkillUtils {
|
||||
|
||||
if (efficiencyLevel <= AdvancedConfig.getInstance().getEnchantBuff()) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - AdvancedConfig.getInstance().getEnchantBuff(), true);
|
||||
}
|
||||
|
||||
@@ -225,9 +221,9 @@ public class SkillUtils {
|
||||
/**
|
||||
* Modify the durability of an ItemStack.
|
||||
*
|
||||
* @param itemStack The ItemStack which durability should be modified
|
||||
* @param itemStack The ItemStack which durability should be modified
|
||||
* @param durabilityModifier the amount to modify the durability by
|
||||
* @param maxDamageModifier the amount to adjust the max damage by
|
||||
* @param maxDamageModifier the amount to adjust the max damage by
|
||||
*/
|
||||
public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier, double maxDamageModifier) {
|
||||
if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) {
|
||||
@@ -254,26 +250,19 @@ public class SkillUtils {
|
||||
protected static Material getRepairAndSalvageItem(ItemStack inHand) {
|
||||
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
|
||||
return Material.DIAMOND;
|
||||
}
|
||||
else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
|
||||
} else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
|
||||
return Material.GOLD_INGOT;
|
||||
}
|
||||
else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
|
||||
} else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
|
||||
return Material.IRON_INGOT;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(inHand)) {
|
||||
} else if (ItemUtils.isStoneTool(inHand)) {
|
||||
return Material.COBBLESTONE;
|
||||
}
|
||||
else if (ItemUtils.isWoodTool(inHand)) {
|
||||
} else if (ItemUtils.isWoodTool(inHand)) {
|
||||
return Material.OAK_WOOD;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(inHand)) {
|
||||
} else if (ItemUtils.isLeatherArmor(inHand)) {
|
||||
return Material.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(inHand)) {
|
||||
} else if (ItemUtils.isStringTool(inHand)) {
|
||||
return Material.STRING;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -302,8 +291,7 @@ public class SkillUtils {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedRecipe) {
|
||||
} else if (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) {
|
||||
quantity += ingredient.getAmount();
|
||||
|
Reference in New Issue
Block a user