use of com.gmail.filoghost.holographicdisplays.api.Hologram in project ChatBubbles by DrkMatr1984.
the class HandleHolographicDisplays method handleOne.
public void handleOne(String message, Player p) {
boolean sendOriginal = plugin.getConfig().getBoolean("ChatBubble_Send_Original_Message");
boolean requirePerm = plugin.getConfig().getBoolean("ConfigOne_Require_Permissions");
String usePerm = plugin.getConfig().getString("ConfigOne_Use_Permission");
String seePerm = plugin.getConfig().getString("ConfigOne_See_Permission");
new BukkitRunnable() {
@Override
public void run() {
if (requirePerm && !p.hasPermission(usePerm))
return;
if (!config.togglePF.getBoolean(p.getUniqueId().toString()))
return;
if (existingHolograms.containsKey(p.getUniqueId())) {
for (Hologram h : existingHolograms.get(p.getUniqueId())) {
if (!h.isDeleted())
h.delete();
}
}
final Hologram hologram = HologramsAPI.createHologram(plugin, p.getLocation().add(0.0, config.bubbleOffset, 0.0));
List<Hologram> hList = new ArrayList<Hologram>();
hList.add(hologram);
existingHolograms.put(p.getUniqueId(), hList);
hologram.getVisibilityManager().setVisibleByDefault(false);
for (Player oP : Bukkit.getOnlinePlayers()) {
if (((config.seeOwnBubble) || (!config.seeOwnBubble && oP.getName() != p.getName())) && (oP.getWorld().getName().equals(p.getWorld().getName()) && oP.getLocation().distance(p.getLocation()) <= config.distance) && (!requirePerm || (requirePerm && oP.hasPermission(seePerm))) && oP.canSee(p))
hologram.getVisibilityManager().showTo(oP);
}
int lines = formatHologramLines(p, hologram, message);
if (sendOriginal)
p.chat(message);
new BukkitRunnable() {
int ticksRun = 0;
@Override
public void run() {
ticksRun++;
if (!hologram.isDeleted())
hologram.teleport(p.getLocation().add(0.0, config.bubbleOffset + .25 * lines, 0.0));
if (ticksRun > config.life) {
hologram.delete();
cancel();
}
}
}.runTaskTimer(plugin, 1L, 1L);
if (plugin.getConfig().getBoolean("ChatBubble_Play_Sound")) {
String sound = plugin.getConfig().getString("ChatBubble_Sound_Name").toLowerCase();
float volume = (float) plugin.getConfig().getDouble("ChatBubble_Sound_Volume");
if (!sound.equals("")) {
try {
p.getWorld().playSound(p.getLocation(), sound, volume, 1.0f);
} catch (Exception e) {
plugin.getServer().getConsoleSender().sendMessage("Something is wrong in your ChatBubble config.yml sound settings!");
plugin.getServer().getConsoleSender().sendMessage("Please ensure that 'ChatBubble_Sound_Name' works in a '/playsound' command test.");
}
}
}
}
}.runTask(plugin);
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project ChatBubbles by DrkMatr1984.
the class CitizensHDChatbubble method createBubbleHD.
public void createBubbleHD(LivingEntity p, String msg) {
if (plugin.hdHandler.existingHolograms.containsKey(p.getUniqueId())) {
for (Hologram h : plugin.hdHandler.existingHolograms.get(p.getUniqueId())) {
if (!h.isDeleted())
h.delete();
}
}
final Hologram hologram = HologramsAPI.createHologram(plugin, p.getLocation().add(0.0, plugin.getCBConfig().bubbleOffset, 0.0));
List<Hologram> hList = new ArrayList<Hologram>();
hList.add(hologram);
plugin.hdHandler.existingHolograms.put(p.getUniqueId(), hList);
hologram.getVisibilityManager().setVisibleByDefault(false);
for (Player oP : Bukkit.getOnlinePlayers()) {
if (oP.getWorld().getName().equals(p.getWorld().getName()) && oP.getLocation().distance(p.getLocation()) <= plugin.getCBConfig().distance)
;
hologram.getVisibilityManager().showTo(oP);
}
int lines = plugin.hdHandler.formatHologramLines(p, hologram, msg);
new BukkitRunnable() {
int ticksRun = 0;
@Override
public void run() {
ticksRun++;
if (!hologram.isDeleted())
hologram.teleport(p.getLocation().add(0.0, plugin.getCBConfig().bubbleOffset + .25 * lines, 0.0));
if (ticksRun > plugin.getCBConfig().life) {
hologram.delete();
cancel();
}
}
}.runTaskTimer(plugin, 1L, 1L);
if (plugin.getConfig().getBoolean("ChatBubble_Play_Sound")) {
String sound = plugin.getConfig().getString("ChatBubble_Sound_Name").toLowerCase();
float volume = (float) plugin.getConfig().getDouble("ChatBubble_Sound_Volume");
if (!sound.equals("")) {
try {
p.getWorld().playSound(p.getLocation(), sound, volume, 1.0f);
} catch (Exception e) {
Bukkit.getServer().getConsoleSender().sendMessage("Something is wrong in your ChatBubble config.yml sound settings!");
Bukkit.getServer().getConsoleSender().sendMessage("Please ensure that 'ChatBubble_Sound_Name' works in a '/playsound' command test.");
}
}
}
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project Nexus by ProjectEdenGG.
the class Pugmas20 method createNpcHolograms.
public static void createNpcHolograms() {
deleteNpcHolograms();
for (QuestNPC questNPC : QuestNPC.values()) {
NPC npc = CitizensUtils.getNPC(questNPC.getId());
Hologram hologram = HologramsAPI.createHologram(Nexus.getInstance(), npc.getStoredLocation().clone().add(0, 3.15, 0));
hologram.appendItemLine(new ItemStack(Material.EMERALD));
holograms.add(hologram);
}
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project Nexus by ProjectEdenGG.
the class Crate method spawnHologram.
public void spawnHologram() {
List<Hologram> holograms = new ArrayList<>();
for (int i = 0; i < 2; i++) {
Hologram hologram = HologramsAPI.createHologram(Nexus.getInstance(), getHologramLocation());
for (String line : getCrateHologramLines()) hologram.appendTextLine(StringUtils.colorize(line));
hologram.getVisibilityManager().setVisibleByDefault(true);
holograms.add(hologram);
}
crateHologram = holograms;
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project PotPvPReprised by DevDrizzy.
the class GlobalHologram method spawn.
/**
* Spawn the hologram for all players on the server
* at the given location in the constructor
*/
public void spawn() {
Preconditions.checkNotNull(this.meta, "Hologram Meta can not be null!");
BasicConfigurationFile config = plugin.getHologramsConfig();
Hologram apiHologram = HologramsAPI.createHologram(plugin, meta.getLocation());
apiHologram.clearLines();
apiHologram.getVisibilityManager().setVisibleByDefault(true);
if (!apiHologram.getLocation().getChunk().isLoaded()) {
apiHologram.getLocation().getChunk().load();
}
for (String line : config.getStringList("SETTINGS.DEFAULT.LINES")) {
if (line.contains("<top>")) {
int position = 1;
for (Map.Entry<String, Integer> entry : plugin.getEloHandler().topElo(null).entrySet()) {
apiHologram.appendTextLine(config.getString("SETTINGS.DEFAULT.FORMAT").replace("<number>", String.valueOf(position)).replace("<value>", String.valueOf(entry.getValue())).replace("<name>", entry.getKey()));
position++;
}
continue;
}
String replace = line.replace("<update>", String.valueOf(updateIn));
apiHologram.appendTextLine(replace);
}
meta.setHologram(apiHologram);
}
Aggregations