From f16d6d359087a9a458b904c5e41b6c64fe80fcca Mon Sep 17 00:00:00 2001 From: Jules Date: Mon, 3 Nov 2025 13:03:35 +0100 Subject: [PATCH] Added small position offset to profession exp holograms --- .../builtin/mmocore/admin/InfoCommandTreeNode.java | 2 +- .../Indyuce/mmocore/experience/PlayerProfessions.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/builtin/mmocore/admin/InfoCommandTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/builtin/mmocore/admin/InfoCommandTreeNode.java index 3828fc08..8dd01bcc 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/builtin/mmocore/admin/InfoCommandTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/builtin/mmocore/admin/InfoCommandTreeNode.java @@ -43,7 +43,7 @@ public class InfoCommandTreeNode extends CommandTreeNode { for (Profession profession : MMOCore.plugin.professionManager.getAll()) sender.sendMessage( ChatColor.YELLOW + profession.getName() + ": Lvl " + ChatColor.GOLD + playerData.getCollectionSkills().getLevel(profession) - + ChatColor.YELLOW + " - " + ChatColor.GOLD + playerData.getCollectionSkills().getExperience(profession) + + ChatColor.YELLOW + " - " + ChatColor.GOLD + MythicLib.plugin.getMMOConfig().decimal.format(playerData.getCollectionSkills().getExperience(profession)) + ChatColor.YELLOW + " / " + ChatColor.GOLD + playerData.getCollectionSkills().getLevelUpExperience(profession)); sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------"); return CommandResult.SUCCESS; diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java index a8a458a3..484cf639 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Random; public class PlayerProfessions { private final Map exp = new HashMap<>(); @@ -175,6 +176,8 @@ public class PlayerProfessions { giveExperience(profession, value, source, null, true); } + private static final Random RANDOM = new Random(); + public void giveExperience(@NotNull Profession profession, double value, @NotNull EXPSource source, @Nullable Location hologramLocation, boolean splitExp) { Validate.isTrue(playerData.isOnline(), "Cannot give experience to offline player"); if (value <= 0) { @@ -204,8 +207,11 @@ public class PlayerProfessions { if (event.isCancelled()) return; // Display hologram - if (hologramLocation != null && profession.getOption(Profession.ProfessionOption.EXP_HOLOGRAMS)) - MMOCoreUtils.displayIndicator(hologramLocation.add(.5, 1.5, .5), Language.EXP_HOLOGRAM.getFormat().replace("{exp}", MythicLib.plugin.getMMOConfig().decimal.format(event.getExperience()))); + if (hologramLocation != null && profession.getOption(Profession.ProfessionOption.EXP_HOLOGRAMS)) { + // TODO custom location per profession/exp source. + hologramLocation.add(.5 + .7 * RANDOM.nextDouble(), 1.3 + RANDOM.nextDouble() / 3, .5 + .7 * RANDOM.nextDouble()); + MMOCoreUtils.displayIndicator(hologramLocation, Language.EXP_HOLOGRAM.getFormat().replace("{exp}", MythicLib.plugin.getMMOConfig().decimal.format(event.getExperience()))); + } final var maxLevel = profession.getMaxLevel(); var currentExp = Math.max(0d, exp.getOrDefault(profession.getId(), 0d) + event.getExperience());