Only ignore 0 dmg if specific plugins are detected

This commit is contained in:
nossr50 2020-10-05 14:43:06 -07:00
parent a6586e07cc
commit 0767e62965
10 changed files with 26 additions and 19 deletions

View File

@ -21,7 +21,6 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -23,7 +23,6 @@ import com.gmail.nossr50.util.skills.SkillUtils;
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 net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.SoundCategory; import org.bukkit.SoundCategory;

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.datatypes.skills.subskills.interfaces;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill; import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public interface SubSkill extends Skill { public interface SubSkill extends Skill {

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
@ -329,12 +330,6 @@ public class EntityListener implements Listener {
return; return;
} }
if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey))
{
event.setCancelled(true);
return;
}
if (Misc.isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { if (Misc.isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return; return;
} }
@ -420,8 +415,10 @@ public class EntityListener implements Listener {
* Surprising this kind of thing * Surprising this kind of thing
* *
*/ */
if(event.getDamage() <= 0 && !CombatUtils.isDamageLikelyFromNormalCombat(event.getCause())) { if(mcMMO.isProjectKorraEnabled()) {
return; if(event.getFinalDamage() == 0) {
return;
}
} }
CombatUtils.processCombatAttack(event, attacker, target); CombatUtils.processCombatAttack(event, attacker, target);

View File

@ -102,6 +102,7 @@ public class mcMMO extends JavaPlugin {
/* Plugin Checks */ /* Plugin Checks */
private static boolean healthBarPluginEnabled; private static boolean healthBarPluginEnabled;
private static boolean projectKorraEnabled;
// API checks // API checks
private static boolean serverAPIOutdated = false; private static boolean serverAPIOutdated = false;
@ -159,6 +160,7 @@ public class mcMMO extends JavaPlugin {
PluginManager pluginManager = getServer().getPluginManager(); PluginManager pluginManager = getServer().getPluginManager();
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null; healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
projectKorraEnabled = pluginManager.getPlugin("ProjectKorra") != null;
upgradeManager = new UpgradeManager(); upgradeManager = new UpgradeManager();
@ -182,6 +184,10 @@ public class mcMMO extends JavaPlugin {
checkModConfigs(); checkModConfigs();
} }
if(projectKorraEnabled) {
getLogger().info("ProjectKorra was detected, this can cause some issues with weakness potions and combat skills for mcMMO");
}
if (healthBarPluginEnabled) { if (healthBarPluginEnabled) {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled."); getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
} }
@ -689,4 +695,8 @@ public class mcMMO extends JavaPlugin {
public static BukkitAudiences getAudiences() { public static BukkitAudiences getAudiences() {
return audiences; return audiences;
} }
public static boolean isProjectKorraEnabled() {
return projectKorraEnabled;
}
} }

View File

@ -35,7 +35,7 @@ public class UnarmedManager extends SkillManager {
return mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && Permissions.berserk(getPlayer()); return mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && Permissions.berserk(getPlayer());
} }
public boolean canUseIronArm() { public boolean canUseSteelArm() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE)) if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE))
return false; return false;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.experience.XPGainSource;

View File

@ -1,10 +1,11 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import java.util.function.BiConsumer;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import java.util.function.BiConsumer;
public enum McMMOMessageType { public enum McMMOMessageType {
ACTION_BAR(Audience::sendActionBar), ACTION_BAR(Audience::sendActionBar),
SYSTEM((audience, message) -> audience.sendMessage(message, MessageType.SYSTEM)); SYSTEM((audience, message) -> audience.sendMessage(message, MessageType.SYSTEM));

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import java.util.concurrent.atomic.AtomicReference;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -22,12 +21,11 @@ import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.format.TextDecoration;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* This class handles many of the JSON components that mcMMO makes and uses * This class handles many of the JSON components that mcMMO makes and uses

View File

@ -32,6 +32,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import java.util.EnumMap; import java.util.EnumMap;
@ -54,6 +55,11 @@ public final class CombatUtils {
} }
} }
public static boolean hasWeakenedDamage(LivingEntity livingEntity) {
return livingEntity.hasPotionEffect(PotionEffectType.WEAKNESS);
}
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) { if (event.getCause() == DamageCause.THORNS) {
return; return;
@ -198,8 +204,7 @@ public final class CombatUtils {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
} }
//Only execute bonuses if the player is not spamming if (unarmedManager.canUseSteelArm()) {
if (unarmedManager.canUseIronArm()) {
finalDamage+=(unarmedManager.calculateSteelArmStyleDamage() * mcMMOPlayer.getAttackStrength()); finalDamage+=(unarmedManager.calculateSteelArmStyleDamage() * mcMMOPlayer.getAttackStrength());
} }