Static Abuse Removal - ComatUtils -> CombatTools

This commit is contained in:
nossr50 2019-07-04 05:22:52 -07:00
parent 084b5edf1f
commit 381eba8ddc
25 changed files with 203 additions and 221 deletions

View File

@ -12,6 +12,7 @@ Version 2.2.0
Parties no longer have a cap, you can level them forever for bragging rights Parties no longer have a cap, you can level them forever for bragging rights
You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks) You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks)
Repair config has been rewritten and expanded to support much more complex settings Repair config has been rewritten and expanded to support much more complex settings
Fixed a bug where salvage anvil noises wouldn't play for a player that lacked repair permissions nodes
Removed the following Repair/Salvage permissions Removed the following Repair/Salvage permissions
mcmmo.ability.repair.stonerepair mcmmo.ability.repair.stonerepair
mcmmo.ability.repair.stringrepair mcmmo.ability.repair.stringrepair

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.util.skills.CombatUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -75,7 +74,7 @@ public class ArcheryCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))));
} }
return messages; return messages;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
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.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -95,7 +94,7 @@ public class AxesCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK))));
} }
return messages; return messages;

View File

@ -32,11 +32,11 @@ public abstract class SkillCommand implements TabExecutor {
private CommandExecutor skillGuideCommand; private CommandExecutor skillGuideCommand;
protected mcMMO pluginRef; protected mcMMO pluginRef;
public SkillCommand(PrimarySkillType skill, mcMMO pluginRef) { public SkillCommand(PrimarySkillType primarySkillType, mcMMO pluginRef) {
this.pluginRef = pluginRef; this.pluginRef = pluginRef;
this.skill = skill; this.skill = primarySkillType;
skillName = skill.getLocalizedSkillName(); skillName = pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType);
skillGuideCommand = new SkillGuideCommand(skill, pluginRef); skillGuideCommand = new SkillGuideCommand(primarySkillType, pluginRef);
} }
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) { public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
@ -145,7 +145,7 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", skillName)); player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", skillName));
if (!skill.isChildSkill()) { if (!pluginRef.getSkillTools().isChildSkill(skill)) {
/* /*
* NON-CHILD SKILLS * NON-CHILD SKILLS
*/ */
@ -173,10 +173,10 @@ public abstract class SkillCommand implements TabExecutor {
for (int i = 0; i < parentList.size(); i++) { for (int i = 0; i < parentList.size(); i++) {
if (i + 1 < parentList.size()) { if (i + 1 < parentList.size()) {
parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", parentList.get(i).getLocalizedSkillName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", pluginRef.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i))));
parentMessage.append(ChatColor.GRAY + ", "); parentMessage.append(ChatColor.GRAY + ", ");
} else { } else {
parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", parentList.get(i).getLocalizedSkillName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", pluginRef.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i))));
} }
} }
@ -210,9 +210,9 @@ public abstract class SkillCommand implements TabExecutor {
protected String[] formatLengthDisplayValues(Player player, double skillValue) { protected String[] formatLengthDisplayValues(Player player, double skillValue) {
int length = pluginRef.getSkillTools().calculateAbilityLength(pluginRef.getUserManager().getPlayer(player), skill, skill.getSuperAbility()); int length = pluginRef.getSkillTools().calculateAbilityLength(pluginRef.getUserManager().getPlayer(player), skill, pluginRef.getSkillTools().getSuperAbility(skill));
int enduranceLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(pluginRef.getUserManager().getPlayer(player), skill, skill.getSuperAbility()); int enduranceLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(pluginRef.getUserManager().getPlayer(player), skill, pluginRef.getSkillTools().getSuperAbility(skill));
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)}; return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
} }
@ -223,7 +223,7 @@ public abstract class SkillCommand implements TabExecutor {
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) { protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) {
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template"; String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription(); String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription(pluginRef) : subSkillType.getLocaleKeyStatExtraDescription(pluginRef);
if (isCustom) if (isCustom)
return pluginRef.getLocaleManager().getString(templateKey, pluginRef.getLocaleManager().getString(statDescriptionKey, vars)); return pluginRef.getLocaleManager().getString(templateKey, pluginRef.getLocaleManager().getString(statDescriptionKey, vars));

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
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.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -101,7 +100,7 @@ public class SwordsCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))));
} }
return messages; return messages;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
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.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -113,7 +112,7 @@ public class UnarmedCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))));
} }
return messages; return messages;

View File

@ -131,30 +131,8 @@ public enum SubSkillType {
* *
* @return * @return
*/ */
public PrimarySkillType getParentSkill() { public PrimarySkillType getParentSkill(mcMMO pluginRef) {
return PrimarySkillType.getPrimarySkillBySubSkill(this); return pluginRef.getSkillTools().getPrimarySkillBySubSkill(this);
}
/**
* Returns the root address for this skill in the advanced.yml file
*
* @return the root address for this skill in advanced.yml
*/
public String[] getAdvConfigAddress() {
//return "Skills." + StringUtils.getCapitalized(getParentSkill().toString()) + "." + getConfigName(toString());
//TODO: Reduce string operations
return new String[]{"Skills", StringUtils.getCapitalized(getParentSkill().toString()), getConfigName(toString())};
}
/**
* Returns the root address for this skill in the rankskills.yml file
*
* @return the root address for this skill in rankskills.yml
*/
public String[] getRankConfigAddress() {
//return StringUtils.getCapitalized(getParentSkill().toString()) + "." + getConfigName(toString());
//TODO: Reduce string operations
return new String[]{StringUtils.getCapitalized(getParentSkill().toString()), getConfigName(toString())};
} }
/** /**
@ -162,9 +140,9 @@ public enum SubSkillType {
* *
* @return the permission node for this subskill * @return the permission node for this subskill
*/ */
public String getPermissionNodeAddress() { public String getPermissionNodeAddress(mcMMO pluginRef) {
//TODO: This could be optimized //TODO: This could be optimized
return "mcmmo.ability." + getParentSkill().toString().toLowerCase() + "." + getConfigName(toString()).toLowerCase(); return "mcmmo.ability." + getParentSkill(pluginRef).toString().toLowerCase() + "." + getConfigName(toString()).toLowerCase();
} }
/** /**
@ -270,7 +248,7 @@ public enum SubSkillType {
* @return The parent skill as defined in the locale * @return The parent skill as defined in the locale
*/ */
public String getParentNiceNameLocale(mcMMO pluginRef) { public String getParentNiceNameLocale(mcMMO pluginRef) {
return pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(getParentSkill().toString()) + ".SkillName"); return pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(getParentSkill(pluginRef).toString()) + ".SkillName");
} }
/** /**
@ -304,8 +282,8 @@ public enum SubSkillType {
return subStringIndex; return subStringIndex;
} }
public String getLocaleKeyRoot() { public String getLocaleKeyRoot(mcMMO pluginRef) {
return StringUtils.getCapitalized(getParentSkill().toString()) + ".SubSkill." + getConfigName(toString()); return StringUtils.getCapitalized(getParentSkill(pluginRef).toString()) + ".SubSkill." + getConfigName(toString());
} }
public String getLocaleName(mcMMO pluginRef) { public String getLocaleName(mcMMO pluginRef) {
@ -320,16 +298,16 @@ public enum SubSkillType {
return getFromLocaleSubAddress(pluginRef,".Stat"); return getFromLocaleSubAddress(pluginRef,".Stat");
} }
public String getLocaleKeyStatDescription() { public String getLocaleKeyStatDescription(mcMMO pluginRef) {
return getLocaleKeyFromSubAddress(".Stat"); return getLocaleKeyFromSubAddress(pluginRef, ".Stat");
} }
public String getLocaleStatExtraDescription(mcMMO pluginRef) { public String getLocaleStatExtraDescription(mcMMO pluginRef) {
return getFromLocaleSubAddress(pluginRef,".Stat.Extra"); return getFromLocaleSubAddress(pluginRef,".Stat.Extra");
} }
public String getLocaleKeyStatExtraDescription() { public String getLocaleKeyStatExtraDescription(mcMMO pluginRef) {
return getLocaleKeyFromSubAddress(".Stat.Extra"); return getLocaleKeyFromSubAddress(pluginRef, ".Stat.Extra");
} }
public String getLocaleStat(mcMMO pluginRef, String... vars) { public String getLocaleStat(mcMMO pluginRef, String... vars) {
@ -343,10 +321,10 @@ public enum SubSkillType {
} }
private String getFromLocaleSubAddress(mcMMO pluginRef, String s) { private String getFromLocaleSubAddress(mcMMO pluginRef, String s) {
return pluginRef.getLocaleManager().getString(getLocaleKeyRoot() + s); return pluginRef.getLocaleManager().getString(getLocaleKeyRoot(pluginRef) + s);
} }
private String getLocaleKeyFromSubAddress(String s) { private String getLocaleKeyFromSubAddress(mcMMO pluginRef, String subAddress) {
return getLocaleKeyRoot() + s; return getLocaleKeyRoot(pluginRef) + subAddress;
} }
} }

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.datatypes.skills.behaviours; package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
/** /**
* These behaviour classes are a band-aid fix for a larger problem * These behaviour classes are a band-aid fix for a larger problem
@ -12,9 +13,14 @@ import com.gmail.nossr50.mcMMO;
public class RepairBehaviour { public class RepairBehaviour {
private final mcMMO pluginRef; private final mcMMO pluginRef;
private final Material anvilMaterial;
public RepairBehaviour(mcMMO pluginRef) { public RepairBehaviour(mcMMO pluginRef) {
this.pluginRef = pluginRef; this.pluginRef = pluginRef;
this.anvilMaterial = pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().getRepairAnvilMaterial();
} }
public Material getAnvilMaterial() {
return anvilMaterial;
}
} }

View File

@ -10,11 +10,8 @@ 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.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
@ -166,10 +163,6 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
@ -181,20 +174,22 @@ public class BlockListener implements Listener {
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (blockState.getType() == Repair.getInstance().getAnvilMaterial()
&& PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player)) {
if (mcMMOPlayer == null) if (mcMMOPlayer == null)
return; return;
if (blockState.getType() == Repair.getInstance().getAnvilMaterial() Material repairAnvil = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial();
&& PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player)) { Material salvageAnvil = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial();
if (blockState.getType() == repairAnvil
&& pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player)) {
//Make some noise
mcMMOPlayer.getRepairManager().placedAnvilCheck(); mcMMOPlayer.getRepairManager().placedAnvilCheck();
} else if (blockState.getType() == Salvage.anvilMaterial
&& PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player)) { } else if (blockState.getType() == salvageAnvil
&& pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player)) {
mcMMOPlayer.getSalvageManager().placedAnvilCheck(); mcMMOPlayer.getSalvageManager().placedAnvilCheck();
} }
} }
}
/** /**
* Monitor BlockMultiPlace events. * Monitor BlockMultiPlace events.
@ -297,19 +292,19 @@ public class BlockListener implements Listener {
* 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.
* Instead, we check it inside the drops handler. * Instead, we check it inside the drops handler.
*/ */
if (PrimarySkillType.HERBALISM.doesPlayerHaveSkillPermission(player)) { if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.HERBALISM, player)) {
herbalismManager.herbalismBlockCheck(blockState); herbalismManager.herbalismBlockCheck(blockState);
} }
} }
/* MINING */ /* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.doesPlayerHaveSkillPermission(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.MINING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState); miningManager.miningBlockCheck(blockState);
} }
/* WOOD CUTTING */ /* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.doesPlayerHaveSkillPermission(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.WOODCUTTING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) { if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState); woodcuttingManager.processTreeFeller(blockState);
@ -319,7 +314,7 @@ public class BlockListener implements Listener {
} }
/* EXCAVATION */ /* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.doesPlayerHaveSkillPermission(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.EXCAVATION, player) && !pluginRef.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState); excavationManager.excavationBlockCheck(blockState);
@ -367,7 +362,7 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (Herbalism.isRecentlyRegrown(blockState)) { if (pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getHerbalismBehaviour().isRecentlyRegrown(blockState)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -8,8 +8,6 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.mining.BlastMining;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
@ -18,7 +16,6 @@ import com.gmail.nossr50.util.BlockUtils;
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.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.Material; import org.bukkit.Material;
@ -327,7 +324,7 @@ public class EntityListener implements Listener {
LivingEntity target = (LivingEntity) defender; LivingEntity target = (LivingEntity) defender;
if (CombatUtils.isInvincible(target, damage)) { if (pluginRef.getCombatTools().isInvincible(target, damage)) {
return; return;
} }
@ -342,7 +339,7 @@ public class EntityListener implements Listener {
attacker = (Entity) animalTamer; attacker = (Entity) animalTamer;
} }
} else if (attacker instanceof TNTPrimed && defender instanceof Player) { } else if (attacker instanceof TNTPrimed && defender instanceof Player) {
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) { if (pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getMiningBehaviour().processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
return; return;
} }
} }
@ -406,18 +403,18 @@ public class EntityListener implements Listener {
return; return;
} }
CombatUtils.processCombatAttack(event, attacker, target); pluginRef.getCombatTools().processCombatAttack(event, attacker, target);
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage(), pluginRef); pluginRef.getCombatTools().handleHealthbars(attacker, target, event.getFinalDamage(), pluginRef);
/** /**
* This sets entity names back to whatever they are supposed to be * This sets entity names back to whatever they are supposed to be
*/ */
if (event.getFinalDamage() >= target.getHealth()) { if (event.getFinalDamage() >= target.getHealth()) {
if (attacker instanceof LivingEntity) { if (attacker instanceof LivingEntity) {
CombatUtils.fixNames((LivingEntity) attacker); pluginRef.getCombatTools().fixNames((LivingEntity) attacker);
} }
CombatUtils.fixNames(target); pluginRef.getCombatTools().fixNames(target);
} }
} }
@ -501,7 +498,7 @@ public class EntityListener implements Listener {
LivingEntity livingEntity = (LivingEntity) entity; LivingEntity livingEntity = (LivingEntity) entity;
if (CombatUtils.isInvincible(livingEntity, damage)) { if (pluginRef.getCombatTools().isInvincible(livingEntity, damage)) {
return; return;
} }
@ -661,7 +658,7 @@ public class EntityListener implements Listener {
return; return;
} }
Archery.arrowRetrievalCheck(entity); pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getArcheryBehaviour().arrowRetrievalCheck(entity);
} }
/** /**
@ -986,7 +983,7 @@ public class EntityListener implements Listener {
Tameable tameable = (Tameable) entity; Tameable tameable = (Tameable) entity;
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getCombatTools().isFriendlyPet(player, tameable)) {
return; return;
} }

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
@ -9,7 +8,6 @@ import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand; import org.bukkit.block.BrewingStand;
@ -135,7 +133,7 @@ public class InventoryListener implements Listener {
return; return;
} }
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.doesPlayerHaveSkillPermission(player)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SMELTING, player)) {
return; return;
} }
@ -401,16 +399,35 @@ public class InventoryListener implements Listener {
} }
ItemStack item = event.getItem(); ItemStack item = event.getItem();
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
if (MainConfig.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) { //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
event.setCancelled(true); //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
return; //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
} //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
if (MainConfig.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) { //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
event.setCancelled(true); //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
return; //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
} //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
//TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced
// if (MainConfig.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
// event.setCancelled(true);
// return;
// }
//
// if (MainConfig.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
// event.setCancelled(true);
// return;
// }
// if (MainConfig.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) { // if (MainConfig.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
// AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder); // AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);

View File

@ -14,9 +14,7 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.*;
@ -252,7 +250,7 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.doesPlayerHaveSkillPermission(player)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.FISHING, player)) {
return; return;
} }
@ -327,7 +325,7 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.doesPlayerHaveSkillPermission(player)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.FISHING, player)) {
return; return;
} }
@ -592,8 +590,8 @@ public class PlayerListener implements Listener {
if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) {
/* REPAIR CHECKS */ /* REPAIR CHECKS */
if (type == Repair.getInstance().getAnvilMaterial() if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial()
&& PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player)
&& pluginRef.getRepairableManager().isRepairable(heldItem) && pluginRef.getRepairableManager().isRepairable(heldItem)
&& heldItem.getAmount() <= 1) { && heldItem.getAmount() <= 1) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = mcMMOPlayer.getRepairManager();
@ -606,8 +604,8 @@ public class PlayerListener implements Listener {
} }
} }
/* SALVAGE CHECKS */ /* SALVAGE CHECKS */
else if (type == Salvage.anvilMaterial else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial()
&& PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player)
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& pluginRef.getSalvageableManager().isSalvageable(heldItem) && pluginRef.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) { && heldItem.getAmount() <= 1) {
@ -634,30 +632,32 @@ public class PlayerListener implements Listener {
break; break;
case LEFT_CLICK_BLOCK: case LEFT_CLICK_BLOCK:
type = block.getType(); //TODO: Not sure why this code is here, I disabled it for now.
//TODO: Not sure why this code is here, I disabled it for now.
if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { //TODO: Not sure why this code is here, I disabled it for now.
/* REPAIR CHECKS */ // type = block.getType();
if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player) && pluginRef.getRepairableManager().isRepairable(heldItem)) { // if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); // /* REPAIR CHECKS */
// if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player) && pluginRef.getRepairableManager().isRepairable(heldItem)) {
// Cancel repairing an enchanted item // RepairManager repairManager = mcMMOPlayer.getRepairManager();
if (repairManager.checkConfirmation(false)) { //
repairManager.setLastAnvilUse(0); // // Cancel repairing an enchanted item
player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Repair.Pretty.Name"))); // if (repairManager.checkConfirmation(false)) {
} // repairManager.setLastAnvilUse(0);
} // player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Repair.Pretty.Name")));
/* SALVAGE CHECKS */ // }
else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player) && pluginRef.getSalvageableManager().isSalvageable(heldItem)) { // }
SalvageManager salvageManager = mcMMOPlayer.getSalvageManager(); // /* SALVAGE CHECKS */
// else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player) && pluginRef.getSalvageableManager().isSalvageable(heldItem)) {
// Cancel salvaging an enchanted item // SalvageManager salvageManager = mcMMOPlayer.getSalvageManager();
if (salvageManager.checkConfirmation(false)) { //
salvageManager.setLastAnvilUse(0); // // Cancel salvaging an enchanted item
player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Salvage.Pretty.Name"))); // if (salvageManager.checkConfirmation(false)) {
} // salvageManager.setLastAnvilUse(0);
} // player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Salvage.Pretty.Name")));
} // }
// }
// }
break; break;
@ -880,11 +880,11 @@ public class PlayerListener implements Listener {
String lowerCaseCommand = command.toLowerCase(); String lowerCaseCommand = command.toLowerCase();
// Do these ACTUALLY have to be lower case to work properly? // Do these ACTUALLY have to be lower case to work properly?
for (PrimarySkillType skill : PrimarySkillType.values()) { for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
String skillName = skill.toString().toLowerCase(); String skillName = primarySkillType.toString().toLowerCase();
String localizedName = skill.getLocalizedSkillName().toLowerCase(); String localizedName = pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType).toLowerCase();
if (lowerCaseCommand.equals(localizedName)) { if (command.equalsIgnoreCase(localizedName)) {
event.setMessage(message.replace(command, skillName)); event.setMessage(message.replace(command, skillName));
break; break;
} }
@ -895,17 +895,4 @@ public class PlayerListener implements Listener {
} }
} }
} }
/*@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
*//* WORLD BLACKLIST CHECK *//*
if(pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getPlayer().getWorld().getName()))
return;
if (!mcMMO.getHolidayManager().isAprilFirst()) {
return;
}
mcMMO.getHolidayManager().handleStatisticEvent(event);
}*/
} }

View File

@ -105,7 +105,7 @@ public class SelfListener implements Listener {
return; return;
} }
if (primarySkillType.isChildSkill()) { if (pluginRef.getSkillTools().isChildSkill(primarySkillType)) {
return; return;
} }
@ -113,7 +113,7 @@ public class SelfListener implements Listener {
double guaranteedMinimum = pluginRef.getConfigManager().getConfigLeveling().getGuaranteedMinimums() * rawXp; double guaranteedMinimum = pluginRef.getConfigManager().getConfigLeveling().getGuaranteedMinimums() * rawXp;
double modifiedThreshold = (double) (threshold / primarySkillType.getXpModifier() * pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); double modifiedThreshold = (double) (threshold / pluginRef.getSkillTools().getXpModifier(primarySkillType) * pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult());
double difference = (mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold; double difference = (mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold;
if (difference > 0) { if (difference > 0) {

View File

@ -39,6 +39,7 @@ import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.PlayerLevelUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.CombatTools;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillTools; import com.gmail.nossr50.util.skills.SkillTools;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
@ -88,6 +89,7 @@ public class mcMMO extends JavaPlugin {
private DatabaseManagerFactory databaseManagerFactory; private DatabaseManagerFactory databaseManagerFactory;
private CommandTools commandTools; private CommandTools commandTools;
private SkillTools skillTools; //TODO: Remove once a new skill system is in place private SkillTools skillTools; //TODO: Remove once a new skill system is in place
private CombatTools combatTools; //TODO: Rewrite this garbo
private TextComponentFactory textComponentFactory; private TextComponentFactory textComponentFactory;
/* Never-Ending tasks */ /* Never-Ending tasks */
@ -239,6 +241,9 @@ public class mcMMO extends JavaPlugin {
//Init Skill Tools //Init Skill Tools
skillTools = new SkillTools(this); skillTools = new SkillTools(this);
//Init Combat Tools
combatTools = new CombatTools(this);
} }
@Override @Override
@ -742,4 +747,8 @@ public class mcMMO extends JavaPlugin {
public SkillTools getSkillTools() { public SkillTools getSkillTools() {
return skillTools; return skillTools;
} }
public CombatTools getCombatTools() {
return combatTools;
}
} }

View File

@ -673,7 +673,7 @@ public final class PartyManager {
ArrayList<Party> hasAlly = new ArrayList<Party>(); ArrayList<Party> hasAlly = new ArrayList<Party>();
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
Party party = new Party(partyName); Party party = new Party(partyName, pluginRef);
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.BleedContainer; import com.gmail.nossr50.datatypes.skills.BleedContainer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
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.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -47,7 +46,7 @@ public class BleedTimerTask extends BukkitRunnable {
*/ */
if (bleedList.containsKey(entity)) { if (bleedList.containsKey(entity)) {
CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity).bleedTicks * 2, bleedList.get(entity).damageSource); pluginRef.getCombatTools().dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity).bleedTicks * 2, bleedList.get(entity).damageSource);
} }
} }
@ -155,7 +154,7 @@ public class BleedTimerTask extends BukkitRunnable {
// debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], "; // debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], ";
CombatUtils.dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier); pluginRef.getCombatTools().dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier);
double victimHealthAftermath = target.getHealth(); double victimHealthAftermath = target.getHealth();

View File

@ -71,7 +71,7 @@ public class AcrobaticsManager extends SkillManager {
return false; return false;
}*/ }*/
return skill.canCombatSkillsTrigger(damager); return pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ACROBATICS, damager);
} }
return false; return false;

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
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.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -173,6 +172,6 @@ public class AxesManager extends SkillManager {
* @param damage The amount of damage initially dealt by the event * @param damage The amount of damage initially dealt by the event
*/ */
public void skullSplitterCheck(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) { public void skullSplitterCheck(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigAxes().getConfigAxesSkullSplitter().getSkullSplitterDamageDivisor(), modifiers, skill); pluginRef.getCombatTools().applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigAxes().getConfigAxesSkullSplitter().getSkullSplitterDamageDivisor(), modifiers, skill);
} }
} }

View File

@ -23,7 +23,6 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -427,7 +426,7 @@ public class FishingManager extends SkillManager {
} }
Misc.dropItem(target.getLocation(), drop); Misc.dropItem(target.getLocation(), drop);
CombatUtils.dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times. pluginRef.getCombatTools().dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times.
applyXpGain(pluginRef.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE); applyXpGain(pluginRef.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE);
} }
} }

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -121,7 +120,7 @@ public class SwordsManager extends SkillManager {
*/ */
public void counterAttackChecks(LivingEntity attacker, double damage) { public void counterAttackChecks(LivingEntity attacker, double damage) {
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) { if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) {
CombatUtils.dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer()); pluginRef.getCombatTools().dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer());
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered"); pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered");
@ -138,6 +137,6 @@ public class SwordsManager extends SkillManager {
* @param damage The amount of damage initially dealt by the event * @param damage The amount of damage initially dealt by the event
*/ */
public void serratedStrikes(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) { public void serratedStrikes(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigSwords().getSerratedStrikesDamageModifier(), modifiers, skill); pluginRef.getCombatTools().applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigSwords().getSerratedStrikesDamageModifier(), modifiers, skill);
} }
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -35,7 +34,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
Location location = livingEntity.getLocation(); Location location = livingEntity.getLocation();
location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F);
ParticleEffectUtils.playCallOfTheWildEffect(livingEntity); ParticleEffectUtils.playCallOfTheWildEffect(livingEntity);
CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); pluginRef.getCombatTools().dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity);
} }
TamingManager.removeFromTracker(this); TamingManager.removeFromTracker(this);

View File

@ -14,7 +14,6 @@ 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.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
@ -107,7 +106,7 @@ public class WoodcuttingManager extends SkillManager {
double health = player.getHealth(); double health = player.getHealth();
if (health > 1) { if (health > 1) {
CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (health - 1))); pluginRef.getCombatTools().dealDamage(player, Misc.getRandom().nextInt((int) (health - 1)));
} }
return; return;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup; import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location; import org.bukkit.Location;
@ -84,7 +83,7 @@ public final class ChimaeraWing {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail");
player.updateInventory(); player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0)); player.setVelocity(new Vector(0, 0.5D, 0));
CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); pluginRef.getCombatTools().dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10)));
mcMMOPlayer.actualizeChimeraWingLastUse(); mcMMOPlayer.actualizeChimeraWingLastUse();
return; return;
} }

View File

@ -31,7 +31,6 @@ import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent; import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.CombatUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -133,7 +132,7 @@ public class EventManager {
LivingEntity livingEntity = (LivingEntity) entity; LivingEntity livingEntity = (LivingEntity) entity;
if (CombatUtils.isInvincible(livingEntity, damage)) { if (pluginRef.getCombatTools().isInvincible(livingEntity, damage)) {
return false; return false;
} }

View File

@ -39,11 +39,14 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public final class CombatUtils { public final class CombatTools {
private CombatUtils() { private final mcMMO pluginRef;
public CombatTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { private void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) { if (event.getCause() == DamageCause.THORNS) {
return; return;
} }
@ -82,7 +85,7 @@ public final class CombatUtils {
startGainXp(mcMMOPlayer, target, PrimarySkillType.SWORDS); startGainXp(mcMMOPlayer, target, PrimarySkillType.SWORDS);
} }
private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { private void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) { if (event.getCause() == DamageCause.THORNS) {
return; return;
} }
@ -124,7 +127,7 @@ public final class CombatUtils {
startGainXp(mcMMOPlayer, target, PrimarySkillType.AXES); startGainXp(mcMMOPlayer, target, PrimarySkillType.AXES);
} }
private static void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { private void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) { if (event.getCause() == DamageCause.THORNS) {
return; return;
} }
@ -163,7 +166,7 @@ public final class CombatUtils {
Unarmed.lastAttacked = System.currentTimeMillis(); //Track how often the player is punching Unarmed.lastAttacked = System.currentTimeMillis(); //Track how often the player is punching
} }
private static void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) { private void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) {
double initialDamage = event.getDamage(); double initialDamage = event.getDamage();
double finalDamage = initialDamage; double finalDamage = initialDamage;
@ -188,7 +191,7 @@ public final class CombatUtils {
startGainXp(mcMMOPlayer, target, PrimarySkillType.TAMING); startGainXp(mcMMOPlayer, target, PrimarySkillType.TAMING);
} }
private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) { private void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) {
double initialDamage = event.getDamage(); double initialDamage = event.getDamage();
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
@ -196,7 +199,8 @@ public final class CombatUtils {
double finalDamage = event.getDamage(); double finalDamage = event.getDamage();
if (target instanceof Player && PrimarySkillType.UNARMED.getPVPEnabled()) { if (target instanceof Player
&& pluginRef.getSkillTools().getPVPEnabled(PrimarySkillType.UNARMED)) {
UnarmedManager unarmedManager = pluginRef.getUserManager().getPlayer((Player) target).getUnarmedManager(); UnarmedManager unarmedManager = pluginRef.getUserManager().getPlayer((Player) target).getUnarmedManager();
if (unarmedManager.canDeflect()) { if (unarmedManager.canDeflect()) {
@ -239,7 +243,7 @@ public final class CombatUtils {
* *
* @param event The event to run the combat checks on. * @param event The event to run the combat checks on.
*/ */
public static void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { public void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
Entity damager = event.getDamager(); Entity damager = event.getDamager();
EntityType entityType = damager.getType(); EntityType entityType = damager.getType();
@ -260,7 +264,7 @@ public final class CombatUtils {
} }
if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) { if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) {
if (!PrimarySkillType.SWORDS.canCombatSkillsTrigger(target)) { if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.SWORDS, target)) {
return; return;
} }
@ -298,27 +302,27 @@ public final class CombatUtils {
} }
if (ItemUtils.isSword(heldItem)) { if (ItemUtils.isSword(heldItem)) {
if (!PrimarySkillType.SWORDS.canCombatSkillsTrigger(target)) { if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.SWORDS, target)) {
return; return;
} }
if (PrimarySkillType.SWORDS.doesPlayerHaveSkillPermission(player)) { if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SWORDS, player)) {
processSwordCombat(target, player, event); processSwordCombat(target, player, event);
} }
} else if (ItemUtils.isAxe(heldItem)) { } else if (ItemUtils.isAxe(heldItem)) {
if (!PrimarySkillType.AXES.canCombatSkillsTrigger(target)) { if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.AXES, target)) {
return; return;
} }
if (PrimarySkillType.AXES.doesPlayerHaveSkillPermission(player)) { if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.AXES, player)) {
processAxeCombat(target, player, event); processAxeCombat(target, player, event);
} }
} else if (ItemUtils.isUnarmed(heldItem)) { } else if (ItemUtils.isUnarmed(heldItem)) {
if (!PrimarySkillType.UNARMED.canCombatSkillsTrigger(target)) { if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.UNARMED, target)) {
return; return;
} }
if (PrimarySkillType.UNARMED.doesPlayerHaveSkillPermission(player)) { if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.UNARMED, player)) {
processUnarmedCombat(target, player, event); processUnarmedCombat(target, player, event);
} }
} }
@ -326,10 +330,10 @@ public final class CombatUtils {
Wolf wolf = (Wolf) damager; Wolf wolf = (Wolf) damager;
AnimalTamer tamer = wolf.getOwner(); AnimalTamer tamer = wolf.getOwner();
if (tamer instanceof Player && PrimarySkillType.TAMING.canCombatSkillsTrigger(target)) { if (tamer instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) {
Player master = (Player) tamer; Player master = (Player) tamer;
if (!Misc.isNPCEntityExcludingVillagers(master) && PrimarySkillType.TAMING.doesPlayerHaveSkillPermission(master)) { if (!Misc.isNPCEntityExcludingVillagers(master) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, master)) {
processTamingCombat(target, master, wolf, event); processTamingCombat(target, master, wolf, event);
} }
} }
@ -337,14 +341,14 @@ public final class CombatUtils {
Arrow arrow = (Arrow) damager; Arrow arrow = (Arrow) damager;
ProjectileSource projectileSource = arrow.getShooter(); ProjectileSource projectileSource = arrow.getShooter();
if (projectileSource instanceof Player && PrimarySkillType.ARCHERY.canCombatSkillsTrigger(target)) { if (projectileSource instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) {
Player player = (Player) projectileSource; Player player = (Player) projectileSource;
if (!Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.ARCHERY.doesPlayerHaveSkillPermission(player)) { if (!Misc.isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.ARCHERY, player)) {
processArcheryCombat(target, player, event, arrow); processArcheryCombat(target, player, event, arrow);
} }
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.TAMING.doesPlayerHaveSkillPermission(player)) { if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, player)) {
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
TamingManager tamingManager = mcMMOPlayer.getTamingManager(); TamingManager tamingManager = mcMMOPlayer.getTamingManager();
tamingManager.attackTarget(target); tamingManager.attackTarget(target);
@ -358,7 +362,7 @@ public final class CombatUtils {
* *
* @param entity target entity * @param entity target entity
*/ */
public static void fixNames(LivingEntity entity) { public void fixNames(LivingEntity entity) {
List<MetadataValue> metadataValue = entity.getMetadata("mcMMO_oldName"); List<MetadataValue> metadataValue = entity.getMetadata("mcMMO_oldName");
if (metadataValue.size() <= 0) if (metadataValue.size() <= 0)
@ -371,7 +375,7 @@ public final class CombatUtils {
} }
} }
public static int getLimitBreakDamage(Player player, SubSkillType subSkillType) { public int getLimitBreakDamage(Player player, SubSkillType subSkillType) {
return RankUtils.getRank(player, subSkillType); return RankUtils.getRank(player, subSkillType);
} }
@ -381,7 +385,7 @@ public final class CombatUtils {
* @param player target player * @param player target player
* @return true if the player has access to the limit break * @return true if the player has access to the limit break
*/ */
public static boolean canUseLimitBreak(Player player, SubSkillType subSkillType) { public boolean canUseLimitBreak(Player player, SubSkillType subSkillType) {
return RankUtils.hasUnlockedSubskill(player, subSkillType) return RankUtils.hasUnlockedSubskill(player, subSkillType)
&& Permissions.isSubSkillEnabled(player, subSkillType); && Permissions.isSubSkillEnabled(player, subSkillType);
} }
@ -393,7 +397,7 @@ public final class CombatUtils {
* @param damage Amount of damage to attempt to do * @param damage Amount of damage to attempt to do
*/ */
@Deprecated @Deprecated
public static void dealDamage(LivingEntity target, double damage) { public void dealDamage(LivingEntity target, double damage) {
dealDamage(target, damage, DamageCause.CUSTOM, null); dealDamage(target, damage, DamageCause.CUSTOM, null);
} }
@ -405,7 +409,7 @@ public final class CombatUtils {
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
@Deprecated @Deprecated
public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker) { public void dealDamage(LivingEntity target, double damage, LivingEntity attacker) {
dealDamage(target, damage, DamageCause.CUSTOM, attacker); dealDamage(target, damage, DamageCause.CUSTOM, attacker);
} }
@ -416,7 +420,7 @@ public final class CombatUtils {
* @param damage Amount of damage to attempt to do * @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
public static void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) { public void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) {
if (target.isDead()) { if (target.isDead()) {
return; return;
} }
@ -433,7 +437,7 @@ public final class CombatUtils {
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
@Deprecated @Deprecated
public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) { public void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) {
if (target.isDead()) { if (target.isDead()) {
return; return;
} }
@ -442,7 +446,7 @@ public final class CombatUtils {
target.damage(damage); target.damage(damage);
} }
public static void dealNoInvulnerabilityTickDamage(LivingEntity target, double damage, Entity attacker) { public void dealNoInvulnerabilityTickDamage(LivingEntity target, double damage, Entity attacker) {
if (target.isDead()) { if (target.isDead()) {
return; return;
} }
@ -457,7 +461,7 @@ public final class CombatUtils {
target.setHealth(newHealth); target.setHealth(newHealth);
} }
public static void dealNoInvulnerabilityTickDamageRupture(LivingEntity target, double damage, Entity attacker, int toolTier) { public void dealNoInvulnerabilityTickDamageRupture(LivingEntity target, double damage, Entity attacker, int toolTier) {
if (target.isDead()) { if (target.isDead()) {
return; return;
} }
@ -474,7 +478,7 @@ public final class CombatUtils {
* @param damage The initial damage amount * @param damage The initial damage amount
* @param type The type of skill being used * @param type The type of skill being used
*/ */
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, PrimarySkillType type) { public void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, PrimarySkillType type) {
int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
double damageAmount = Math.max(damage, 1); double damageAmount = Math.max(damage, 1);
@ -515,7 +519,7 @@ public final class CombatUtils {
} }
} }
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) { public void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
startGainXp(mcMMOPlayer, target, primarySkillType, 1.0); startGainXp(mcMMOPlayer, target, primarySkillType, 1.0);
} }
@ -526,7 +530,7 @@ public final class CombatUtils {
* @param target The defending entity * @param target The defending entity
* @param primarySkillType The skill being used * @param primarySkillType The skill being used
*/ */
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) { private void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
double baseXPMultiplier = 0; double baseXPMultiplier = 0;
XPGainReason xpGainReason; XPGainReason xpGainReason;
@ -595,7 +599,7 @@ public final class CombatUtils {
* @param entity The defending Entity * @param entity The defending Entity
* @return true if the Entity should be damaged, false otherwise. * @return true if the Entity should be damaged, false otherwise.
*/ */
private static boolean shouldBeAffected(Player player, Entity entity) { private boolean shouldBeAffected(Player player, Entity entity) {
if (entity instanceof Player) { if (entity instanceof Player) {
Player defender = (Player) entity; Player defender = (Player) entity;
@ -646,7 +650,7 @@ public final class CombatUtils {
* @param eventDamage The damage from the event the entity is involved in * @param eventDamage The damage from the event the entity is involved in
* @return true if the entity is invincible, false otherwise * @return true if the entity is invincible, false otherwise
*/ */
public static boolean isInvincible(LivingEntity entity, double eventDamage) { public boolean isInvincible(LivingEntity entity, double eventDamage) {
/* /*
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility. * So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
* So yeah, this is for that. * So yeah, this is for that.
@ -661,7 +665,7 @@ public final class CombatUtils {
* @param pet The entity to check. * @param pet The entity to check.
* @return true if the entity is friendly, false otherwise * @return true if the entity is friendly, false otherwise
*/ */
public static boolean isFriendlyPet(Player attacker, Tameable pet) { public boolean isFriendlyPet(Player attacker, Tameable pet) {
if (pet.isTamed()) { if (pet.isTamed()) {
AnimalTamer tamer = pet.getOwner(); AnimalTamer tamer = pet.getOwner();
@ -676,12 +680,12 @@ public final class CombatUtils {
} }
@Deprecated @Deprecated
public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) { public double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) {
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage))); return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)));
} }
@Deprecated @Deprecated
public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause damageCause, double damage) { public double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause damageCause, double damage) {
EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage); EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage);
if (damageEvent.isCancelled()) { if (damageEvent.isCancelled()) {
@ -691,7 +695,7 @@ public final class CombatUtils {
return damageEvent.getFinalDamage(); return damageEvent.getFinalDamage();
} }
public static boolean canDamage(Entity attacker, Entity target, DamageCause damageCause, double damage) { public boolean canDamage(Entity attacker, Entity target, DamageCause damageCause, double damage) {
EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage); EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage);
if (damageEvent.isCancelled()) { if (damageEvent.isCancelled()) {
@ -701,21 +705,21 @@ public final class CombatUtils {
return true; return true;
} }
public static EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) { public EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage); EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
pluginRef.getServer().getPluginManager().callEvent(damageEvent); pluginRef.getServer().getPluginManager().callEvent(damageEvent);
return damageEvent; return damageEvent;
} }
public static double getFakeDamageFinalResult(Entity attacker, Entity target, Map<DamageModifier, Double> modifiers) { public double getFakeDamageFinalResult(Entity attacker, Entity target, Map<DamageModifier, Double> modifiers) {
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, modifiers); return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, modifiers);
} }
public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage, Map<DamageModifier, Double> modifiers) { public double getFakeDamageFinalResult(Entity attacker, Entity target, double damage, Map<DamageModifier, Double> modifiers) {
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers)); return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers));
} }
public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) { public double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) {
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers); EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers);
pluginRef.getServer().getPluginManager().callEvent(damageEvent); pluginRef.getServer().getPluginManager().callEvent(damageEvent);
@ -726,7 +730,7 @@ public final class CombatUtils {
return damageEvent.getFinalDamage(); return damageEvent.getFinalDamage();
} }
private static Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) { private Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) {
Map<DamageModifier, Double> modifiers = new HashMap<>(); Map<DamageModifier, Double> modifiers = new HashMap<>();
for (DamageModifier modifier : DamageModifier.values()) { for (DamageModifier modifier : DamageModifier.values()) {
modifiers.put(modifier, event.getDamage(modifier)); modifiers.put(modifier, event.getDamage(modifier));
@ -735,7 +739,7 @@ public final class CombatUtils {
return modifiers; return modifiers;
} }
private static Map<DamageModifier, Double> getScaledModifiers(double damage, Map<DamageModifier, Double> modifiers) { private Map<DamageModifier, Double> getScaledModifiers(double damage, Map<DamageModifier, Double> modifiers) {
Map<DamageModifier, Double> scaledModifiers = new HashMap<>(); Map<DamageModifier, Double> scaledModifiers = new HashMap<>();
for (DamageModifier modifier : modifiers.keySet()) { for (DamageModifier modifier : modifiers.keySet()) {
@ -750,7 +754,7 @@ public final class CombatUtils {
return scaledModifiers; return scaledModifiers;
} }
public static void applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) { public void applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) {
// No additional damage // No additional damage
if (initialDamage == finalDamage) { if (initialDamage == finalDamage) {
return; return;
@ -777,7 +781,7 @@ public final class CombatUtils {
* @param inHand The item to check the tier of * @param inHand The item to check the tier of
* @return the tier of the item * @return the tier of the item
*/ */
private static int getTier(ItemStack inHand) { private int getTier(ItemStack inHand) {
int tier = 0; int tier = 0;
if (ItemUtils.isWoodTool(inHand)) { if (ItemUtils.isWoodTool(inHand)) {
@ -798,7 +802,7 @@ public final class CombatUtils {
return tier; return tier;
} }
public static void handleHealthbars(Entity attacker, LivingEntity target, double damage, mcMMO plugin) { public void handleHealthbars(Entity attacker, LivingEntity target, double damage, mcMMO plugin) {
if (!(attacker instanceof Player)) { if (!(attacker instanceof Player)) {
return; return;
} }