From bc2b14136cd4fe6c6faeb4dd8595c3ba75080158 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Mon, 21 Dec 2020 02:11:54 +0100 Subject: [PATCH] Exp holograms are no longer hidden to player --- .../mmocore/api/player/PlayerData.java | 28 +++++++++++-------- .../mmocore/comp/holograms/CMIPlugin.java | 16 ++++++----- .../comp/holograms/HologramSupport.java | 16 +++++++---- .../holograms/HolographicDisplaysPlugin.java | 4 +-- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 0568786a..116b1469 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -141,8 +141,8 @@ public class PlayerData extends OfflinePlayerData { MMOCore.log(Level.SEVERE, "[Userdata] Could not find skill " + boundSkills.get(j).getSkill().getId() + " in class " + getProfess().getId() + " while refreshing player data."); } catch (NullPointerException npe2) { - MMOCore.log(Level.SEVERE, "[Userdata] Could not find unidentified skill in class " - + getProfess().getId() + " while refreshing player data."); + MMOCore.log(Level.SEVERE, + "[Userdata] Could not find unidentified skill in class " + getProfess().getId() + " while refreshing player data."); } } } @@ -260,7 +260,8 @@ public class PlayerData extends OfflinePlayerData { public void refreshVanillaExp() { if (MMOCore.plugin.configManager.overrideVanillaExp) { - if(!isOnline()) return; + if (!isOnline()) + return; getPlayer().setLevel(getLevel()); getPlayer().setExp(Math.max(0, Math.min(1, (float) experience / (float) getLevelUpExperience()))); } @@ -315,7 +316,7 @@ public class PlayerData extends OfflinePlayerData { } public boolean hasWaypoint(Waypoint waypoint) { - return waypoint.isDefault() || waypoints.contains(waypoint.getId()); + return waypoint.isDefault() || waypoints.contains(waypoint.getId()); } public void unlockWaypoint(Waypoint waypoint) { @@ -340,7 +341,8 @@ public class PlayerData extends OfflinePlayerData { } public void heal(double heal) { - if(!isOnline()) return; + if (!isOnline()) + return; double newest = Math.max(0, Math.min(getPlayer().getHealth() + heal, getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())); if (getPlayer().getHealth() == newest) return; @@ -384,7 +386,8 @@ public class PlayerData extends OfflinePlayerData { } public void sendFriendRequest(PlayerData target) { - if(!isOnline() || !target.isOnline()) return; + if (!isOnline() || !target.isOnline()) + return; setLastFriendRequest(System.currentTimeMillis()); FriendRequest request = new FriendRequest(this, target); @@ -404,7 +407,8 @@ public class PlayerData extends OfflinePlayerData { giveStellium(-waypoint.getStelliumCost()); - if(!isOnline()) return; + if (!isOnline()) + return; new BukkitRunnable() { final int x = getPlayer().getLocation().getBlockX(); final int y = getPlayer().getLocation().getBlockY(); @@ -412,7 +416,8 @@ public class PlayerData extends OfflinePlayerData { int t; public void run() { - if(!isOnline()) return; + if (!isOnline()) + return; if (getPlayer().getLocation().getBlockX() != x || getPlayer().getLocation().getBlockY() != y || getPlayer().getLocation().getBlockZ() != z) { MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.WARP_CANCELLED); @@ -485,7 +490,7 @@ public class PlayerData extends OfflinePlayerData { if (level > oldLevel) { Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(this, null, oldLevel, level)); - if(isOnline()) { + if (isOnline()) { new ConfigMessage("level-up").addPlaceholders("level", "" + level).send(getPlayer()); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.LEVEL_UP); new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT); @@ -593,7 +598,8 @@ public class PlayerData extends OfflinePlayerData { } public void displayActionBar(String message) { - if(!isOnline()) return; + if (!isOnline()) + return; setActionBarTimeOut(MMOCore.plugin.actionBarManager.getTimeOut()); getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); } @@ -745,7 +751,7 @@ public class PlayerData extends OfflinePlayerData { */ SkillResult cast = skill.getSkill().whenCast(this, skill); if (!cast.isSuccessful()) { - if (!skill.getSkill().isPassive() && isOnline()) { + if (!skill.getSkill().isPassive() && isOnline()) { if (cast.getCancelReason() == CancelReason.LOCKED) MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(getPlayer()); diff --git a/src/main/java/net/Indyuce/mmocore/comp/holograms/CMIPlugin.java b/src/main/java/net/Indyuce/mmocore/comp/holograms/CMIPlugin.java index bcf9578b..b5d5dec2 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/holograms/CMIPlugin.java +++ b/src/main/java/net/Indyuce/mmocore/comp/holograms/CMIPlugin.java @@ -1,22 +1,24 @@ package net.Indyuce.mmocore.comp.holograms; -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Modules.Holograms.CMIHologram; -import net.Indyuce.mmocore.MMOCore; +import java.util.Collections; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -import java.util.Collections; -import java.util.UUID; +import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.Holograms.CMIHologram; + +import net.Indyuce.mmocore.MMOCore; public class CMIPlugin extends HologramSupport { @Override public void displayIndicator(Location loc, String format, Player player) { final CMIHologram hologram = new CMIHologram("MMOItems_" + UUID.randomUUID().toString(), loc); hologram.setLines(Collections.singletonList(format)); - if (player != null) - hologram.hide(player.getUniqueId()); + // if (player != null) +// hologram.hide(player.getUniqueId()); CMI.getInstance().getHologramManager().addHologram(hologram); hologram.update(); Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> CMI.getInstance().getHologramManager().removeHolo(hologram), 20); diff --git a/src/main/java/net/Indyuce/mmocore/comp/holograms/HologramSupport.java b/src/main/java/net/Indyuce/mmocore/comp/holograms/HologramSupport.java index a5605970..49b8f7b3 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/holograms/HologramSupport.java +++ b/src/main/java/net/Indyuce/mmocore/comp/holograms/HologramSupport.java @@ -1,16 +1,20 @@ package net.Indyuce.mmocore.comp.holograms; +import javax.annotation.Nullable; + import org.bukkit.Location; import org.bukkit.entity.Player; public abstract class HologramSupport { - - /* - * the third argument is the player which the hologram needs to be hidden - * from to prevent the indicator from taking too much space on the player - * screen + /** + * Displays a message using a hologram + * + * @param loc The location at which the message should be displayed + * @param message The message to display + * @param player Source player, can be null in some cases source player for + * instance for regen holograms */ - public abstract void displayIndicator(Location loc, String message, Player player); + public abstract void displayIndicator(Location loc, String message, @Nullable Player player); public void displayIndicator(Location loc, String message) { displayIndicator(loc, message, null); diff --git a/src/main/java/net/Indyuce/mmocore/comp/holograms/HolographicDisplaysPlugin.java b/src/main/java/net/Indyuce/mmocore/comp/holograms/HolographicDisplaysPlugin.java index d3f7cb74..0bf6ceca 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/holograms/HolographicDisplaysPlugin.java +++ b/src/main/java/net/Indyuce/mmocore/comp/holograms/HolographicDisplaysPlugin.java @@ -14,8 +14,8 @@ public class HolographicDisplaysPlugin extends HologramSupport { public void displayIndicator(Location loc, String format, Player player) { Hologram hologram = HologramsAPI.createHologram(MMOCore.plugin, loc); hologram.appendTextLine(format); - if (player != null) - hologram.getVisibilityManager().hideTo(player); + // if (player != null) + // hologram.getVisibilityManager().hideTo(player); Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, hologram::delete, 20); } }