mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Fixed an issue with exp holos
This commit is contained in:
parent
735baac901
commit
2d3249b15f
@ -538,7 +538,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
|
||||
// Experience hologram
|
||||
if (hologramLocation != null && isOnline())
|
||||
MMOCoreUtils.displayIndicator(hologramLocation.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message());
|
||||
MMOCoreUtils.displayIndicator(hologramLocation, MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message());
|
||||
|
||||
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
||||
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
|
||||
|
@ -65,6 +65,7 @@ public class MMOCoreUtils {
|
||||
*/
|
||||
public static void displayIndicator(Location loc, String message) {
|
||||
Hologram holo = Hologram.create(Position.of(loc), Arrays.asList(message));
|
||||
holo.spawn();
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> holo.despawn(), 20);
|
||||
}
|
||||
|
||||
@ -212,4 +213,11 @@ public class MMOCoreUtils {
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Center location of an entity using its bounding box
|
||||
*/
|
||||
public static Location getCenterLocation(Entity entity) {
|
||||
return entity.getBoundingBox().getCenter().toLocation(entity.getWorld());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.experience.dispenser;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -37,7 +38,8 @@ public interface ExperienceDispenser {
|
||||
*/
|
||||
boolean shouldHandle(PlayerData playerData);
|
||||
|
||||
@Nullable
|
||||
default Location getPlayerLocation(PlayerData player) {
|
||||
return player.isOnline() ? player.getPlayer().getLocation() : null;
|
||||
return player.isOnline() ? MMOCoreUtils.getCenterLocation(player.getPlayer()) : null;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
@ -34,7 +35,7 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
||||
|
||||
for (KillMobExperienceSource source : getSources())
|
||||
if (source.matches(data, event.getTarget()))
|
||||
source.giveExperience(data, 1, event.getTarget().getLocation());
|
||||
source.giveExperience(data, 1, MMOCoreUtils.getCenterLocation(event.getTarget()));
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user