More Javadocs

This commit is contained in:
TfT_02 2013-09-15 21:52:45 +02:00
parent 63b332216e
commit 1a2d586086
9 changed files with 227 additions and 2 deletions

View File

@ -11,34 +11,90 @@ import com.gmail.nossr50.util.player.UserManager;
public final class AbilityAPI {
private AbilityAPI() {}
/**
* Checks if the ability "Berserk" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Berserk" is active
*/
public static boolean berserkEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.BERSERK);
}
/**
* Checks if the ability "Giga Drill Breaker" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Giga Drill Breaker" is active
*/
public static boolean gigaDrillBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
}
/**
* Checks if the ability "Green Terra" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Green Terra" is active
*/
public static boolean greenTerraEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GREEN_TERRA);
}
/**
* Checks if the ability "Serrated Strikes" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Serrated Strikes" is active
*/
public static boolean serratedStrikesEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
}
/**
* Checks if the ability "Skull Splitter" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Skull Splitter" is active
*/
public static boolean skullSplitterEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SKULL_SPLITTER);
}
/**
* Checks if the ability "Super Breaker" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Super Breaker" is active
*/
public static boolean superBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SUPER_BREAKER);
}
/**
* Checks if the ability "Tree Feller" is active.
*
* @param player The {@link Player} to check
*
* @return true if "Tree Feller" is active
*/
public static boolean treeFellerEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(AbilityType.TREE_FELLER);
}
/**
* Checks if any ability is active.
*
* @param player The {@link Player} to check
*
* @return true if any ability is active
*/
public static boolean isAnyAbilityEnabled(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
@ -51,34 +107,81 @@ public final class AbilityAPI {
return false;
}
/**
* Reset the ability cooldowns for a player
*
* @param player The {@link Player} to reset the cooldowns for
*/
public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).resetCooldowns();
}
/**
* Set the cooldown for the "Berserk" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setBerserkCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.BERSERK, cooldown);
}
/**
* Set the cooldown for the "Giga Drill Breaker" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
}
/**
* Set the cooldown for the "Green Terra" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setGreenTerraCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.GREEN_TERRA, cooldown);
}
/**
* Set the cooldown for the "Serrated Strikes" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SERRATED_STRIKES, cooldown);
}
/**
* Set the cooldown for the "Skull Splitter" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setSkullSplitterCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SKULL_SPLITTER, cooldown);
}
/**
* Set the cooldown for the "Super Breaker" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setSuperBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SUPER_BREAKER, cooldown);
}
/**
* Set the cooldown for the "Tree Feller" ability
*
* @param player The {@link Player} to set the cooldown for
* @param cooldown The cooldown length to set
*/
public static void setTreeFellerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
}

View File

@ -55,7 +55,7 @@ public interface DatabaseManager {
/**
* Retrieve rank info into a HashMap from SkillType to the rank.
* <p>
* The special value <code>null</code> is used to represent the Power
* The special value {@code null} is used to represent the Power
* Level rank (the combination of all skill levels).
*
* @param playerName The name of the user to retrieve the rankings for

View File

@ -85,30 +85,67 @@ public enum AbilityType {
this.abilityPlayerOff = abilityPlayerOff;
}
/**
* Get the cooldown time in seconds for this ability
*
* @return cooldown time in seconds
*/
public int getCooldown() {
return Config.getInstance().getCooldown(this);
}
/**
* Get the maximum length in seconds for this ability
*
* @return maximum length in seconds
*/
public int getMaxLength() {
return Config.getInstance().getMaxLength(this);
}
/**
* Get the locale string for when the ability activates
*
* @return localized activation message
*/
public String getAbilityOn() {
return LocaleLoader.getString(this.abilityOn);
}
/**
* Get the locale string for when the ability deactivates
*
* @return localized deactivation message
*/
public String getAbilityOff() {
return LocaleLoader.getString(this.abilityOff);
}
/**
* Get the locale string for nearby players when someone activates this ability
*
* @param player {@link Player} object that activates this ability
* @return localized activation message
*/
public String getAbilityPlayer(Player player) {
return LocaleLoader.getString(this.abilityPlayer, player.getName());
}
/**
* Get the locale string for nearby players when someone deactivates this ability
*
* @param player {@link Player} object that deactivates this ability
* @return localized deactivation message
*/
public String getAbilityPlayerOff(Player player) {
return LocaleLoader.getString(this.abilityPlayerOff, player.getName());
}
/**
* Get ability refresh message
*
* @return Localized ability refresh message
*/
public String getAbilityRefresh() {
return LocaleLoader.getString(this.abilityRefresh);
}

View File

@ -19,10 +19,26 @@ public final class Acrobatics {
private Acrobatics() {};
/**
* Calculates how much damage should be dealt when Dodging
*
* @param damage the base damage
* @param damageModifier the damage modifier
*
* @return modified damage
*/
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
return Math.max(damage / damageModifier, 1.0);
}
/**
* Calculates how much damage should be dealt when Rolling
*
* @param damage the base damage
* @param damageThreshold the damage threshold
*
* @return modified damage
*/
protected static double calculateModifiedRollDamage(double damage, double damageThreshold) {
return Math.max(damage - damageThreshold, 0.0);
}

View File

@ -28,10 +28,22 @@ public class AcrobaticsManager extends SkillManager {
super(mcMMOPlayer, SkillType.ACROBATICS);
}
/**
* Check if the player is allowed to use Roll,
* checks permissions and exploit prevention.
*
* @return true if the player is allowed to use Roll
*/
public boolean canRoll() {
return !exploitPrevention() && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.ROLL);
}
/**
* Check if the player is allowed to use Dodge
*
* @param damager {@link Entity} that caused damage
* @return true if the player can Dodge damage from damager
*/
public boolean canDodge(Entity damager) {
if (Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DODGE)) {
if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) {
@ -152,10 +164,23 @@ public class AcrobaticsManager extends SkillManager {
return fallTries + 1 > maxTries;
}
/**
* Check if a fall is fatal
*
* @param damage amount of damage taken from the fall
* @return true if the fall is fatal, false otherwise
*/
private boolean isFatal(double damage) {
return getPlayer().getHealth() - damage <= 0;
}
/**
* Calculate the amount of XP gained from falling
*
* @param damage amount of damage taken in the fall
* @param isRoll boolean if the player was rolling
* @return amount of XP gained
*/
private float calculateRollXP(double damage, boolean isRoll) {
ItemStack boots = getPlayer().getInventory().getBoots();
float xp = (float) (damage * (isRoll ? Acrobatics.rollXpModifier : Acrobatics.fallXpModifier));

View File

@ -23,6 +23,12 @@ public class Archery {
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
/**
* Increment tracked arrow count for a LivingEntity,
* if the entity isn't tracked yet it will get added to the tracker.
*
* @param livingEntity the {@link LivingEntity} to increment the arrow count for
*/
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
@ -34,6 +40,11 @@ public class Archery {
addToTracker(livingEntity); // If the entity isn't tracked yet
}
/**
* Add a LivingEntity to the tracker.
*
* @param livingEntity the {@link LivingEntity} to add.
*/
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
@ -41,6 +52,11 @@ public class Archery {
trackedEntities.add(trackedEntity);
}
/**
* Remove a TrackedEntity from the tracker.
*
* @param trackedEntity the {@link TrackedEntity} to remove.
*/
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}

View File

@ -23,14 +23,30 @@ public class ArcheryManager extends SkillManager {
super(mcMMOPlayer, SkillType.ARCHERY);
}
/**
* Check if the target can be dazed. Checks if target is valid and if the player has sufficient permissions.
*
* @param target the {@link LivingEntity} object of the target to check
* @return true if the target can be dazed, false otherwise
*/
public boolean canDaze(LivingEntity target) {
return target instanceof Player && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DAZE);
}
/**
* Check if the player can use SkillShot.
*
* @return true if the player can use SkillShot, false otherwise
*/
public boolean canSkillShot() {
return getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.SKILL_SHOT);
}
/**
* Check if the player can use RetrieveArrows.
*
* @return true if the player can use RetrieveArrows, false otherwise
*/
public boolean canRetrieveArrows() {
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.RETRIEVE);
}
@ -67,6 +83,8 @@ public class ArcheryManager extends SkillManager {
* Handle the effects of the Daze ability
*
* @param defender The {@link Player} being affected by the ability
*
* @return amount of damage from Daze
*/
public double daze(Player defender) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.DAZE, getPlayer(), getSkillLevel(), activationChance)) {
@ -94,6 +112,7 @@ public class ArcheryManager extends SkillManager {
* Handle the effects of the Skill Shot ability
*
* @param damage The amount of damage initially dealt by the event
* @return amount of damage from Skill Shot
*/
public double skillShot(double damage) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.SKILL_SHOT, getPlayer())) {

View File

@ -23,6 +23,12 @@ public class Axes {
public static double skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
/**
* Check if the target is wearing any armor.
*
* @param target the {@link LivingEntity} object of the target to check.
* @return true if the target is wearing at least one piece of armor, false otherwise
*/
protected static boolean hasArmor(LivingEntity target) {
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(itemStack)) {

View File

@ -159,6 +159,9 @@ public class RepairManager extends SkillManager {
/**
* Check if the player has tried to use an Anvil before.
*
* @param anvilType The {@link Material} of the anvil block
* @param actualize determines if last anvil use should be actualized
*
* @return true if the player has confirmed using an Anvil
*/
public boolean checkConfirmation(boolean actualize) {
@ -273,7 +276,7 @@ public class RepairManager extends SkillManager {
/**
* Handles removing & downgrading enchants.
*
* @param item Item being repaired
* @param item {@link ItemStack} being repaired
*/
private void addEnchants(ItemStack item) {
Player player = getPlayer();