mcMMO/src/main/java/com/gmail/nossr50/skills/archery/Archery.java

68 lines
2.7 KiB
Java
Raw Normal View History

2012-06-13 03:36:01 +02:00
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
2012-06-13 14:54:02 +02:00
2012-06-13 03:36:01 +02:00
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
2012-11-21 21:49:54 +01:00
import com.gmail.nossr50.config.AdvancedConfig;
2012-06-13 03:36:01 +02:00
import com.gmail.nossr50.util.Misc;
public class Archery {
2013-01-08 23:24:09 +01:00
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
2012-06-13 03:36:01 +02:00
2012-11-21 21:49:54 +01:00
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = advancedConfig.getRetrieveMaxBonusLevel();
public static final int ARROW_TRACKING_MAX_BONUS = advancedConfig.getRetrieveBonusMax();
2012-12-24 22:56:25 +01:00
2012-11-21 21:49:54 +01:00
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getSkillShotIncreaseLevel();
public static final double BONUS_DAMAGE_INCREASE_PERCENT = advancedConfig.getSkillShotIncreasePercentage();
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = advancedConfig.getSkillShotBonusMax();
2012-06-13 03:36:01 +02:00
2012-11-21 21:49:54 +01:00
public static final int DAZE_MAX_BONUS_LEVEL = advancedConfig.getDazeMaxBonusLevel();
public static final int DAZE_MAX_BONUS = advancedConfig.getDazeBonusMax();
2012-11-21 21:49:54 +01:00
public static final int DAZE_MODIFIER = advancedConfig.getDazeModifier();
2012-06-13 03:36:01 +02:00
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
2013-01-08 23:24:09 +01:00
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
trackedEntity.incrementArrowCount();
return;
}
}
2012-06-15 02:46:41 +02:00
2013-01-08 23:24:09 +01:00
addToTracker(livingEntity); //If the entity isn't tracked yet
2012-06-13 03:36:01 +02:00
}
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);
2012-06-13 03:36:01 +02:00
}
/**
* Check for arrow retrieval.
*
* @param entity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
2013-01-09 00:09:02 +01:00
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) {
TrackedEntity trackedEntity = entityIterator.next();
2012-06-13 14:53:18 +02:00
2013-01-09 00:09:02 +01:00
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
2013-01-09 00:09:02 +01:00
entityIterator.remove();
return;
}
2012-06-13 03:36:01 +02:00
}
}
}