mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Move standard activation checks into activation function, Archery refactoring, Unarmed cleanup, start work on Axe events.
This commit is contained in:
parent
965035fa72
commit
d6fbf1be34
@ -51,6 +51,7 @@ Version 1.4.07
|
|||||||
+ Added new /mccooldowns command to show all ability cooldowns
|
+ Added new /mccooldowns command to show all ability cooldowns
|
||||||
+ Commands may now both print text and display a scoreboard
|
+ Commands may now both print text and display a scoreboard
|
||||||
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
|
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
|
||||||
|
= Fixed McMMOPlayerDisarmEvent reporting the skill level of the defending player, not the attacking player.
|
||||||
= Fixed bug where arrow retrieval was not properly detecting entities that already existed in the tracker
|
= Fixed bug where arrow retrieval was not properly detecting entities that already existed in the tracker
|
||||||
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||||
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
||||||
|
@ -757,6 +757,10 @@ public class McMMOPlayer {
|
|||||||
ToolType tool = skill.getTool();
|
ToolType tool = skill.getTool();
|
||||||
AbilityType ability = skill.getAbility();
|
AbilityType ability = skill.getAbility();
|
||||||
|
|
||||||
|
if (!getToolPreparationMode(tool) || !ability.getPermissions(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setToolPreparationMode(tool, false);
|
setToolPreparationMode(tool, false);
|
||||||
|
|
||||||
if (getAbilityMode(ability)) {
|
if (getAbilityMode(ability)) {
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.axes;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerCombatEvent;
|
||||||
|
|
||||||
|
public class McMMOPlayerAxeCombatEvent extends McMMOPlayerCombatEvent {
|
||||||
|
public McMMOPlayerAxeCombatEvent(Player player, Entity damager, Entity damagee, DamageCause cause, double damage) {
|
||||||
|
super(player, damager, damagee, cause, damage, SkillType.AXES);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.axes;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
public abstract class McMMOPlayerAxeEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
protected McMMOPlayerAxeEvent(Player player) {
|
||||||
|
super(player, SkillType.AXES);
|
||||||
|
cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.unarmed;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class McMMOPlayerDeflectEvent extends McMMOPlayerUnarmedEvent {
|
||||||
|
public McMMOPlayerDeflectEvent(Player player) {
|
||||||
|
super(player);
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,27 @@
|
|||||||
package com.gmail.nossr50.events.skills.unarmed;
|
package com.gmail.nossr50.events.skills.unarmed;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
public class McMMOPlayerDisarmEvent extends McMMOPlayerUnarmedEvent {
|
||||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
|
||||||
|
|
||||||
public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
|
||||||
private boolean cancelled;
|
|
||||||
private Player defender;
|
private Player defender;
|
||||||
|
private ItemStack droppedItem;
|
||||||
|
|
||||||
public McMMOPlayerDisarmEvent(Player defender) {
|
public McMMOPlayerDisarmEvent(Player attacker, Player defender) {
|
||||||
super(defender, SkillType.UNARMED);
|
super(attacker);
|
||||||
this.defender = defender;
|
this.defender = defender;
|
||||||
|
this.setDroppedItem(defender.getItemInHand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getDefender() {
|
public Player getDefender() {
|
||||||
return defender;
|
return defender;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Following are required for Cancellable **/
|
public ItemStack getDroppedItem() {
|
||||||
@Override
|
return droppedItem;
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setDroppedItem(ItemStack droppedItem) {
|
||||||
public void setCancelled(boolean cancelled) {
|
this.droppedItem = droppedItem;
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.unarmed;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
public abstract class McMMOPlayerUnarmedEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
protected McMMOPlayerUnarmedEvent(Player player) {
|
||||||
|
super(player, SkillType.UNARMED);
|
||||||
|
cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,6 @@ import com.gmail.nossr50.config.HiddenConfig;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||||
@ -148,9 +147,7 @@ public class BlockListener implements Listener {
|
|||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||||
|
|
||||||
/* Green Terra */
|
/* Green Terra */
|
||||||
if (herbalismManager.canActivateAbility()) {
|
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
* We don't check the block store here because herbalism has too many unusual edge cases.
|
||||||
@ -279,19 +276,19 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
if (ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState))) {
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
else if (ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState)) {
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.WOODCUTTING);
|
mcMMOPlayer.checkAbilityActivation(SkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
else if (ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState)) {
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.MINING);
|
mcMMOPlayer.checkAbilityActivation(SkillType.MINING);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
else if (ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState)) {
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.EXCAVATION);
|
mcMMOPlayer.checkAbilityActivation(SkillType.EXCAVATION);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
else if (heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState))) {
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
|
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,25 +25,13 @@ public class ArcheryManager extends SkillManager {
|
|||||||
super(mcMMOPlayer, SkillType.ARCHERY);
|
super(mcMMOPlayer, SkillType.ARCHERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDaze(LivingEntity target) {
|
|
||||||
return target instanceof Player && Permissions.daze(getPlayer()) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUseSkillShot() {
|
|
||||||
return getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(getPlayer(), skill);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canTrack(Arrow arrow) {
|
|
||||||
return Permissions.arrowRetrieval(getPlayer()) && !arrow.hasMetadata(mcMMO.infiniteArrowKey) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate bonus XP awarded for Archery when hitting a far-away target.
|
* Calculate bonus XP awarded for Archery when hitting a far-away target.
|
||||||
*
|
*
|
||||||
* @param target The {@link LivingEntity} damaged by the arrow
|
* @param target The {@link LivingEntity} damaged by the arrow
|
||||||
* @param damager The {@link Entity} who shot the arrow
|
* @param damager The {@link Entity} who shot the arrow
|
||||||
*/
|
*/
|
||||||
public void distanceXpBonus(LivingEntity target, Entity damager) {
|
public void awardDistanceXpBonus(LivingEntity target, Entity damager) {
|
||||||
Location firedLocation = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
|
Location firedLocation = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
|
||||||
Location targetLocation = target.getLocation();
|
Location targetLocation = target.getLocation();
|
||||||
|
|
||||||
@ -134,4 +122,16 @@ public class ArcheryManager extends SkillManager {
|
|||||||
|
|
||||||
return archeryBonus;
|
return archeryBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canDaze(LivingEntity target) {
|
||||||
|
return target instanceof Player && Permissions.daze(getPlayer()) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseSkillShot() {
|
||||||
|
return getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(getPlayer(), skill);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canTrack(Arrow arrow) {
|
||||||
|
return Permissions.arrowRetrieval(getPlayer()) && !arrow.hasMetadata(mcMMO.infiniteArrowKey) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@ -43,10 +42,6 @@ public class AxesManager extends SkillManager {
|
|||||||
return target.isValid() && mcMMOPlayer.getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
|
return target.isValid() && mcMMOPlayer.getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canActivateAbility() {
|
|
||||||
return mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the effects of the Axe Mastery ability
|
* Handle the effects of the Axe Mastery ability
|
||||||
*
|
*
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
@ -21,10 +20,6 @@ public class SwordsManager extends SkillManager {
|
|||||||
super(mcMMOPlayer, SkillType.SWORDS);
|
super(mcMMOPlayer, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canActivateAbility() {
|
|
||||||
return mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && Permissions.serratedStrikes(getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUseBleed() {
|
public boolean canUseBleed() {
|
||||||
return Permissions.bleed(getPlayer());
|
return Permissions.bleed(getPlayer());
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,15 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.bukkit.material.SmoothBrick;
|
import org.bukkit.material.SmoothBrick;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
|
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDeflectEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
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.CombatUtils;
|
||||||
@ -37,14 +39,20 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && Permissions.berserk(getPlayer());
|
return mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && Permissions.berserk(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDisarm(LivingEntity target) {
|
private boolean canDisarm(LivingEntity target) {
|
||||||
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer());
|
if (target instanceof Player) {
|
||||||
|
Player defender = (Player) target;
|
||||||
|
|
||||||
|
return defender.getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer()) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDeflect() {
|
private boolean canDeflect() {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
return player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player);
|
return skill.getPVPEnabled() && player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBlockCracker() {
|
public boolean canUseBlockCracker() {
|
||||||
@ -78,31 +86,47 @@ public class UnarmedManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Check for disarm.
|
* Check for disarm.
|
||||||
*
|
*
|
||||||
* @param defender The defending player
|
* @param target The defending {@link LivingEntity}
|
||||||
*/
|
*/
|
||||||
public void disarmCheck(Player defender) {
|
public void disarm(LivingEntity target) {
|
||||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
|
if (!canDisarm(target)) {
|
||||||
if (EventUtils.callDisarmEvent(defender).isCancelled()) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Misc.dropItem(defender.getLocation(), defender.getItemInHand());
|
|
||||||
|
|
||||||
defender.setItemInHand(new ItemStack(Material.AIR));
|
|
||||||
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player defender = (Player) target;
|
||||||
|
|
||||||
|
McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(getPlayer(), defender);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Misc.dropItem(defender.getLocation(), event.getDroppedItem());
|
||||||
|
|
||||||
|
defender.setItemInHand(new ItemStack(Material.AIR));
|
||||||
|
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for arrow deflection.
|
* Check for arrow deflection.
|
||||||
*/
|
*/
|
||||||
public boolean deflectCheck() {
|
public boolean deflect() {
|
||||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
|
if (!canDeflect()) {
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
McMMOPlayerDeflectEvent event = new McMMOPlayerDeflectEvent(player);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,6 @@ import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
|||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
@ -182,11 +181,4 @@ public class EventUtils {
|
|||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerDisarmEvent callDisarmEvent(Player defender) {
|
|
||||||
McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(defender);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,7 @@ public final class CombatUtils {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||||
|
|
||||||
if (swordsManager.canActivateAbility()) {
|
mcMMOPlayer.checkAbilityActivation(SkillType.SWORDS);
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.SWORDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (swordsManager.canUseBleed()) {
|
if (swordsManager.canUseBleed()) {
|
||||||
swordsManager.bleedCheck(target);
|
swordsManager.bleedCheck(target);
|
||||||
@ -65,35 +63,33 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
||||||
double initialDamage = event.getDamage();
|
double initialDamage = event.getDamage();
|
||||||
double finalDamage = initialDamage;
|
double bonusDamage = 0;
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
||||||
|
|
||||||
if (axesManager.canActivateAbility()) {
|
mcMMOPlayer.checkAbilityActivation(SkillType.AXES);
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.AXES);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (axesManager.canUseAxeMastery()) {
|
if (axesManager.canUseAxeMastery()) {
|
||||||
finalDamage += axesManager.axeMastery(target);
|
bonusDamage += axesManager.axeMastery(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canCriticalHit(target)) {
|
if (axesManager.canCriticalHit(target)) {
|
||||||
finalDamage += axesManager.criticalHit(target, initialDamage);
|
bonusDamage += axesManager.criticalHit(target, initialDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canImpact(target)) {
|
if (axesManager.canImpact(target)) {
|
||||||
axesManager.impactCheck(target);
|
axesManager.impactCheck(target);
|
||||||
}
|
}
|
||||||
else if (axesManager.canGreaterImpact(target)) {
|
else if (axesManager.canGreaterImpact(target)) {
|
||||||
finalDamage += axesManager.greaterImpact(target);
|
bonusDamage += axesManager.greaterImpact(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canUseSkullSplitter(target)) {
|
if (axesManager.canUseSkullSplitter(target)) {
|
||||||
axesManager.skullSplitterCheck(target, initialDamage);
|
axesManager.skullSplitterCheck(target, initialDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setDamage(finalDamage);
|
event.setDamage(initialDamage + bonusDamage);
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,9 +100,7 @@ public final class CombatUtils {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||||
|
|
||||||
if (unarmedManager.canActivateAbility()) {
|
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unarmedManager.canUseIronArm()) {
|
if (unarmedManager.canUseIronArm()) {
|
||||||
finalDamage += unarmedManager.ironArm(target);
|
finalDamage += unarmedManager.ironArm(target);
|
||||||
@ -116,9 +110,7 @@ public final class CombatUtils {
|
|||||||
finalDamage += unarmedManager.berserkDamage(target, initialDamage);
|
finalDamage += unarmedManager.berserkDamage(target, initialDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unarmedManager.canDisarm(target)) {
|
unarmedManager.disarm(target);
|
||||||
unarmedManager.disarmCheck((Player) target);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setDamage(finalDamage);
|
event.setDamage(finalDamage);
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||||
@ -148,31 +140,28 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) {
|
private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) {
|
||||||
|
if (target instanceof Player) {
|
||||||
|
UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager();
|
||||||
|
event.setCancelled(unarmedManager.deflect());
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double initialDamage = event.getDamage();
|
double initialDamage = event.getDamage();
|
||||||
double finalDamage = initialDamage;
|
double bonusDamage = 0;
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||||
|
|
||||||
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled()) {
|
bonusDamage += archeryManager.skillShot(target, initialDamage, arrow);
|
||||||
UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager();
|
bonusDamage += archeryManager.daze(target, arrow);
|
||||||
|
|
||||||
if (unarmedManager.canDeflect()) {
|
|
||||||
event.setCancelled(unarmedManager.deflectCheck());
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalDamage += archeryManager.skillShot(target, initialDamage, arrow);
|
|
||||||
finalDamage += archeryManager.daze(target, arrow);
|
|
||||||
|
|
||||||
archeryManager.trackArrow(target, arrow);
|
archeryManager.trackArrow(target, arrow);
|
||||||
archeryManager.distanceXpBonus(target, arrow);
|
archeryManager.awardDistanceXpBonus(target, arrow);
|
||||||
|
|
||||||
event.setDamage(finalDamage);
|
event.setDamage(initialDamage + bonusDamage);
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY, arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble());
|
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY, arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user