mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Straightening up our Managers more, also fixed a few bugs regarding
unlock levels and Deflect not working properly.
This commit is contained in:
parent
27ed5f7c38
commit
0c027ca697
@ -9,6 +9,8 @@ Key:
|
|||||||
|
|
||||||
Version 1.4.02-dev
|
Version 1.4.02-dev
|
||||||
+ Added API to get the skill and power level caps.
|
+ Added API to get the skill and power level caps.
|
||||||
|
= Fixed bug where Deflect was calculated based on the attacker, not the defender
|
||||||
|
= Fixed bug where some skills weren't registering as unlocked until one level later
|
||||||
|
|
||||||
Version 1.4.01
|
Version 1.4.01
|
||||||
= Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs
|
= Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs
|
||||||
|
@ -69,10 +69,11 @@ public class McMMOPlayer {
|
|||||||
private boolean placedSalvageAnvil;
|
private boolean placedSalvageAnvil;
|
||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
|
|
||||||
private Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
private Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||||
private Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
private Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||||
private Map<ToolType, Boolean> toolPreparationMode = new HashMap<ToolType, Boolean>();
|
|
||||||
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
private Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||||
|
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||||
|
|
||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
@ -110,7 +111,7 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ToolType toolType : ToolType.values()) {
|
for (ToolType toolType : ToolType.values()) {
|
||||||
toolPreparationMode.put(toolType, false);
|
toolMode.put(toolType, false);
|
||||||
toolATS.put(toolType, 0);
|
toolATS.put(toolType, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +220,7 @@ public class McMMOPlayer {
|
|||||||
* @return true if the tool is prepped, false otherwise
|
* @return true if the tool is prepped, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getToolPreparationMode(ToolType tool) {
|
public boolean getToolPreparationMode(ToolType tool) {
|
||||||
return toolPreparationMode.get(tool);
|
return toolMode.get(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAbilityUse() {
|
public boolean getAbilityUse() {
|
||||||
@ -250,7 +251,7 @@ public class McMMOPlayer {
|
|||||||
* @param bool true if the tool should be prepped, false otherwise
|
* @param bool true if the tool should be prepped, false otherwise
|
||||||
*/
|
*/
|
||||||
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
||||||
toolPreparationMode.put(tool, bool);
|
toolMode.put(tool, bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -234,20 +235,26 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
ItemStack heldItem = player.getItemInHand();
|
||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
|
||||||
SmeltingManager smeltingManager = mcMMOPlayer.getSmeltingManager();
|
|
||||||
|
|
||||||
if (herbalismManager.canUseHylianLuck()) {
|
if (ItemUtils.isSword(heldItem)) {
|
||||||
if (herbalismManager.processHylianLuck(blockState)) {
|
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||||
blockState.update(true);
|
|
||||||
event.setCancelled(true);
|
if (herbalismManager.canUseHylianLuck()) {
|
||||||
|
if (herbalismManager.processHylianLuck(blockState)) {
|
||||||
|
blockState.update(true);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (smeltingManager.canUseFluxMining(blockState)) {
|
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
if (smeltingManager.processFluxMining(blockState)) {
|
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
|
||||||
blockState.update(true);
|
|
||||||
event.setCancelled(true);
|
if (smeltingManager.canUseFluxMining(blockState)) {
|
||||||
|
if (smeltingManager.processFluxMining(blockState)) {
|
||||||
|
blockState.update(true);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,8 @@ public class EntityListener implements Listener {
|
|||||||
Player defendingPlayer = (Player) defender;
|
Player defendingPlayer = (Player) defender;
|
||||||
Player attackingPlayer = (Player) attacker;
|
Player attackingPlayer = (Player) attacker;
|
||||||
|
|
||||||
// TODO: Why?
|
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
|
||||||
if (defendingPlayer == attackingPlayer) {
|
if (defendingPlayer.equals(attackingPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
@ -27,12 +28,11 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
|
|
||||||
public boolean canDodge(Entity damager) {
|
public boolean canDodge(Entity damager) {
|
||||||
if (Permissions.dodge(getPlayer())) {
|
if (Permissions.dodge(getPlayer())) {
|
||||||
if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) {
|
if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) {
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CombatUtils.shouldProcessSkill(damager, skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -48,7 +48,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
|
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
|
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
|
||||||
ParticleEffectUtils.playDodgeEffect(player);
|
ParticleEffectUtils.playDodgeEffect(player);
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
@ -26,9 +26,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSkillShot() {
|
public boolean canSkillShot() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(getPlayer(), skill);
|
||||||
|
|
||||||
return SkillUtils.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTrackArrows() {
|
public boolean canTrackArrows() {
|
||||||
@ -64,7 +62,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param target The {@link LivingEntity} damaged by the arrow
|
* @param target The {@link LivingEntity} damaged by the arrow
|
||||||
*/
|
*/
|
||||||
public void trackArrows(LivingEntity target) {
|
public void trackArrows(LivingEntity target) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
|
||||||
Archery.incrementTrackerValue(target);
|
Archery.incrementTrackerValue(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,14 +70,12 @@ public class ArcheryManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Handle the effects of the Daze ability
|
* Handle the effects of the Daze ability
|
||||||
*
|
*
|
||||||
* @param defender The player being affected by the ability
|
* @param defender The {@link Player} being affected by the ability
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public int dazeCheck(Player defender, int damage) {
|
public int dazeCheck(Player defender, int damage) {
|
||||||
Player attacker = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
|
||||||
Location dazedLocation = defender.getLocation();
|
Location dazedLocation = defender.getLocation();
|
||||||
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
||||||
|
|
||||||
@ -91,7 +87,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage + Archery.dazeModifier;
|
return damage + Archery.dazeModifier;
|
||||||
|
@ -68,10 +68,8 @@ public class AxesManager extends SkillManager {
|
|||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public int criticalHitCheck(LivingEntity target, int damage) {
|
public int criticalHitCheck(LivingEntity target, int damage) {
|
||||||
Player player = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||||
@ -94,10 +92,11 @@ public class AxesManager extends SkillManager {
|
|||||||
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
||||||
|
|
||||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||||
if (ItemUtils.isArmor(armor) && SkillUtils.activationSuccessful(getPlayer(), skill, Axes.impactChance)) {
|
if (ItemUtils.isArmor(armor) && Axes.impactChance > getActivationChance()) {
|
||||||
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
||||||
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
||||||
double maxDurabilityDamage = (ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityModifier;
|
short maxDurability = ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability();
|
||||||
|
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
|
||||||
|
|
||||||
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
||||||
}
|
}
|
||||||
@ -112,9 +111,9 @@ public class AxesManager extends SkillManager {
|
|||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public int greaterImpactCheck(LivingEntity target, int damage) {
|
public int greaterImpactCheck(LivingEntity target, int damage) {
|
||||||
Player player = getPlayer();
|
if (Axes.greaterImpactChance > getActivationChance()) {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Axes.greaterImpactChance)) {
|
|
||||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||||
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
||||||
|
|
||||||
|
@ -38,9 +38,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canShake(Entity target) {
|
public boolean canShake(Entity target) {
|
||||||
Player player = getPlayer();
|
return target instanceof LivingEntity && getSkillLevel() >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(getPlayer());
|
||||||
|
|
||||||
return target instanceof LivingEntity && SkillUtils.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,7 +134,7 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param mob The {@link LivingEntity} affected by the ability
|
* @param mob The {@link LivingEntity} affected by the ability
|
||||||
*/
|
*/
|
||||||
public void shakeCheck(LivingEntity target) {
|
public void shakeCheck(LivingEntity target) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
|
if (getActivationChance() > getShakeProbability()) {
|
||||||
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
||||||
|
|
||||||
Fishing.findPossibleDrops(target, possibleDrops);
|
Fishing.findPossibleDrops(target, possibleDrops);
|
||||||
|
@ -24,7 +24,6 @@ import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
|||||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask;
|
import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -54,9 +53,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseHylianLuck() {
|
public boolean canUseHylianLuck() {
|
||||||
Player player = getPlayer();
|
return Permissions.hylianLuck(getPlayer());
|
||||||
|
|
||||||
return ItemUtils.isSword(player.getItemInHand()) && Permissions.hylianLuck(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGreenTerraBlock(BlockState blockState) {
|
public boolean canGreenTerraBlock(BlockState blockState) {
|
||||||
@ -150,7 +147,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
xp = customBlock.getXpGain();
|
xp = customBlock.getXpGain();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||||
Location location = blockState.getLocation();
|
Location location = blockState.getLocation();
|
||||||
|
|
||||||
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
|
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
|
||||||
@ -178,10 +175,8 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
||||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,9 +190,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processHylianLuck(BlockState blockState) {
|
public boolean processHylianLuck(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
|
||||||
|
|
||||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +229,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
|
|
||||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
getPlayer().sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +257,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
|
||||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -293,7 +286,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0);
|
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
else if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||||
playerInventory.removeItem(seed);
|
playerInventory.removeItem(seed);
|
||||||
player.updateInventory(); // Needed until replacement available
|
player.updateInventory(); // Needed until replacement available
|
||||||
|
|
||||||
|
@ -30,38 +30,33 @@ public class MiningManager extends SkillManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseDemolitionsExpertise() {
|
public boolean canUseDemolitionsExpertise() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= BlastMining.Tier.FOUR.getLevel() && Permissions.demolitionsExpertise(getPlayer());
|
||||||
|
|
||||||
return SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDetonate() {
|
public boolean canDetonate() {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel());
|
return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBlastMining() {
|
public boolean canUseBlastMining() {
|
||||||
return SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel());
|
return getSkillLevel() >= BlastMining.Tier.ONE.getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBiggerBombs() {
|
public boolean canUseBiggerBombs() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= BlastMining.Tier.TWO.getLevel() && Permissions.biggerBombs(getPlayer());
|
||||||
|
|
||||||
return Permissions.biggerBombs(player) && SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process double drops & XP gain for Mining.
|
* Process double drops & XP gain for Mining.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
* @param player The {@link Player} using this ability
|
|
||||||
*/
|
*/
|
||||||
public void miningBlockCheck(BlockState blockState) {
|
public void miningBlockCheck(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
int xp = Mining.getBlockXp(blockState);
|
int xp = Mining.getBlockXp(blockState);
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
||||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
Mining.handleSilkTouchDrops(blockState);
|
Mining.handleSilkTouchDrops(blockState);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.smelting;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -16,7 +15,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.skills.mining.Mining;
|
import com.gmail.nossr50.skills.mining.Mining;
|
||||||
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@ -27,16 +25,11 @@ public class SmeltingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseFluxMining(BlockState blockState) {
|
public boolean canUseFluxMining(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.placeStore.isTrue(blockState);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
|
||||||
|
|
||||||
return BlockUtils.affectedByFluxMining(blockState) && ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseVanillaXpBoost() {
|
public boolean canUseVanillaXpBoost() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= Smelting.Tier.ONE.getLevel() && Permissions.vanillaXpBoost(getPlayer(), skill);
|
||||||
|
|
||||||
return SkillUtils.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +41,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
public boolean processFluxMining(BlockState blockState) {
|
public boolean processFluxMining(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (SkillUtils.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillUtils.activationSuccessful(player, skill, Smelting.fluxMiningChance)) {
|
if (getActivationChance() > Smelting.fluxMiningChance) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
@ -72,7 +65,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
|
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +94,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
|
|
||||||
applyXpGain(Smelting.getResourceXp(resourceType));
|
applyXpGain(Smelting.getResourceXp(resourceType));
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
|
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
|
||||||
ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1);
|
ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1);
|
||||||
return newResult;
|
return newResult;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,10 @@ public class SwordsManager extends SkillManager {
|
|||||||
return Permissions.bleed(getPlayer());
|
return Permissions.bleed(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUseCounterAttack() {
|
||||||
|
return Permissions.counterAttack(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canUseSerratedStrike() {
|
public boolean canUseSerratedStrike() {
|
||||||
return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer());
|
return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer());
|
||||||
}
|
}
|
||||||
@ -38,9 +42,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
* @param target The defending entity
|
* @param target The defending entity
|
||||||
*/
|
*/
|
||||||
public void bleedCheck(LivingEntity target) {
|
public void bleedCheck(LivingEntity target) {
|
||||||
Player player = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
|
|
||||||
|
|
||||||
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
|
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
|
||||||
BleedTimerTask.add(target, Swords.bleedMaxTicks);
|
BleedTimerTask.add(target, Swords.bleedMaxTicks);
|
||||||
@ -50,7 +52,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
@ -64,7 +66,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
|
||||||
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
||||||
|
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||||
|
@ -27,23 +27,35 @@ public class TamingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseThickFur() {
|
public boolean canUseThickFur() {
|
||||||
return getSkillLevel() > Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer());
|
return getSkillLevel() >= Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseEnvironmentallyAware() {
|
public boolean canUseEnvironmentallyAware() {
|
||||||
return getSkillLevel() > Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer());
|
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseShockProof() {
|
public boolean canUseShockProof() {
|
||||||
return getSkillLevel() > Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer());
|
return getSkillLevel() >= Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseHolyHound() {
|
public boolean canUseHolyHound() {
|
||||||
return getSkillLevel() > Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer());
|
return getSkillLevel() >= Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBeastLore(LivingEntity target) {
|
public boolean canUseFastFoodService() {
|
||||||
return target instanceof Tameable && Permissions.beastLore(getPlayer());
|
return getSkillLevel() >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseSharpenedClaws() {
|
||||||
|
return getSkillLevel() >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseGore() {
|
||||||
|
return Permissions.gore(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBeastLore() {
|
||||||
|
return Permissions.beastLore(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +85,7 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param damage The damage being absorbed by the wolf
|
* @param damage The damage being absorbed by the wolf
|
||||||
*/
|
*/
|
||||||
public void fastFoodService(Wolf wolf, int damage) {
|
public void fastFoodService(Wolf wolf, int damage) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) {
|
if (getActivationChance() > Taming.fastFoodServiceActivationChance) {
|
||||||
|
|
||||||
int health = wolf.getHealth();
|
int health = wolf.getHealth();
|
||||||
int maxHealth = wolf.getMaxHealth();
|
int maxHealth = wolf.getMaxHealth();
|
||||||
@ -91,16 +103,14 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public int gore(LivingEntity target, int damage) {
|
public int gore(LivingEntity target, int damage) {
|
||||||
Player owner = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(owner, skill, Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
|
||||||
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.sendMessage(LocaleLoader.getString("Combat.Gore"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||||
return damage * Taming.goreModifier;
|
return damage * Taming.goreModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,19 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer());
|
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canDeflect() {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
return player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for disarm.
|
* Check for disarm.
|
||||||
*
|
*
|
||||||
* @param defender The defending player
|
* @param defender The defending player
|
||||||
*/
|
*/
|
||||||
public void disarmCheck(Player defender) {
|
public void disarmCheck(Player defender) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
|
||||||
McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender);
|
McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent);
|
||||||
|
|
||||||
@ -61,10 +67,8 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* Check for arrow deflection.
|
* Check for arrow deflection.
|
||||||
*/
|
*/
|
||||||
public boolean deflectCheck() {
|
public boolean deflectCheck() {
|
||||||
Player player = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,22 +55,27 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
|
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
|
||||||
Player player = (Player) attacker;
|
Player player = (Player) attacker;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (Misc.isNPCEntity(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if (target instanceof Tameable) {
|
if (target instanceof Tameable) {
|
||||||
if (heldItem.getType() == Material.BONE && Permissions.beastLore(player)) {
|
if (isFriendlyPet(player, (Tameable) target)) {
|
||||||
mcMMOPlayer.getTamingManager().beastLore(target);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (isFriendlyPet(player, (Tameable) target)) {
|
|
||||||
return;
|
if (heldItem.getType() == Material.BONE) {
|
||||||
|
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||||
|
|
||||||
|
if (tamingManager.canUseBeastLore()) {
|
||||||
|
tamingManager.beastLore(target);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +99,7 @@ public final class CombatUtils {
|
|||||||
swordsManager.serratedStrikes(target, event.getDamage());
|
swordsManager.serratedStrikes(target, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(swordsManager.getMcMMOPlayer(), target, SkillType.SWORDS);
|
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isAxe(heldItem)) {
|
else if (ItemUtils.isAxe(heldItem)) {
|
||||||
@ -128,7 +133,7 @@ public final class CombatUtils {
|
|||||||
axesManager.skullSplitterCheck(target, event.getDamage());
|
axesManager.skullSplitterCheck(target, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(axesManager.getMcMMOPlayer(), target, SkillType.AXES);
|
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (heldItem.getType() == Material.AIR) {
|
else if (heldItem.getType() == Material.AIR) {
|
||||||
@ -155,14 +160,7 @@ public final class CombatUtils {
|
|||||||
unarmedManager.disarmCheck((Player) target);
|
unarmedManager.disarmCheck((Player) target);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(unarmedManager.getMcMMOPlayer(), target, SkillType.UNARMED);
|
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (heldItem.getType() == Material.BONE) {
|
|
||||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
|
||||||
|
|
||||||
if (tamingManager.canUseBeastLore(target)) {
|
|
||||||
tamingManager.beastLore(target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,17 +183,16 @@ public final class CombatUtils {
|
|||||||
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
||||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||||
int skillLevel = tamingManager.getSkillLevel();
|
|
||||||
|
|
||||||
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) {
|
if (tamingManager.canUseFastFoodService()) {
|
||||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) {
|
if (tamingManager.canUseSharpenedClaws()) {
|
||||||
event.setDamage(Taming.sharpenedClaws(event.getDamage()));
|
event.setDamage(Taming.sharpenedClaws(event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.gore(master)) {
|
if (tamingManager.canUseGore()) {
|
||||||
event.setDamage(tamingManager.gore(target, event.getDamage()));
|
event.setDamage(tamingManager.gore(target, event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,10 +211,47 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldProcessSkill(target, SkillType.ARCHERY)) {
|
if (!shouldProcessSkill(target, SkillType.ARCHERY)) {
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) shooter;
|
||||||
|
|
||||||
|
if (Misc.isNPCEntity(player)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Permissions.skillEnabled(player, SkillType.ARCHERY)) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||||
|
|
||||||
|
if (archeryManager.canSkillShot()) {
|
||||||
|
event.setDamage(archeryManager.skillShotCheck(event.getDamage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled()) {
|
||||||
|
UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager();
|
||||||
|
|
||||||
|
if (unarmedManager.canDeflect()) {
|
||||||
|
event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck());
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archeryManager.canDaze(target)) {
|
||||||
|
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archeryManager.canTrackArrows()) {
|
||||||
|
archeryManager.trackArrows(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
archeryManager.distanceXpBonus(target);
|
||||||
|
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
archeryCheck((Player) shooter, target, event);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -238,59 +272,17 @@ public final class CombatUtils {
|
|||||||
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack heldItem = player.getItemInHand();
|
if (ItemUtils.isSword(player.getItemInHand())) {
|
||||||
|
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
|
||||||
if (damager instanceof Player) {
|
|
||||||
if (SkillType.SWORDS.getPVPEnabled() && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) {
|
|
||||||
mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) {
|
|
||||||
mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Process archery abilities.
|
|
||||||
*
|
|
||||||
* @param shooter The player shooting
|
|
||||||
* @param target The defending entity
|
|
||||||
* @param event The event to run the archery checks on.
|
|
||||||
*/
|
|
||||||
private static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) {
|
|
||||||
if (Misc.isNPCEntity(shooter)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) {
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(shooter);
|
|
||||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
|
||||||
|
|
||||||
if (archeryManager.canSkillShot()) {
|
|
||||||
event.setDamage(archeryManager.skillShotCheck(event.getDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) {
|
|
||||||
event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck());
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (archeryManager.canDaze(target)) {
|
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||||
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (archeryManager.canTrackArrows()) {
|
if (swordsManager.canUseCounterAttack()) {
|
||||||
archeryManager.trackArrows(target);
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
archeryManager.distanceXpBonus(target);
|
|
||||||
startGainXp(UserManager.getPlayer(shooter), target, SkillType.ARCHERY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +574,7 @@ public final class CombatUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldProcessSkill(LivingEntity target, SkillType skill) {
|
public static boolean shouldProcessSkill(Entity target, SkillType skill) {
|
||||||
boolean process;
|
boolean process;
|
||||||
|
|
||||||
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
|
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
|
||||||
|
@ -612,12 +612,8 @@ public class SkillUtils {
|
|||||||
return chance > Misc.getRandom().nextInt(activationChance);
|
return chance > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean activationSuccessful(Player player, SkillType skill, double chance) {
|
public static boolean activationSuccessful(int skillLevel, int activationChance, double maxChance, int maxLevel) {
|
||||||
return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill));
|
return ((maxChance / maxLevel) * Math.min(skillLevel, maxLevel)) > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) {
|
|
||||||
return UserManager.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean treasureDropSuccessful(double dropChance, int activationChance) {
|
public static boolean treasureDropSuccessful(double dropChance, int activationChance) {
|
||||||
|
Loading…
Reference in New Issue
Block a user