mcMMO will no longer use the DamageModifier API (potentially fix immortal player bug)

This commit is contained in:
nossr50
2022-03-17 19:58:42 -07:00
parent 8066f7f7f2
commit 5ab55c1653
42 changed files with 188 additions and 432 deletions

View File

@@ -102,8 +102,7 @@ public class AcrobaticsManager extends SkillManager {
}
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
if(attacker instanceof Mob) {
Mob mob = (Mob) attacker;
if(attacker instanceof Mob mob) {
//Check to see how many dodge XP rewards this mob has handed out
if(mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
//If Dodge XP has been handed out 5 times then consider it being exploited

View File

@@ -15,12 +15,9 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.*;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
public class AxesManager extends SkillManager {
public AxesManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.AXES);
@@ -93,8 +90,7 @@ public class AxesManager extends SkillManager {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CriticalHit");
}
if (target instanceof Player) {
Player defender = (Player) target;
if (target instanceof Player defender) {
if (NotificationManager.doesPlayerUseNotifications(defender)) {
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CritStruck");
@@ -150,8 +146,7 @@ public class AxesManager extends SkillManager {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Proc");
}
if (target instanceof Player) {
Player defender = (Player) target;
if (target instanceof Player defender) {
if (NotificationManager.doesPlayerUseNotifications(defender)) {
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Struck");
@@ -163,11 +158,10 @@ public class AxesManager extends SkillManager {
/**
* Handle the effects of the Skull Splitter ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public void skullSplitterCheck(@NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, modifiers, skill);
public void skullSplitterCheck(@NotNull LivingEntity target, double damage) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
}
}

View File

@@ -88,11 +88,9 @@ public class HerbalismManager extends SkillManager {
mmoPlayer.getPlayer().sendMessage("Processing sweet berry bush rewards");
}
//Check the age
if(blockState.getBlockData() instanceof Ageable) {
if(blockState.getBlockData() instanceof Ageable ageable) {
int rewardByAge = 0;
Ageable ageable = (Ageable) blockState.getBlockData();
if(ageable.getAge() == 2) {
rewardByAge = 1; //Normal XP
} else if(ageable.getAge() == 3) {
@@ -134,8 +132,7 @@ public class HerbalismManager extends SkillManager {
BlockState blockState = block.getState();
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
if(blockState.getBlockData() instanceof Ageable) {
Ageable ageable = (Ageable) blockState.getBlockData();
if(blockState.getBlockData() instanceof Ageable ageable) {
if(ageable.getAge() <= 1) {
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
@@ -351,8 +348,7 @@ public class HerbalismManager extends SkillManager {
*/
//Not all things that are natural should give double drops, make sure its fully mature as well
if(plantData instanceof Ageable) {
Ageable ageable = (Ageable) plantData;
if(plantData instanceof Ageable ageable) {
if(isAgeableMature(ageable) || isBizarreAgeable(plantData)) {
if(checkDoubleDrop(brokenPlantState)) {
@@ -447,8 +443,7 @@ public class HerbalismManager extends SkillManager {
*/
//Calculate XP
if(plantData instanceof Ageable) {
Ageable plantAgeable = (Ageable) plantData;
if(plantData instanceof Ageable plantAgeable) {
if(isAgeableMature(plantAgeable) || isBizarreAgeable(plantData)) {
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenBlockNewState.getType());
@@ -764,12 +759,10 @@ public class HerbalismManager extends SkillManager {
BlockData blockData = blockState.getBlockData();
if (!(blockData instanceof Ageable)) {
if (!(blockData instanceof Ageable ageable)) {
return false;
}
Ageable ageable = (Ageable) blockData;
//If the ageable is NOT mature and the player is NOT using a hoe, abort
Player player = getPlayer();

View File

@@ -8,7 +8,6 @@ import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
public class BlastMining {
// The order of the values is extremely important, a few methods depend on it to work properly
@@ -114,7 +113,7 @@ public class BlastMining {
return false;
}
event.setDamage(DamageModifier.BASE, miningManager.processDemolitionsExpertise(event.getDamage()));
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
if (event.getFinalDamage() == 0) {
event.setCancelled(true);

View File

@@ -130,7 +130,7 @@ public class MiningManager extends SkillManager {
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
mmoPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
}
/**

View File

@@ -21,12 +21,9 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
public class SwordsManager extends SkillManager {
public SwordsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.SWORDS);
@@ -81,8 +78,7 @@ public class SwordsManager extends SkillManager {
if (RandomChanceUtil.rollDice(mcMMO.p.getAdvancedConfig().getRuptureChanceToApplyOnHit(getRuptureRank()), 100)) {
if (target instanceof Player) {
Player defender = (Player) target;
if (target instanceof Player defender) {
//Don't start or add to a bleed if they are blocking
if(defender.isBlocking())
@@ -158,11 +154,10 @@ public class SwordsManager extends SkillManager {
/**
* Handle the effects of the Serrated Strikes ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public void serratedStrikes(@NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, modifiers, skill);
public void serratedStrikes(@NotNull LivingEntity target, double damage) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
}
}

View File

@@ -240,8 +240,7 @@ public class TamingManager extends SkillManager {
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
// Bred mules & donkeys can actually have horse-like stats, but llamas cannot.
if (beast instanceof AbstractHorse && !(beast instanceof Llama)) {
AbstractHorse horseLikeCreature = (AbstractHorse) beast;
if (beast instanceof AbstractHorse horseLikeCreature && !(beast instanceof Llama)) {
AttributeInstance jumpAttribute = horseLikeCreature.getAttribute(Attribute.HORSE_JUMP_STRENGTH);
if(jumpAttribute != null) {
@@ -277,8 +276,7 @@ public class TamingManager extends SkillManager {
ParticleEffectUtils.playGreaterImpactEffect(target);
target.setVelocity(wolf.getLocation().getDirection().normalize().multiply(1.5D));
if (target instanceof Player) {
Player defender = (Player) target;
if (target instanceof Player defender) {
if (NotificationManager.doesPlayerUseNotifications(defender)) {
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Taming.SubSkill.Pummel.TargetMessage");
@@ -287,9 +285,8 @@ public class TamingManager extends SkillManager {
}
public void attackTarget(LivingEntity target) {
if(target instanceof Tameable)
if(target instanceof Tameable tameable)
{
Tameable tameable = (Tameable) target;
if(tameable.getOwner() == getPlayer())
{
return;