Squashed commit of the following:

commit cb3e057dee1f2b29838ab654a526baac1baab7d6
Author: NuclearW <incongruency@gmail.com>
Date:   Fri Mar 1 00:43:57 2013 -0500

    1.4.00 release

commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35
Author: NuclearW <incongruency@gmail.com>
Date:   Fri Mar 1 00:07:30 2013 -0500

    \r -> \n

commit b2ca22e0477c747143b0f08a28a096967ee6ffd7
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 23:53:56 2013 -0500

    Commented-out code shouldn't be done like that.

commit 92f131712cc671e3e616c14a22e22769ef6d6d0b
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 23:45:36 2013 -0500

    More things we missed.

commit 408b03766f6261a03a862a1ab7f5835772feda4a
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 23:20:13 2013 -0500

    Format: util through spout and backup lib

commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 22:50:08 2013 -0500

    The things we missed the first time through...

commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 22:05:29 2013 -0500

    Formatting: Skills

commit c097a6e188a7b760dd1b4389ed81dca417146b16
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:30:12 2013 -0500

    Organize imports.

commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:09:45 2013 -0500

    Fixed a missing fallthrough comment from ChatCommand

commit b4a76c9f022a2fd98bdd8f083accfea03becfd71
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:09:36 2013 -0500

    Formatting: datatypes.* through events.*

commit 3e57dd41d3265a7c8106c7eb026df926770a4d15
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:56:15 2013 -0500

    Fix issue with bad rebase

commit e8c8e06b2971555b7334e49128257e3af6f36892
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 17:35:32 2013 -0500

    Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and
    PlayerStat

commit 13ecf1cc41f377a12991e357ac10abdcda24d6de
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:31:43 2013 -0500

    Format: listeners.* through runnables.*

commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:13:57 2013 -0500

    Format PartyLockCommand

commit d50abed10bf94e1a88df3dc5cc07c259aea920ea
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 16:54:08 2013 -0500

    Format: base through config.*

commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:21:40 2013 -0500

    Example of using spaces to align like things

commit 534190cfe2481e466fe459d65628550458cc2993
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:12:19 2013 -0500

    Capitalization

commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:07:43 2013 -0500

    Updated readme, added standards.md

commit 5ec0df70fb82c527420a2f437f27f31bd758f884
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 14:42:16 2013 -0500

    Markdown was here, Creole is a loser

commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 13:46:24 2013 -0500

    Move MCStats shading to .metrics.mcstats

commit eb9d67e66b1659d6abd2397ecf403343cfeffdda
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 13:37:37 2013 -0500

    Move ALL the packages!

commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 12:37:12 2013 -0500

    /r/n -> /n
This commit is contained in:
NuclearW
2013-03-01 00:52:01 -05:00
parent 13111a8d1b
commit a542d6cf3e
263 changed files with 24364 additions and 23982 deletions

View File

@ -1,68 +1,68 @@
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public class Archery {
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static int retrieveMaxBonusLevel = AdvancedConfig.getInstance().getRetrieveMaxBonusLevel();
public static double retrieveMaxChance = AdvancedConfig.getInstance().getRetrieveChanceMax();
public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel();
public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage();
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
public static int dazeMaxBonusLevel = AdvancedConfig.getInstance().getDazeMaxBonusLevel();
public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax();
public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
public static double distanceXpModifer = 0.025;
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
trackedEntity.incrementArrowCount();
return;
}
}
addToTracker(livingEntity); //If the entity isn't tracked yet
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
trackedEntity.incrementArrowCount();
trackedEntities.add(trackedEntity);
}
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}
/**
* Check for arrow retrieval.
*
* @param livingEntity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) {
TrackedEntity trackedEntity = entityIterator.next();
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
entityIterator.remove();
return;
}
}
}
}
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public class Archery {
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static int retrieveMaxBonusLevel = AdvancedConfig.getInstance().getRetrieveMaxBonusLevel();
public static double retrieveMaxChance = AdvancedConfig.getInstance().getRetrieveChanceMax();
public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel();
public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage();
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
public static int dazeMaxBonusLevel = AdvancedConfig.getInstance().getDazeMaxBonusLevel();
public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax();
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
trackedEntity.incrementArrowCount();
return;
}
}
addToTracker(livingEntity); // If the entity isn't tracked yet
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
trackedEntity.incrementArrowCount();
trackedEntities.add(trackedEntity);
}
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}
/**
* Check for arrow retrieval.
*
* @param livingEntity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext();) {
TrackedEntity trackedEntity = entityIterator.next();
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
entityIterator.remove();
return;
}
}
}
}

View File

@ -1,104 +0,0 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String dazeChanceLucky;
private String retrieveChance;
private String retrieveChanceLucky;
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
public ArcheryCommand() {
super(SkillType.ARCHERY);
}
@Override
protected void dataCalculations() {
//SKILL SHOT
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
if (bonus > Archery.skillShotMaxBonusPercentage) {
skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage);
}
else {
skillShotBonus = percent.format(bonus);
}
//DAZE
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
//RETRIEVE
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
@Override
protected void permissionsCheck() {
canSkillShot = Permissions.bonusDamage(player, skill);
canDaze = Permissions.daze(player);
canRetrieve = Permissions.arrowRetrieval(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void statsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
}
if (canDaze) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance));
}
}
if (canRetrieve) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance));
}
}
}
}

View File

@ -1,115 +1,115 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ArcheryManager extends SkillManager {
public ArcheryManager (McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ARCHERY);
}
public boolean canDaze(LivingEntity target) {
return target instanceof Player && Permissions.daze(getPlayer());
}
public boolean canSkillShot() {
Player player = getPlayer();
return SkillTools.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
}
public boolean canTrackArrows() {
Player player = getPlayer();
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
}
/**
* Calculate bonus XP awarded for Archery when hitting a far-away target.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void distanceXpBonus(LivingEntity target) {
Player player = getPlayer();
Location shooterLocation = player.getLocation();
Location targetLocation = target.getLocation();
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
return;
}
// Cap distance at 100^2 to prevent teleport exploit.
// TODO: Better way to handle this would be great...
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
applyXpGain((int) (squaredDistance * Archery.distanceXpModifer));
}
/**
* Track arrows fired for later retrieval.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void trackArrows(LivingEntity target) {
if (SkillTools.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
Archery.incrementTrackerValue(target);
}
}
/**
* Handle the effects of the Daze ability
*
* @param defender The player being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int dazeCheck(Player defender, int damage) {
Player attacker = getPlayer();
if (SkillTools.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
defender.teleport(dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
}
if (getProfile().useChatNotifications()) {
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
return damage + Archery.dazeModifier;
}
return damage;
}
/**
* Handle the effects of the Skill Shot ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int skillShotCheck(int damage) {
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
int archeryBonus = (int) (damage * damageBonusPercent);
return damage + archeryBonus;
}
}
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class ArcheryManager extends SkillManager {
public ArcheryManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ARCHERY);
}
public boolean canDaze(LivingEntity target) {
return target instanceof Player && Permissions.daze(getPlayer());
}
public boolean canSkillShot() {
Player player = getPlayer();
return SkillUtils.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
}
public boolean canTrackArrows() {
Player player = getPlayer();
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
}
/**
* Calculate bonus XP awarded for Archery when hitting a far-away target.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void distanceXpBonus(LivingEntity target) {
Player player = getPlayer();
Location shooterLocation = player.getLocation();
Location targetLocation = target.getLocation();
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
return;
}
// Cap distance at 100^2 to prevent teleport exploit.
// TODO: Better way to handle this would be great...
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
applyXpGain((int) (squaredDistance * Archery.DISTANCE_XP_MULTIPLIER));
}
/**
* Track arrows fired for later retrieval.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void trackArrows(LivingEntity target) {
if (SkillUtils.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
Archery.incrementTrackerValue(target);
}
}
/**
* Handle the effects of the Daze ability
*
* @param defender The player being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int dazeCheck(Player defender, int damage) {
Player attacker = getPlayer();
if (SkillUtils.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
defender.teleport(dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
}
if (getProfile().useChatNotifications()) {
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
return damage + Archery.dazeModifier;
}
return damage;
}
/**
* Handle the effects of the Skill Shot ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int skillShotCheck(int damage) {
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
int archeryBonus = (int) (damage * damageBonusPercent);
return damage + archeryBonus;
}
}

View File

@ -21,6 +21,14 @@ public class TrackedEntity implements Runnable {
this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
}
@Override
public void run() {
if (!livingEntity.isValid()) {
Archery.removeFromTracker(this);
scheduler.cancelTask(taskId);
}
}
protected LivingEntity getLivingEntity() {
return livingEntity;
}
@ -36,12 +44,4 @@ public class TrackedEntity implements Runnable {
protected void incrementArrowCount() {
arrowCount++;
}
@Override
public void run() {
if (!livingEntity.isValid()) {
Archery.removeFromTracker(this);
scheduler.cancelTask(taskId);
}
}
}