mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Custom tools - should now support enabling/disabling ability activation
per tool.
This commit is contained in:
parent
81ac4e8d01
commit
29ee8a035b
@ -16,6 +16,7 @@ import com.gmail.nossr50.skills.misc.Repair;
|
|||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Skills;
|
import com.gmail.nossr50.util.Skills;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
@ -185,7 +186,14 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
|
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
|
||||||
WoodCutting.treeFeller(event);
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
|
if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) {
|
||||||
|
WoodCutting.treeFeller(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WoodCutting.treeFeller(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -252,12 +260,27 @@ public class BlockListener implements Listener {
|
|||||||
* ABILITY TRIGGER CHECKS
|
* ABILITY TRIGGER CHECKS
|
||||||
*/
|
*/
|
||||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) {
|
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||||
Herbalism.greenTerra(player, block);
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
|
if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) {
|
||||||
|
Herbalism.greenTerra(player, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Herbalism.greenTerra(player, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
||||||
event.setInstaBreak(true);
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
Excavation.gigaDrillBreaker(player, block);
|
if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) {
|
||||||
|
event.setInstaBreak(true);
|
||||||
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.setInstaBreak(true);
|
||||||
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
@ -277,10 +300,18 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||||
if(!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
if (!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { //TODO: Why are we checking this?
|
||||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
|
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
|
||||||
event.setInstaBreak(true);
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
Mining.SuperBreakerBlockCheck(player, block);
|
if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) {
|
||||||
|
event.setInstaBreak(true);
|
||||||
|
Mining.SuperBreakerBlockCheck(player, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.setInstaBreak(true);
|
||||||
|
Mining.SuperBreakerBlockCheck(player, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
else if (!Config.getInstance().getMiningRequiresTool()) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
|
@ -366,6 +366,14 @@ public class Combat {
|
|||||||
* @param type The type of skill being used
|
* @param type The type of skill being used
|
||||||
*/
|
*/
|
||||||
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
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 numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
||||||
int damageAmount = damage;
|
int damageAmount = damage;
|
||||||
|
|
||||||
@ -373,6 +381,7 @@ public class Combat {
|
|||||||
damageAmount = 1;
|
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)) {
|
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||||
if (!(entity instanceof LivingEntity)) {
|
if (!(entity instanceof LivingEntity)) {
|
||||||
continue;
|
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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user