use of com.gmail.filoghost.holographicdisplays.api.Hologram in project AureliumSkills by Archy-X.
the class HologramSupport method createHologram.
private void createHologram(Location location, String text) {
Hologram hologram = HologramsAPI.createHologram(plugin, location);
hologram.appendTextLine(text);
new BukkitRunnable() {
@Override
public void run() {
hologram.delete();
}
}.runTaskLater(plugin, 30L);
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project CharacterDialogue by iAtog.
the class ApiImplementation method reloadHolograms.
@Override
public void reloadHolograms() {
YamlFile config = main.getFileFactory().getConfig();
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
return;
}
for (Hologram hologram : HologramsAPI.getHolograms(main)) {
hologram.delete();
}
config.getConfigurationSection("npc").getKeys(false).forEach((id) -> {
this.loadHologram(Integer.parseInt(id));
});
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project NT-RPG by Sponge-RPG-dev.
the class HolographicDisplaysExpansion method onSkillCast.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onSkillCast(SpigotSkillPostUsageEvent event) {
ISkill skill = event.getSkill();
String damageType = skill.getDamageType();
IEntity caster = event.getCaster();
Entity entity = (Entity) caster.getEntity();
String s = colors.get(damageType);
if (s == null) {
s = ChatColor.WHITE.toString();
}
Location location = entity.getLocation().add(0, entity.getHeight() + 0.1, 0).add(getLocation());
Hologram hologram = HologramsAPI.createHologram(SpigotRpgPlugin.getInstance(), location);
// todo in future when entitis are able to casts spells
IActiveCharacter c = (IActiveCharacter) caster;
PlayerSkillContext info = c.getSkillInfo(skill.getId());
if (info == null) {
// nadmin / contextless
return;
}
String skillName = info.getSkillData().getSkillName();
// ran as nadmin skill <id> we have no context to grab name from
if (skillName == null) {
skillName = info.getSkill().getId();
}
hologram.insertTextLine(0, ChatColor.BOLD + s + skillName);
VisibilityManager visiblityManager = hologram.getVisibilityManager();
visiblityManager.setVisibleByDefault(true);
holograms.put(hologram, System.currentTimeMillis() + 2500L);
}
use of com.gmail.filoghost.holographicdisplays.api.Hologram in project ChatBubbles by DrkMatr1984.
the class HandleHolographicDisplays method handleTwo.
public void handleTwo(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");
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();
}
}
String permGroup = "";
for (String testPerm : plugin.getConfig().getStringList("ConfigTwo_Permision_Groups")) {
if (p.hasPermission(testPerm)) {
permGroup = testPerm;
break;
}
}
if (permGroup.equals(""))
return;
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) && (oP.hasPermission(permGroup)) && 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 HandleHolographicDisplays method handleZero.
public void handleZero(String message, Player p) {
boolean requirePerm = plugin.getConfig().getBoolean("ConfigZero_Require_Permissions");
String usePerm = plugin.getConfig().getString("ConfigZero_Use_Permission");
String seePerm = plugin.getConfig().getString("ConfigZero_See_Permission");
new BukkitRunnable() {
@Override
public void run() {
if (CBConfig.requirePerm) {
if (!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);
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);
}
Aggregations