Search in sources :

Example 1 with NPCRunnable

use of com.nextplugins.economy.ranking.types.NPCRunnable in project NextEconomy by NextPlugins.

the class CustomRankingRegistry method register.

public void register() {
    val pluginManager = Bukkit.getPluginManager();
    String type = RankingValue.get(RankingValue::npcType);
    if (type.equalsIgnoreCase("nothing")) {
        plugin.getLogger().info("Cancelando registro de ranking por NPC, Holograma e ArmorStand, você desativou na ranking.yml.");
        return;
    }
    if (!pluginManager.isPluginEnabled("CMI") && !pluginManager.isPluginEnabled("HolographicDisplays")) {
        plugin.getLogger().log(Level.WARNING, "Dependência não encontrada ({0}) O ranking em NPC, Holograma e ArmorStand não serão usados.", "HolographicDisplays ou CMI");
        return;
    }
    holographicDisplays = pluginManager.isPluginEnabled("HolographicDisplays");
    boolean isNpc = type.equalsIgnoreCase("npc");
    if (isNpc && !pluginManager.isPluginEnabled("ProtocolLib")) {
        plugin.getLogger().log(Level.WARNING, "Dependência não encontrada ({0}) O ranking em NPC não será usado.", "ProtocolLib");
        return;
    }
    LocationLoader.of(plugin, plugin.getLocationManager()).loadLocations();
    if (isNpc)
        runnable = new NPCRunnable(plugin, holographicDisplays);
    else if (type.equalsIgnoreCase("armorstand"))
        runnable = new ArmorStandRunnable(plugin, plugin.getLocationManager(), plugin.getRankingStorage(), holographicDisplays);
    else
        runnable = new HologramRunnable(plugin, plugin.getLocationManager(), plugin.getRankingStorage(), holographicDisplays);
    enabled = true;
    plugin.getLogger().info("Sistema de NPC e ArmorStand registrado com sucesso.");
}
Also used : lombok.val(lombok.val) HologramRunnable(com.nextplugins.economy.ranking.types.HologramRunnable) ArmorStandRunnable(com.nextplugins.economy.ranking.types.ArmorStandRunnable) RankingValue(com.nextplugins.economy.configuration.RankingValue) NPCRunnable(com.nextplugins.economy.ranking.types.NPCRunnable)

Example 2 with NPCRunnable

use of com.nextplugins.economy.ranking.types.NPCRunnable in project NextEconomy by NextPlugins.

the class NextEconomyCommand method onPlayAnimationCommand.

@Command(name = "nexteconomy.playanimation", permission = "nexteconomy.admin", usage = "/ne playanimation <id ou all> <sticker ou emote> <animationId>", async = true)
public void onPlayAnimationCommand(Context<CommandSender> context, String npcId, String option, int animationId) {
    val runnable = CustomRankingRegistry.getInstance().getRunnable();
    if (!(runnable instanceof NPCRunnable)) {
        context.sendMessage(ColorUtil.colored("&cO modo de ranking deve ser npc."));
        return;
    }
    var action = LabyModModifier.LabyModAction.EMOTE;
    try {
        action = LabyModModifier.LabyModAction.valueOf(option.toUpperCase());
    } catch (Exception exception) {
        context.sendMessage(ColorUtil.colored("&cTipos de animação: sticker ou emote"));
        return;
    }
    val labyAction = action;
    val npcPool = ((NPCRunnable) runnable).getNpcPool();
    val npcs = new ArrayList<>(npcPool.getNPCs());
    try {
        if (npcId.equalsIgnoreCase("all")) {
            Bukkit.getScheduler().runTaskAsynchronously(NextEconomy.getInstance(), () -> {
                for (val npc : npcs) {
                    for (val player : npc.getSeeingPlayers()) {
                        npc.labymod().queue(labyAction, animationId).send(player);
                    }
                }
            });
            return;
        }
        val npc = npcs.get(Integer.parseInt(npcId));
        Bukkit.getScheduler().runTaskAsynchronously(NextEconomy.getInstance(), () -> {
            for (val player : npc.getSeeingPlayers()) {
                npc.labymod().queue(labyAction, animationId).send(player);
            }
        });
        context.sendMessage(ColorUtil.colored("&aAnimação executada em todos os npcs para jogadores com labymod!"));
    } catch (Exception exception) {
        val stringBuilder = new StringBuilder();
        int index = 0;
        for (int i = 0; i < npcs.size(); i++) {
            if (index != 0)
                stringBuilder.append(", ");
            stringBuilder.append(index);
            index++;
        }
        context.sendMessage(ColorUtil.colored("&cNão existe npc com esse id, ids válidos: [" + stringBuilder + "]"));
    }
}
Also used : lombok.val(lombok.val) lombok.var(lombok.var) ArrayList(java.util.ArrayList) NPCRunnable(com.nextplugins.economy.ranking.types.NPCRunnable) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Example 3 with NPCRunnable

use of com.nextplugins.economy.ranking.types.NPCRunnable in project NextEconomy by NextPlugins.

the class NextEconomyCommand method onRankingDebug.

@Command(name = "nexteconomy.rankingdebug", permission = "nexteconomy.admin", async = true)
public void onRankingDebug(Context<CommandSender> context) {
    val pluginManager = Bukkit.getPluginManager();
    if (!pluginManager.isPluginEnabled("HolographicDisplays")) {
        context.sendMessage(ColorUtil.colored("&cO plugin HolographicDisplays precisa estar ativo para usar esta função."));
        return;
    }
    for (val world : Bukkit.getWorlds()) {
        for (val entity : world.getEntities()) {
            if (!entity.hasMetadata("nexteconomy"))
                continue;
            entity.remove();
        }
    }
    HologramsAPI.getHolograms(NextEconomy.getInstance()).forEach(Hologram::delete);
    val runnable = CustomRankingRegistry.getInstance().getRunnable();
    if (runnable instanceof NPCRunnable) {
        val npcRunnable = (NPCRunnable) runnable;
        val npcPool = npcRunnable.getNpcPool();
        for (val npc : npcPool.getNPCs()) {
            npcPool.removeNPC(npc.getEntityId());
        }
    }
    context.sendMessage(ColorUtil.colored("&aTodos os NPCs, ArmorStands e Hologramas foram limpos com sucesso."));
}
Also used : lombok.val(lombok.val) Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) NPCRunnable(com.nextplugins.economy.ranking.types.NPCRunnable) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Aggregations

NPCRunnable (com.nextplugins.economy.ranking.types.NPCRunnable)3 lombok.val (lombok.val)3 Command (me.saiintbrisson.minecraft.command.annotation.Command)2 Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)1 RankingValue (com.nextplugins.economy.configuration.RankingValue)1 ArmorStandRunnable (com.nextplugins.economy.ranking.types.ArmorStandRunnable)1 HologramRunnable (com.nextplugins.economy.ranking.types.HologramRunnable)1 ArrayList (java.util.ArrayList)1 lombok.var (lombok.var)1