2012-06-13 03:36:01 +02:00
|
|
|
package com.gmail.nossr50.skills.archery;
|
|
|
|
|
2012-06-15 02:43:13 +02:00
|
|
|
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();
|
2012-06-15 02:43:13 +02:00
|
|
|
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();
|
2013-01-01 23:12:15 +01:00
|
|
|
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();
|
2013-01-01 23:12:15 +01:00
|
|
|
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) {
|
2012-06-15 02:43:13 +02:00
|
|
|
for (TrackedEntity trackedEntity : trackedEntities) {
|
2013-01-08 23:24:09 +01:00
|
|
|
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
|
2012-06-15 02:43:13 +02:00
|
|
|
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) {
|
2012-06-15 02:43:13 +02:00
|
|
|
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
|
|
|
|
*/
|
2012-06-15 02:43:13 +02:00
|
|
|
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()) {
|
2012-06-15 02:43:13 +02:00
|
|
|
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
|
2013-01-09 00:09:02 +01:00
|
|
|
entityIterator.remove();
|
2012-06-15 02:43:13 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-06-13 03:36:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|