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:
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;
|
||||
|
25
src/main/java/com/gmail/nossr50/util/ModChecks.java
Normal file
25
src/main/java/com/gmail/nossr50/util/ModChecks.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user