Fix exceptions when shooting entities through worlds on folia (#5024)

This commit is contained in:
Warrior 2024-08-31 22:02:00 +02:00 committed by GitHub
parent f67e30641d
commit 93bb160742
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;
@ -44,6 +45,7 @@ public class AwardCombatXpTask extends CancellableRunnable {
damage = Math.min(damage, ExperienceConfig.getInstance().getCombatHPCeiling());
}
mcMMOPlayer.beginXpGain(primarySkillType, (int) (damage * baseXp), xpGainReason, XPGainSource.SELF);
final double finalDamage = damage;
mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), task -> mcMMOPlayer.beginXpGain(primarySkillType, (int) (finalDamage * baseXp), xpGainReason, XPGainSource.SELF));
}
}

View File

@ -287,6 +287,9 @@ public class TamingManager extends SkillManager {
double range = 5;
Player player = getPlayer();
if (!target.getWorld().equals(player.getWorld()))
return;
for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity.getType() != EntityType.WOLF) {
continue;

View File

@ -945,7 +945,7 @@ public final class CombatUtils {
baseXP *= multiplier;
if (baseXP > 0) {
mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
mcMMO.p.getFoliaLib().getImpl().runAtEntity(target, new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
}
}