forked from Upstream/mmocore
Fixes player combat updating on fake damage events
This commit is contained in:
parent
3d48a7e7c0
commit
13ada015c9
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.experience.source;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
|
||||
import io.lumine.mythic.lib.damage.DamagePacket;
|
||||
@ -10,7 +11,6 @@ import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
@ -31,13 +31,12 @@ public class DamageDealtExperienceSource extends SpecificExperienceSource<Damage
|
||||
if (!config.contains("type"))
|
||||
type = null;
|
||||
else {
|
||||
String str = config.getString("type").toUpperCase().replace("-", "_");
|
||||
String str = UtilityMethods.enumName(config.getString("type"));
|
||||
//Checks if the damage type correspond to a value of the damage type enum
|
||||
Validate.isTrue(Arrays.stream(DamageType.values()).map(Objects::toString).collect(Collectors.toList()).contains(str),
|
||||
"Type value not allowed. Type value allowed: magic, physical, weapon, skill, projectile," +
|
||||
" unarmed, on-hit, minion, dot.");
|
||||
type = DamageType.valueOf(str);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void updateCombat(EntityDamageEvent event) {
|
||||
if (UtilityMethods.isFakeEvent(event)) return;
|
||||
if (UtilityMethods.isRealPlayer(event.getEntity()) && MMOCore.plugin.configManager.combatLogDamageCauses.contains(event.getCause()))
|
||||
PlayerData.get(event.getEntity().getUniqueId()).getCombat().update();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user