1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2025-07-04 22:54:44 +02:00

Custom tools - should now support enabling/disabling ability activation

per tool.
This commit is contained in:
GJ
2012-05-15 13:44:39 -04:00
parent 81ac4e8d01
commit 29ee8a035b
3 changed files with 72 additions and 7 deletions
src/main/java/com/gmail/nossr50

@ -366,6 +366,14 @@ public class Combat {
* @param type The type of skill being used
*/
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
ItemStack inHand = attacker.getItemInHand();
if (Config.getInstance().getToolModsEnabled()) {
if (ItemChecks.isCustomTool(inHand) && !ModChecks.toolAbilityEnabled(inHand)) {
return;
}
}
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
int damageAmount = damage;
@ -373,6 +381,7 @@ public class Combat {
damageAmount = 1;
}
//TODO: Looking at this, I think it's busted. Need to test to confirm.
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
if (!(entity instanceof LivingEntity)) {
continue;

@ -0,0 +1,25 @@
package com.gmail.nossr50.util;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.mods.LoadCustomTools;
import com.gmail.nossr50.datatypes.mods.CustomTool;
public class ModChecks {
/**
* Check if this custom tool can use abilities.
*
* @param item The custom item to check
* @return true if the tool can use abilities, false otherwise
*/
public static boolean toolAbilityEnabled(ItemStack item) {
for (CustomTool tool : LoadCustomTools.getInstance().customTools) {
if (tool.getItemID() == item.getTypeId()) {
return tool.isAbilityEnabled();
}
}
return false;
}
}