mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
7c59621c9e
Bukkit is dumb.
75 lines
2.3 KiB
Java
75 lines
2.3 KiB
Java
package com.gmail.nossr50.skills.archery;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
import com.gmail.nossr50.skills.SkillType;
|
|
import com.gmail.nossr50.util.Misc;
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
public class ArcheryManager extends SkillManager {
|
|
public ArcheryManager (Player player) {
|
|
super(player, SkillType.ARCHERY);
|
|
}
|
|
|
|
/**
|
|
* Track arrows fired for later retrieval.
|
|
*
|
|
* @param livingEntity Entity damaged by the arrow
|
|
*/
|
|
public void trackArrows(LivingEntity livingEntity) {
|
|
if (Misc.isNPCPlayer(player) || !Permissions.trackArrows(player)) {
|
|
return;
|
|
}
|
|
|
|
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
|
|
|
double chance = (Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * eventHandler.skillModifier;
|
|
|
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
|
eventHandler.addToTracker();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check for Daze.
|
|
*
|
|
* @param defender Defending player
|
|
* @param event The event to modify
|
|
*/
|
|
public void dazeCheck(Player defender, EntityDamageEvent event) {
|
|
if (Misc.isNPCPlayer(player) || !Permissions.daze(player)) {
|
|
return;
|
|
}
|
|
|
|
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
|
|
|
double chance = (Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * eventHandler.skillModifier;
|
|
|
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
|
eventHandler.handleDazeEffect();
|
|
eventHandler.sendAbilityMessages();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle archery bonus damage.
|
|
*
|
|
* @param event The event to modify.
|
|
*/
|
|
public void skillShot(EntityDamageEvent event) {
|
|
if (Misc.isNPCPlayer(player) || !Permissions.archeryBonus(player)) {
|
|
return;
|
|
}
|
|
|
|
if (skillLevel >= Archery.skillShotIncreaseLevel) {
|
|
SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event);
|
|
|
|
eventHandler.calculateDamageBonus();
|
|
eventHandler.modifyEventDamage();
|
|
}
|
|
}
|
|
}
|