mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-29 01:05:40 +01:00
Fixed exp holograms always showing for certain professions
This commit is contained in:
parent
d9fa24a730
commit
bbe7d2b9b8
@ -128,8 +128,8 @@ public class MMOCoreUtils {
|
|||||||
* @param message Message to display
|
* @param message Message to display
|
||||||
*/
|
*/
|
||||||
public static void displayIndicator(Location loc, String message) {
|
public static void displayIndicator(Location loc, String message) {
|
||||||
Hologram holo = Hologram.create(loc, Arrays.asList(message));
|
Hologram holo = Hologram.create(loc, Collections.singletonList(message));
|
||||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> holo.despawn(), 20);
|
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, holo::despawn, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerHead(Material material) {
|
public static boolean isPlayerHead(Material material) {
|
||||||
|
@ -155,11 +155,11 @@ public class PlayerProfessions {
|
|||||||
return profession.hasMaxLevel() && getLevel(profession) >= profession.getMaxLevel();
|
return profession.hasMaxLevel() && getLevel(profession) >= profession.getMaxLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveExperience(Profession profession, double value, EXPSource source) {
|
public void giveExperience(@NotNull Profession profession, double value, @NotNull EXPSource source) {
|
||||||
giveExperience(profession, value, source, null, true);
|
giveExperience(profession, value, source, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveExperience(Profession profession, double value, EXPSource source, @Nullable Location hologramLocation, boolean splitExp) {
|
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");
|
Validate.isTrue(playerData.isOnline(), "Cannot give experience to offline player");
|
||||||
if (value <= 0) {
|
if (value <= 0) {
|
||||||
exp.put(profession.getId(), Math.max(0, exp.getOrDefault(profession.getId(), 0d) + value));
|
exp.put(profession.getId(), Math.max(0, exp.getOrDefault(profession.getId(), 0d) + value));
|
||||||
@ -190,7 +190,7 @@ public class PlayerProfessions {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Display hologram
|
// Display hologram
|
||||||
if (hologramLocation != null)
|
if (hologramLocation != null && profession.getOption(Profession.ProfessionOption.EXP_HOLOGRAMS))
|
||||||
MMOCoreUtils.displayIndicator(hologramLocation.add(.5, 1.5, .5), ConfigMessage.fromKey("exp-hologram", "exp", MythicLib.plugin.getMMOConfig().decimal.format(event.getExperience())).asLine());
|
MMOCoreUtils.displayIndicator(hologramLocation.add(.5, 1.5, .5), ConfigMessage.fromKey("exp-hologram", "exp", MythicLib.plugin.getMMOConfig().decimal.format(event.getExperience())).asLine());
|
||||||
|
|
||||||
exp.put(profession.getId(), Math.max(0, exp.getOrDefault(profession.getId(), 0d) + event.getExperience()));
|
exp.put(profession.getId(), Math.max(0, exp.getOrDefault(profession.getId(), 0d) + event.getExperience()));
|
||||||
@ -228,10 +228,10 @@ public class PlayerProfessions {
|
|||||||
playerData.getStats().updateStats();
|
playerData.getStats().updateStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
|
StringBuilder bar = new StringBuilder(ChatColor.BOLD.toString());
|
||||||
int chars = (int) (exp / needed * 20);
|
int chars = (int) (exp / needed * 20);
|
||||||
for (int j = 0; j < 20; j++)
|
for (int j = 0; j < 20; j++)
|
||||||
bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|");
|
bar.append(j == chars ? ChatColor.WHITE.toString() + ChatColor.BOLD : "").append("|");
|
||||||
if (playerData.isOnline())
|
if (playerData.isOnline())
|
||||||
ConfigMessage.fromKey("exp-notification", "profession", profession.getName(), "progress", bar.toString(), "ratio",
|
ConfigMessage.fromKey("exp-notification", "profession", profession.getName(), "progress", bar.toString(), "ratio",
|
||||||
MythicLib.plugin.getMMOConfig().decimal.format(exp / needed * 100)).send(playerData.getPlayer());
|
MythicLib.plugin.getMMOConfig().decimal.format(exp / needed * 100)).send(playerData.getPlayer());
|
||||||
|
@ -124,8 +124,7 @@ public class Profession extends PostLoadObject implements ExperienceObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
public void giveExperience(@NotNull PlayerData playerData, double experience, @Nullable Location hologramLocation, @NotNull EXPSource source) {
|
||||||
hologramLocation = !getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null : hologramLocation;
|
|
||||||
playerData.getCollectionSkills().giveExperience(this, experience, EXPSource.SOURCE, hologramLocation, true);
|
playerData.getCollectionSkills().giveExperience(this, experience, EXPSource.SOURCE, hologramLocation, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class RegionBounds {
|
|||||||
|
|
||||||
String name = config.getString("world");
|
String name = config.getString("world");
|
||||||
Validate.notNull(name, "Could not find world name");
|
Validate.notNull(name, "Could not find world name");
|
||||||
Validate.notNull(world = Bukkit.getWorld(name), "Could not find world " + config.getString("world"));
|
Validate.notNull(world = Bukkit.getWorld(name), "Could not find world '" + config.getString("world") + "'");
|
||||||
|
|
||||||
x1 = Math.min(config.getInt("x1"), config.getInt("x2"));
|
x1 = Math.min(config.getInt("x1"), config.getInt("x2"));
|
||||||
x2 = Math.max(config.getInt("x1"), config.getInt("x2"));
|
x2 = Math.max(config.getInt("x1"), config.getInt("x2"));
|
||||||
|
@ -69,7 +69,7 @@ public class CustomBlockManager extends SpecificProfessionManager {
|
|||||||
* @return The new block behaviour or null if no new behaviour
|
* @return The new block behaviour or null if no new behaviour
|
||||||
*/
|
*/
|
||||||
public @Nullable BlockInfo getInfo(Block block) {
|
public @Nullable BlockInfo getInfo(Block block) {
|
||||||
return map.getOrDefault(findBlockType(block).generateKey(), null);
|
return map.get(findBlockType(block).generateKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockType findBlockType(Block block) {
|
public BlockType findBlockType(Block block) {
|
||||||
|
Loading…
Reference in New Issue
Block a user