Search in sources :

Example 1 with CMIHologram

use of com.Zrips.CMI.Modules.Holograms.CMIHologram in project RoseStacker by Rosewood-Development.

the class CMIHologramHandler method deleteHologram.

@Override
public void deleteHologram(Location location) {
    CMIHologram hologram = this.holograms.get(location);
    if (hologram != null) {
        this.hologramManager.removeHolo(hologram);
        this.holograms.remove(location);
    }
}
Also used : CMIHologram(com.Zrips.CMI.Modules.Holograms.CMIHologram)

Example 2 with CMIHologram

use of com.Zrips.CMI.Modules.Holograms.CMIHologram in project NextEconomy by NextPlugins.

the class HologramRunnable method run.

@Override
public void run() {
    if (holographicDisplays)
        HologramsAPI.getHolograms(plugin).forEach(Hologram::delete);
    else {
        for (val entry : HOLOGRAMS) {
            val cmiHologram = CMI.getInstance().getHologramManager().getHolograms().get(entry);
            if (cmiHologram == null)
                continue;
            CMI.getInstance().getHologramManager().removeHolo(cmiHologram);
        }
    }
    HOLOGRAMS.clear();
    if (locationManager.getLocationMap().isEmpty())
        return;
    val accounts = rankingStorage.getRankByCoin();
    val location = locationManager.getLocation(1);
    if (location == null || location.getWorld() == null) {
        plugin.getLogger().warning("A localização 1 do ranking é inválida.");
        return;
    }
    val chunk = location.getChunk();
    if (!chunk.isLoaded())
        chunk.load(true);
    val playerLines = playersLines(accounts.values());
    val hologramLocation = location.clone().add(0, 5, 0);
    if (holographicDisplays) {
        val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
        for (val line : RankingValue.get(RankingValue::hologramDefaultLines)) {
            if (line.equalsIgnoreCase("@players")) {
                playerLines.forEach(hologram::appendTextLine);
            } else
                hologram.appendTextLine(line);
        }
    } else {
        val cmiHologram = new CMIHologram("NextEconomy", hologramLocation);
        for (val line : RankingValue.get(RankingValue::hologramDefaultLines)) {
            if (line.equalsIgnoreCase("@players")) {
                playerLines.forEach(cmiHologram::addLine);
            } else
                cmiHologram.addLine(line);
        }
        CMI.getInstance().getHologramManager().addHologram(cmiHologram);
        cmiHologram.update();
        HOLOGRAMS.add("NextEconomy");
    }
}
Also used : lombok.val(lombok.val) CMIHologram(com.Zrips.CMI.Modules.Holograms.CMIHologram) RankingValue(com.nextplugins.economy.configuration.RankingValue)

Example 3 with CMIHologram

use of com.Zrips.CMI.Modules.Holograms.CMIHologram in project RoseStacker by Rosewood-Development.

the class CMIHologramHandler method createOrUpdateHologram.

@Override
public void createOrUpdateHologram(Location location, String text) {
    CMIHologram hologram = this.holograms.get(location);
    if (hologram == null) {
        hologram = new CMIHologram(StackerUtils.locationAsKey(location), new CMILocation(location.clone().add(0, 1, 0)));
        hologram.setLines(Collections.singletonList(text));
        this.hologramManager.addHologram(hologram);
        this.holograms.put(location, hologram);
    } else {
        hologram.setLines(Collections.singletonList(text));
    }
    hologram.update();
}
Also used : CMIHologram(com.Zrips.CMI.Modules.Holograms.CMIHologram) CMILocation(net.Zrips.CMILib.Container.CMILocation)

Example 4 with CMIHologram

use of com.Zrips.CMI.Modules.Holograms.CMIHologram in project NextEconomy by NextPlugins.

the class ArmorStandRunnable method run.

@Override
public void run() {
    STANDS.forEach(ArmorStand::remove);
    if (holographicDisplays)
        HologramsAPI.getHolograms(plugin).forEach(Hologram::delete);
    else {
        for (val entry : HOLOGRAMS) {
            val cmiHologram = CMI.getInstance().getHologramManager().getHolograms().get(entry);
            if (cmiHologram == null)
                continue;
            CMI.getInstance().getHologramManager().removeHolo(cmiHologram);
        }
    }
    HOLOGRAMS.clear();
    STANDS.clear();
    if (locationManager.getLocationMap().isEmpty())
        return;
    ArrayList<SimpleAccount> accounts = new ArrayList<>(rankingStorage.getRankByCoin().values());
    val small = RankingValue.get(RankingValue::hologramFormat).equalsIgnoreCase("SMALL");
    val height = small ? 2.15 : 3;
    val hologramLines = RankingValue.get(RankingValue::hologramArmorStandLines);
    val nobodyLines = RankingValue.get(RankingValue::nobodyHologramLines);
    for (val entry : locationManager.getLocationMap().entrySet()) {
        val position = entry.getKey();
        val location = entry.getValue();
        if (location == null || location.getWorld() == null)
            continue;
        val chunk = location.getChunk();
        if (!chunk.isLoaded())
            chunk.load(true);
        SimpleAccount account = position - 1 < accounts.size() ? accounts.get(position - 1) : null;
        if (account == null) {
            if (!nobodyLines.isEmpty()) {
                val hologramLocation = location.clone().add(0, height, 0);
                if (holographicDisplays) {
                    val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
                    for (val nobodyLine : nobodyLines) {
                        hologram.appendTextLine(nobodyLine.replace("$position", String.valueOf(position)));
                    }
                } else {
                    val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
                    for (val nobodyLine : nobodyLines) {
                        cmiHologram.addLine(nobodyLine.replace("$position", String.valueOf(position)));
                    }
                    CMI.getInstance().getHologramManager().addHologram(cmiHologram);
                    cmiHologram.update();
                    HOLOGRAMS.add("NextEconomy" + position);
                }
            }
        } else {
            if (!hologramLines.isEmpty()) {
                val group = plugin.getGroupWrapperManager().getGroup(account.getUsername());
                val format = account.getBalanceFormated();
                val hologramLocation = location.clone().add(0, height, 0);
                if (holographicDisplays) {
                    val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
                    for (val hologramLine : hologramLines) {
                        hologram.appendTextLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
                    }
                } else {
                    val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
                    for (val hologramLine : hologramLines) {
                        cmiHologram.addLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
                    }
                    CMI.getInstance().getHologramManager().addHologram(cmiHologram);
                    cmiHologram.update();
                    HOLOGRAMS.add("NextEconomy" + position);
                }
            }
        }
        val stand = location.getWorld().spawn(location, ArmorStand.class);
        // show only after configuration
        stand.setVisible(false);
        stand.setMetadata("nexteconomy", new FixedMetadataValue(plugin, true));
        stand.setSmall(small);
        stand.setCustomNameVisible(false);
        stand.setGravity(false);
        stand.setArms(true);
        val swordNumber = Math.min(SWORDS.length, position);
        val sword = SWORDS[swordNumber - 1];
        stand.setItemInHand(new ItemStack(sword));
        val skinName = account == null ? "Yuhtin" : account.getUsername();
        stand.setHelmet(new ItemBuilder(skinName).wrap());
        stand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE, ColorUtil.getBukkitColorByHex(RankingValue.get(RankingValue::chestplateRGB))).wrap());
        stand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS, ColorUtil.getBukkitColorByHex(RankingValue.get(RankingValue::leggingsRGB))).wrap());
        stand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS, ColorUtil.getBukkitColorByHex(RankingValue.get(RankingValue::bootsRGB))).wrap());
        // configuration finished, show stand
        stand.setVisible(true);
        STANDS.add(stand);
    }
}
Also used : lombok.val(lombok.val) SimpleAccount(com.nextplugins.economy.model.account.SimpleAccount) ItemBuilder(com.nextplugins.economy.util.ItemBuilder) ArmorStand(org.bukkit.entity.ArmorStand) CMIHologram(com.Zrips.CMI.Modules.Holograms.CMIHologram) RankingValue(com.nextplugins.economy.configuration.RankingValue) ArrayList(java.util.ArrayList) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) ItemStack(org.bukkit.inventory.ItemStack)

Example 5 with CMIHologram

use of com.Zrips.CMI.Modules.Holograms.CMIHologram in project NextEconomy by NextPlugins.

the class NPCRunnable method run.

@Override
public void run() {
    clearPositions();
    if (locationManager.getLocationMap().isEmpty())
        return;
    ArrayList<SimpleAccount> accounts = new ArrayList<>(rankingStorage.getRankByCoin().values());
    val hologramLines = RankingValue.get(RankingValue::hologramArmorStandLines);
    val nobodyLines = RankingValue.get(RankingValue::nobodyHologramLines);
    for (val entry : locationManager.getLocationMap().entrySet()) {
        val position = entry.getKey();
        val location = entry.getValue();
        if (location == null || location.getWorld() == null)
            continue;
        val chunk = location.getChunk();
        if (!chunk.isLoaded())
            chunk.load(true);
        SimpleAccount account = position - 1 < accounts.size() ? accounts.get(position - 1) : null;
        if (account == null) {
            if (!nobodyLines.isEmpty()) {
                val hologramLocation = location.clone().add(0, 3, 0);
                if (holographicDisplays) {
                    val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
                    for (val nobodyLine : nobodyLines) {
                        hologram.appendTextLine(nobodyLine.replace("$position", String.valueOf(position)));
                    }
                } else {
                    val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
                    for (val nobodyLine : nobodyLines) {
                        cmiHologram.addLine(nobodyLine.replace("$position", String.valueOf(position)));
                    }
                    CMI.getInstance().getHologramManager().addHologram(cmiHologram);
                    cmiHologram.update();
                    HOLOGRAMS.add("NextEconomy" + position);
                }
            }
        } else {
            if (!hologramLines.isEmpty()) {
                val group = plugin.getGroupWrapperManager().getGroup(account.getUsername());
                val format = account.getBalanceFormated();
                val hologramLocation = location.clone().add(0, 3, 0);
                if (holographicDisplays) {
                    val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
                    for (val hologramLine : hologramLines) {
                        hologram.appendTextLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
                    }
                } else {
                    val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
                    for (val hologramLine : hologramLines) {
                        cmiHologram.addLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
                    }
                    CMI.getInstance().getHologramManager().addHologram(cmiHologram);
                    cmiHologram.update();
                    HOLOGRAMS.add("NextEconomy" + position);
                }
            }
        }
        val npcRegistry = CitizensAPI.getNPCRegistry();
        val npc = npcRegistry.createNPC(EntityType.PLAYER, "");
        val skinName = account == null ? "Yuhtin" : account.getUsername();
        npc.data().set("player-skin-name", skinName);
        npc.data().set("nexteconomy", true);
        npc.setProtected(true);
        npc.spawn(location);
        npc.getEntity().setMetadata("nexteconomy", new FixedMetadataValue(NextEconomy.getInstance(), true));
        NPCS.add(npc.getId());
    }
}
Also used : SimpleAccount(com.nextplugins.economy.model.account.SimpleAccount) lombok.val(lombok.val) CMIHologram(com.Zrips.CMI.Modules.Holograms.CMIHologram) RankingValue(com.nextplugins.economy.configuration.RankingValue) ArrayList(java.util.ArrayList) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Aggregations

CMIHologram (com.Zrips.CMI.Modules.Holograms.CMIHologram)6 RankingValue (com.nextplugins.economy.configuration.RankingValue)4 lombok.val (lombok.val)4 ArrayList (java.util.ArrayList)3 SimpleAccount (com.nextplugins.economy.model.account.SimpleAccount)2 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)2 Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)1 ItemBuilder (com.nextplugins.economy.util.ItemBuilder)1 CMILocation (net.Zrips.CMILib.Container.CMILocation)1 ArmorStand (org.bukkit.entity.ArmorStand)1 ItemStack (org.bukkit.inventory.ItemStack)1