Archery cleanup.

This commit is contained in:
gmcferrin
2013-01-08 17:44:05 -05:00
parent 08b46e1a7c
commit f3c89fe48b
3 changed files with 14 additions and 28 deletions

View File

@ -6,6 +6,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
@ -17,11 +18,6 @@ public class ArcheryManager {
public ArcheryManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
//Compatibility with Citizens, Citizens NPCs won't create a profile so we'll check for it here
if(this.profile == null)
return;
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
}
@ -31,10 +27,7 @@ public class ArcheryManager {
* @param livingEntity Entity damaged by the arrow
*/
public void trackArrows(LivingEntity livingEntity) {
if(player == null)
return;
if (!Permissions.trackArrows(player)) {
if (Misc.isCitizensNPC(player) || !Permissions.trackArrows(player)) {
return;
}
@ -45,8 +38,7 @@ public class ArcheryManager {
randomChance = (int) (randomChance * 0.75);
}
float chance = (float) (((double) Archery.ARROW_TRACKING_MAX_BONUS / (double) Archery.ARROW_TRACKING_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Archery.ARROW_TRACKING_MAX_BONUS) chance = Archery.ARROW_TRACKING_MAX_BONUS;
float chance = ((float) Archery.ARROW_TRACKING_MAX_BONUS / Archery.ARROW_TRACKING_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
if (chance > Archery.getRandom().nextInt(randomChance)) {
eventHandler.addToTracker();
@ -60,23 +52,18 @@ public class ArcheryManager {
* @param event The event to modify
*/
public void dazeCheck(Player defender, EntityDamageEvent event) {
if(player == null)
return;
if (!Permissions.daze(player)) {
if (Misc.isCitizensNPC(player) || !Permissions.daze(player)) {
return;
}
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
int randomChance = 100;
if (Permissions.luckyArchery(player)) {
randomChance = (int) (randomChance * 0.75);
}
float chance = (float) (((double) Archery.DAZE_MAX_BONUS / (double) Archery.DAZE_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Archery.DAZE_MAX_BONUS) chance = Archery.DAZE_MAX_BONUS;
float chance = ((float) Archery.DAZE_MAX_BONUS / Archery.DAZE_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
if (chance > Archery.getRandom().nextInt(randomChance)) {
eventHandler.handleDazeEffect();
@ -90,10 +77,7 @@ public class ArcheryManager {
* @param event The event to modify.
*/
public void bonusDamage(EntityDamageEvent event) {
if(player == null)
return;
if (!Permissions.archeryBonus(player)) {
if (Misc.isCitizensNPC(player) || !Permissions.archeryBonus(player)) {
return;
}