Fix exceptions when shooting entities through worlds on folia

This commit is contained in:
Warrior 2024-06-18 10:41:35 +02:00
parent b9b1127087
commit b9860b9ba4
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.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable; import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -44,6 +45,7 @@ public class AwardCombatXpTask extends CancellableRunnable {
damage = Math.min(damage, ExperienceConfig.getInstance().getCombatHPCeiling()); 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; double range = 5;
Player player = getPlayer(); Player player = getPlayer();
if (!target.getWorld().equals(player.getWorld()))
return;
for (Entity entity : player.getNearbyEntities(range, range, range)) { for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity.getType() != EntityType.WOLF) { if (entity.getType() != EntityType.WOLF) {
continue; continue;

View File

@ -921,7 +921,7 @@ public final class CombatUtils {
baseXP *= multiplier; baseXP *= multiplier;
if (baseXP > 0) { 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));
} }
} }