mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Missed a refactor :P Also, javadoc event
This commit is contained in:
@ -2,20 +2,24 @@ package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
|
||||
|
||||
private SecondaryAbilityType secondaryAbility;
|
||||
private SecondaryAbility secondaryAbility;
|
||||
|
||||
public SecondaryAbilityEvent(Player player, SecondaryAbilityType secondaryAbility) {
|
||||
public SecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
|
||||
super(player, SkillType.bySecondaryAbility(secondaryAbility));
|
||||
this.secondaryAbility = secondaryAbility;
|
||||
}
|
||||
|
||||
public SecondaryAbilityType getSecondarySkillAbility() {
|
||||
/**
|
||||
* Gets the SecondaryAbility involved in the event
|
||||
* @return the SecondaryAbility
|
||||
*/
|
||||
public SecondaryAbility getSecondaryAbility() {
|
||||
return secondaryAbility;
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,37 @@
|
||||
package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
|
||||
public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbilityEvent {
|
||||
|
||||
private double chance;
|
||||
|
||||
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbilityType ability, double chance) {
|
||||
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbility ability, double chance) {
|
||||
super(player, ability);
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the activation chance of the ability 0D being no chance, 1.0D being 100% chance
|
||||
* @return The activation chance of the ability
|
||||
*/
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the activation chance of the ability [0D-1.0D]
|
||||
* @param The activation chance of the ability
|
||||
*/
|
||||
public void setChance(double chance) {
|
||||
this.chance = Math.min(1D, chance);
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the activation chance of the ability to 100% or 0%
|
||||
* @param whether it should be successful or not
|
||||
*/
|
||||
public void setSuccessful(boolean success) {
|
||||
this.chance = success ? 1.0D : 0D;
|
||||
}
|
||||
|
Reference in New Issue
Block a user