Баф сервис

Статус
В этой теме нельзя размещать новые ответы.

Dovonext

Lineage 2
Участник
Сообщения
129
Розыгрыши
0
Решения
1
Репутация
66
Реакции
18
Баллы
283
Хроники
  1. Chaotic Throne: High Five
Исходники
Присутствуют
Сборка
l2j-dev
Подскажите что я не так сделал.
Почему в списке схем показывает вот так ?

Java:
package services.community.custom;

import gnu.trove.list.array.TIntArrayList;
import org.apache.commons.lang3.ArrayUtils;
import org.mmocore.gameserver.Config;
import org.mmocore.gameserver.common.*;
import org.mmocore.gameserver.dao.CharacterBuffsDAO;
import org.mmocore.gameserver.data.htm.HtmCache;
import org.mmocore.gameserver.handler.bbs.BbsHandlerHolder;
import org.mmocore.gameserver.handler.bbs.IBbsHandler;
import org.mmocore.gameserver.listener.script.OnInitScriptListener;
import org.mmocore.gameserver.model.*;
import org.mmocore.gameserver.model.components.player.community.Buff;
import org.mmocore.gameserver.model.entity.olympiad.Olympiad;
import org.mmocore.gameserver.model.items.ItemInstance;
import org.mmocore.gameserver.scripts.Functions;
import org.mmocore.gameserver.serverpackets.ExShowScreenMessage;
import org.mmocore.gameserver.serverpackets.MagicSkillUse;
import org.mmocore.gameserver.serverpackets.ShowBoard;
import org.mmocore.gameserver.serverpackets.components.CustomMessage;
import org.mmocore.gameserver.tables.SkillTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

public class Buffer extends Functions implements OnInitScriptListener, IBbsHandler {

    private static final Logger _log = LoggerFactory.getLogger(Buffer.class);
    //обычный бафф
    private static final TIntArrayList allowBuff = new TIntArrayList(Config.BBS_BUFFER_ALLOWED_BUFF);
    //PA бафф
    private static final TIntArrayList allowBuffPremium = new TIntArrayList(Config.BBS_BUFFER_ALLOWED_BUFF_PREMIUM);
    //масив для простых играков и петов
    private static ArrayList<String> pageBuffPlayer;
    private static ArrayList<String> pageBuffPet;
    //масив для премиум играков и петов
    private static ArrayList<String> pageBuffPlayerPremium;
    private static ArrayList<String> pageBuffPetPremium;
    private static StringBuilder buffSchemesEn = new StringBuilder();
    private static StringBuilder buffSchemesRu = new StringBuilder();
    private static Map<Integer, Long> reuse_scheme = new HashMap<>();
    private static Map<Integer, Long> reuse_group = new HashMap<>();


    @Override
    public void onInit() {
        _log.info("CommunityBoard: Community Buffer loaded.");
        BbsHandlerHolder.getInstance().registerHandler(this);

        pageBuffPlayer = new ArrayList<>();
        pageBuffPet = new ArrayList<>();

        pageBuffPlayerPremium = new ArrayList<>();
        pageBuffPetPremium = new ArrayList<>();

        //генерация страницы для простых играков
        genPageBuff(pageBuffPlayer, 0, "Player");
        genPage(pageBuffPlayer, "player");

        //генерация страницы для премиум играков
        genPageBuffPremium(pageBuffPlayerPremium, 0, "Player");
        genPagePremium(pageBuffPlayerPremium, "player");

        //генерация страницы для простых играков
        genPageBuff(pageBuffPet, 0, "Pet");
        genPage(pageBuffPet, "pet");

        //генерация страницы для премиум играков
        genPageBuffPremium(pageBuffPetPremium, 0, "Pet");
        genPagePremium(pageBuffPetPremium, "pet");

        BuffScheme.load();

        for (Integer id : BuffScheme.buffSchemes.keySet()) {
            buffSchemesEn.append(GenerateElement.button(BuffScheme.buffSchemes.get(id).getNameEn(), "_bbscastgroupbuff " + id + " $Who", 180, 30, "battle_news.btn_buff_fighter", "battle_news.btn_buff_fighter")).append("<br1>").append(BuffScheme.buffSchemes.get(id).getPriceCount()).append(" ").append(DifferentMethods.getItemName(BuffScheme.buffSchemes.get(id).getPriceId()));
        }

        for (Integer id : BuffScheme.buffSchemes.keySet()) {
            buffSchemesRu.append(GenerateElement.button(BuffScheme.buffSchemes.get(id).getNameRu(), "_bbscastgroupbuff " + id + " $Who", 180, 30, "battle_news.btn_buff_mage", "battle_news.btn_buff_mage")).append("<br1>").append(BuffScheme.buffSchemes.get(id).getPriceCount()).append(" ").append(DifferentMethods.getItemName(BuffScheme.buffSchemes.get(id).getPriceId()));
        }
    }

    @Override
    public String[] getBypassCommands() {
        return new String[]{"_bbsbuffer", "_bbsplayerbuffer", "_bbspetbuffer", "_bbscastbuff", "_bbscastgroupbuff", "_bbsbuffersave", "_bbsbufferuse", "_bbsbufferdelete", "_bbsbufferheal", "_bbsbufferremovebuffs"};
    }

    @Override
    public void onBypassCommand(Player player, String bypass) {
        if (!Config.BBS_BUFFER_ALLOWED_BUFFER) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            DifferentMethods.communityNextPage(player, "_bbshome");
            return;
        }
        if (!check(player)) {
            DifferentMethods.communityNextPage(player, "_bbshome");
            return;
        }
        String html = "";
        if (bypass.equals("_bbsbuffer")) {
            html = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/buffer/index.htm", player);
            html = html.replace("%scheme%", player.isLangRus() ? buffSchemesRu.toString() : buffSchemesEn.toString());
            html = html.replace("%itemcount%", Config.ALTERNATIVE_BUFF_COUNT ? String.valueOf(OneBuffs(player)) : String.valueOf(Config.BBS_BUFFER_PRICE_ONE));
            String template = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/buffer/my-sheme.htm", player);
            String block = "";
            String list = null;
            for (String name : getAccessVipBuffer(player)? player.getSchemesPremium().keySet() : player.getSchemes().keySet()) {
                block = template;
                block = block.replace("{bypass}", "bypass _bbsbufferuse " + name + " $Who");
                block = block.replace("{name}", name);
                block = block.replace("{delete}", "bypass _bbsbufferdelete " + name);
                list = list + block;
            }

            if (list != null) {
                html = html.replace("%buffgrps%", list);
            } else {
                html = html.replace("%buffgrps%", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/buffer/my-sheme-empty.htm", player));
            }
        } else if (bypass.startsWith("_bbsplayerbuffer")) {
            html = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/buffer/scheme.htm", player);
            StringTokenizer st1 = new StringTokenizer(bypass, ":");
            st1.nextToken();
            int page = Integer.parseInt(st1.nextToken());
            if (getAccessVipBuffer(player)) {
                if (pageBuffPlayerPremium.get(page) != null) {
                    html = html.replace("%content%", pageBuffPlayerPremium.get(page));
                }
            }
            else {
                if (pageBuffPlayer.get(page) != null) {
                    html = html.replace("%content%", pageBuffPlayer.get(page));
                }
            }
        } else if (bypass.startsWith("_bbspetbuffer")) {
            html = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/buffer/scheme.htm", player);
            StringTokenizer st1 = new StringTokenizer(bypass, ":");
            st1.nextToken();
            int page = Integer.parseInt(st1.nextToken());
            if (getAccessVipBuffer(player)) {
                if (pageBuffPetPremium.get(page) != null) {
                    html = html.replace("%content%", pageBuffPetPremium.get(page));
                }
            }
            else {
                if (pageBuffPet.get(page) != null) {
                    html = html.replace("%content%", pageBuffPet.get(page));
                }
            }
        } else if (bypass.startsWith("_bbscastbuff")) {

            StringTokenizer st1 = new StringTokenizer(bypass, ":");
            st1.nextToken();
            if (player.isInTvT() || player.isInCtF() || player.isInLastHero()) {
                return;
            }

            int id = Integer.parseInt(st1.nextToken());
            int level = Integer.parseInt(st1.nextToken());
            int page = Integer.parseInt(st1.nextToken());
            String type = st1.nextToken();
            String pagehtml = st1.hasMoreTokens() ? st1.nextToken() : null;
            String nextpage = pagehtml == null ? "pages/buffer/scheme.htm" : "pages/buffer/"+pagehtml+".htm";
            html = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + nextpage, player);
            Playable playable = null;
            if ("Player".equals(type)) {
                playable = player;
            } else if ("Pet".equals(type)) {
                playable = player.getServitor();
            }

            int check = getAccessVipBuffer(player) ? allowBuffPremium.indexOf(id) : allowBuff.indexOf(id);

            if (playable != null && check != -1 && getAccessVipBuffer(player) ? allowBuffPremium.get(check + 1) <= level : allowBuff.get(check + 1) <= level) {
                if (player.getLevel() <= Config.CBB_BUFFER_FREE_LEVEL) {
                    buffList(Collections.singletonList(new Buff(id, level)), playable);
                } else if (DifferentMethods.getPay(player, Config.BBS_BUFFER_PRICE_ID, Config.ALTERNATIVE_BUFF_COUNT ? OneBuffs(player) : Config.BBS_BUFFER_PRICE_ONE, true)) {
                    buffList(Collections.singletonList(new Buff(id, level)), playable);
                }
            }
            if ("Player".equals(type)) {
                html = html.replace("%content%", getAccessVipBuffer(player) ? pageBuffPlayerPremium.get(page) : pageBuffPlayer.get(page));
            } else if ("Pet".equals(type)) {
                html = html.replace("%content%", getAccessVipBuffer(player) ? pageBuffPetPremium.get(page) : pageBuffPet.get(page));
            }
        } else {
            if (bypass.startsWith("_bbscastgroupbuff")) {
                StringTokenizer st1 = new StringTokenizer(bypass, " ");
                st1.nextToken();
                int id = Integer.parseInt(st1.nextToken());
                String type = st1.nextToken();
                int priceId = BuffScheme.buffSchemes.get(id).getPriceId();
                int priceCount = Config.ALTERNATIVE_BUFF_COUNT ? GroupBuffs(player) : BuffScheme.buffSchemes.get(id).getPriceCount();

                Playable playable = null;
                if ("Player".equals(type)) {
                    playable = player;
                } else if ("Pet".equals(type)) {
                    playable = player.getServitor();
                }
                if (playable != null) {
                    if (reuse_group.containsKey(player.getObjectId())) {
                        int time = (int) ((reuse_group.get(player.getObjectId()) - System.currentTimeMillis()) / 1000L);
                        if (time > 0) {
                            player.sendMessage("Wait " + time + " seconds for use this function.");
                            DifferentMethods.communityNextPage(player, "_bbsbuffer");
                            return;
                        }
                    }
                    reuse_group.put(player.getObjectId(), System.currentTimeMillis() + 5000L);
                    if (player.getLevel() < Config.CBB_BUFFER_FREE_LEVEL) {
                        buffList(BuffScheme.buffSchemes.get(id).getBuffIds(), playable);
                    } else if (DifferentMethods.getPay(player, priceId, priceCount, true)) {
                        buffList(BuffScheme.buffSchemes.get(id).getBuffIds(), playable);
                    }
                }
                DifferentMethods.communityNextPage(player, "_bbsbuffer");
                return;
            }
            if (bypass.startsWith("_bbsbuffersave")) {
                if (getAccessVipBuffer(player) ? player.getSchemesPremium().size() > 5 : player.getSchemes().size() >= 5) {
                    player.sendMessage(player.isLangRus() ? "Можно хранить не более 5ти схем." : "You can store up to 5 tee schemes");
                    DifferentMethods.communityNextPage(player, "_bbsbuffer");
                    return;
                }

                StringTokenizer st1 = new StringTokenizer(bypass, " ");

                if (st1.countTokens() < 3) {
                    DifferentMethods.communityNextPage(player, "_bbsbuffer");
                    return;
                }

                st1.nextToken();

                String name = st1.nextToken();
                String type = st1.nextToken();

                Playable playable = null;
                if ("Player".equals(type)) {
                    playable = player;
                } else if ("Pet".equals(type)) {
                    playable = player.getServitor();
                }
                if (playable == null) {
                    return;
                }
                if (playable.getEffectList().getAllEffects().size() == 0) {
                    DifferentMethods.communityNextPage(player, "_bbsbuffer");
                    return;
                }

                if (player.getScheme(name.toLowerCase()) != null || player.getSchemePremium(name.toLowerCase()) != null) {
                    player.sendMessage(player.isLangRus() ? "Такое имя схемы уже есть." : "Such a scheme name already exists");
                    DifferentMethods.communityNextPage(player, "_bbsbuffer");
                    return;
                }

                if (DifferentMethods.getPay(player, Config.BBS_BUFFER_SAVE_PRICE_ID, Config.BBS_BUFFER_SAVE_PRICE_ONE, true)) {
                    StringBuilder buffs = new StringBuilder();
                    Scheme scheme = new Scheme(name);
                    for (Effect effect : playable.getEffectList().getAllEffects()) {
                        Skill skill = effect.getSkill();
                        int id = skill.getId();
                        int level = skill.getLevel();
                        if(!getCheckBuffs(skill.getId(), getAccessVipBuffer(player)))
                            continue;
                        int check = (getAccessVipBuffer(player) && allowBuffPremium.size() > 0) ? allowBuffPremium.indexOf(skill.getId()) : allowBuff.indexOf(skill.getId());
                        if (getAccessVipBuffer(player) && allowBuffPremium.size() > 0) {
                            level = Math.min(level, allowBuffPremium.get(check + 1));
                        }else {
                            level = Math.min(level, allowBuff.get(check + 1));
                        }

                        if (check != -1) {
                            buffs.append(id).append(",").append(level).append(";");
                            scheme.addBuff(id, level);
                        }
                    }
                    if(getAccessVipBuffer(player)) {
                        player.setSchemePremium(name, scheme);
                    }else {
                        player.setScheme(name, scheme);
                    }
                    CharacterBuffsDAO.getInstance().insert(player, buffs.toString(), name, (getAccessVipBuffer(player)));
                }

                DifferentMethods.communityNextPage(player, "_bbsbuffer");
                return;
            }
            if (bypass.startsWith("_bbsbufferuse")) {
                StringTokenizer st1 = new StringTokenizer(bypass, " ");
                st1.nextToken();
                String name = st1.nextToken();
                String type = st1.nextToken();
                Playable playable = null;

                if ("Player".equals(type)) {
                    playable = player;
                } else if ("Pet".equals(type)) {
                    playable = player.getServitor();
                }
                if (playable != null) {
                    if (reuse_scheme.containsKey(player.getObjectId())) {
                        int time = (int) ((reuse_scheme.get(player.getObjectId()) - System.currentTimeMillis()) / 1000L);
                        if (time > 0) {
                            player.sendMessage("Wait " + time + " seconds for use this function.");
                            DifferentMethods.communityNextPage(player, "_bbsbuffer");
                            return;
                        }
                    }
                    reuse_scheme.put(player.getObjectId(),System.currentTimeMillis() + 5000L);
                    List<Buff> buffs = new ArrayList<>();
                    try {
                        for (Map.Entry<Integer,Integer> scheme : getAccessVipBuffer(player) ? player.getSchemePremium(name).getBuffs().entrySet() : player.getScheme(name).getBuffs().entrySet()) {
                            if (getAccessVipBuffer(player) ? allowBuffPremium.indexOf(scheme.getKey()) != -1 : allowBuff.indexOf(scheme.getKey()) != -1) {
                                if (player.getLevel() <= Config.CBB_BUFFER_FREE_LEVEL) {
                                    buffs.add(new Buff(scheme.getKey(),scheme.getValue()));
                                } else if (Config.SAVE_BUFFS) {
                                    buffs.add(new Buff(scheme.getKey(),scheme.getValue()));
                                } else if (DifferentMethods.getPay(player,Config.BBS_BUFFER_PRICE_ID,Config.BBS_BUFFER_PRICE_ONE,true)) {
                                    buffs.add(new Buff(scheme.getKey(),scheme.getValue()));
                                }
                            }
                        }
                    } catch (Exception e) {
                    }
                    if (Config.SAVE_BUFFS) {
                        if (DifferentMethods.getPay(player,Config.BUFFER_SAVE_PRICE_ID,Config.BUFFER_SAVE_PRICE,true)) {
                            buffList(buffs,playable);
                        }
                    }
                    else
                        buffList(buffs,playable);
                }
                DifferentMethods.communityNextPage(player, "_bbsbuffer");
                return;
            }
            if (bypass.startsWith("_bbsbufferdelete")) {
                StringTokenizer st1 = new StringTokenizer(bypass, " ");
                st1.nextToken();
                String name = st1.nextToken();
                CharacterBuffsDAO.getInstance().delete(player, name);
                if (getAccessVipBuffer(player)) {
                    player.removeSchemePremium(name);
                }
                else {
                    player.removeScheme(name);
                }
                DifferentMethods.communityNextPage(player, "_bbsbuffer");
                return;
            }
            if (bypass.startsWith("_bbsbufferheal")) {
                if (!Config.BBS_BUFFER_RECOVER_HP_MP_CP) {
                    player.sendMessage(player.isLangRus() ? "Сервис отключен." : "Service disabled");
                } else if (!player.isInZonePeace() && Config.BUFF_HEAL_IS_IN_PEACE) {
                    player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Восстанавливать статы можно только в мирной зоне" : "To restore stats can only be in a peaceful area", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
                } else {
                    StringTokenizer st1 = new StringTokenizer(bypass, " ");
                    st1.nextToken();
                    String type = st1.nextToken();
                    String target = st1.nextToken();

                    Playable playable = null;
                    if ("Player".equals(target)) {
                        playable = player;
                    } else if ("Pet".equals(target)) {
                        playable = player.getServitor();
                    }
                    if (playable != null) {
                        switch (type) {
                            case "HP":
                                if (DifferentMethods.getPay(player, Config.HP_ITEM_ID, Config.HP_ITEM_COUNT, true)) {
                                    if (playable.getCurrentHp() != playable.getMaxHp())
                                        playable.setCurrentHp(playable.getMaxHp(), true, true);
                                    else
                                        DifferentMethods.communityNextPage(player, "_bbsbuffer");
                                    break;
                                }
                                return;
                            case "MP":
                                if (DifferentMethods.getPay(player, Config.MP_ITEM_ID, Config.MP_ITEM_COUNT, true)) {
                                    if (playable.getCurrentMp() != playable.getMaxMp())
                                        playable.setCurrentMp(playable.getMaxMp(), true);
                                    else
                                        DifferentMethods.communityNextPage(player, "_bbsbuffer");
                                    break;
                                }
                                return;
                            case "CP":
                                if (DifferentMethods.getPay(player, Config.CP_ITEM_ID, Config.CP_ITEM_COUNT, true)) {
                                if (playable.getCurrentCp() != playable.getMaxCp())
                                    playable.setCurrentCp(playable.getMaxCp(), true);
                                else
                                    DifferentMethods.communityNextPage(player, "_bbsbuffer");
                                break;
                            }
                                return;
                            case "ALL":
                                if (DifferentMethods.getPay(player, Config.ALL_ITEM_ID, Config.ALL_ITEM_COUNT, true)) {
                                    if (playable.getCurrentHp() != playable.getMaxHp())
                                        playable.setCurrentHp(playable.getMaxHp(), true, true);
                                    if (playable.getCurrentMp() != playable.getMaxMp())
                                        playable.setCurrentMp(playable.getMaxMp(), true);
                                    if (playable.getCurrentCp() != playable.getMaxCp())
                                        playable.setCurrentCp(playable.getMaxCp(), true);
                                    else
                                        DifferentMethods.communityNextPage(player, "_bbsbuffer");
                                    break;
                                }
                                return;
                            default:
                                DifferentMethods.clear(player);
                                break;

                        }
                        playable.broadcastPacket(new MagicSkillUse(playable, playable, 6696, 1, 1000, 0L));
                    }
                }
                DifferentMethods.communityNextPage(player, "_bbsbuffer");
                return;
            }
            if (bypass.startsWith("_bbsbufferremovebuffs")) {
                if (!Config.BBS_BUFFER_CLEAR_BUFF) {
                    player.sendMessage(player.isLangRus() ? "Сервис отключен." : "Service disabled");
                } else {
                    StringTokenizer st1 = new StringTokenizer(bypass, " ");
                    st1.nextToken();
                    String type = st1.nextToken();

                    Playable playable = null;
                    if ("Player".equals(type)) {
                        playable = player;
                    } else if ("Pet".equals(type)) {
                        playable = player.getServitor();
                    }
                    if (playable != null) {
                        for (Effect effect : playable.getEffectList().getAllEffects()) {
                            if (effect.getSkill().getSkillType() == Skill.SkillType.BUFF || effect.getSkill().getSkillType() == Skill.SkillType.COMBATPOINTHEAL) {
                             if (Config.DELETE_BUFS_ONLY_BUFFER){
                                 if (getAccessVipBuffer(player) ? allowBuffPremium.indexOf(effect.getSkill().getId()) != -1 : allowBuff.indexOf(effect.getSkill().getId()) != -1)
                                     effect.exit();
                             }
                                else
                                    effect.exit();
                            }
                        }
                        playable.broadcastPacket(new MagicSkillUse(playable, playable, 6696, 1, 1000, 0L));
                    }
                }
                DifferentMethods.communityNextPage(player,"_bbsbuffer");
                return;
            }

            ShowBoard.separateAndSend("<html><body><br><br><center>" + new CustomMessage("communityboard.notdone", player).addString(bypass) + "</center><br><br></body></html>", player);
        }
        ShowBoard.separateAndSend(html, player);
    }

    public void onWriteCommand(Player player, String bypass, String arg1, String arg2, String arg3, String arg4, String arg5) {
    }

    private static void genPage(ArrayList<String> list, String type) {

        StringBuilder sb = new StringBuilder("<table><tr>");
        sb.append("<td width=70>Навигация: </td>");

        for (int i = 0; i < list.size(); i++) {
            sb.append(GenerateElement.buttonTD(String.valueOf(i + 1), "_bbs" + type + "buffer:" + i, 25, 25, "battle_news.btn_buff_fighter", "battle_news.btn_buff_fighter"));
        }

        sb.append("<td>").append(GenerateElement.button("Назад", "_bbsbuffer", 60, 25, "battle_news.btn_buff_fighter", "battle_news.btn_buff_fighter")).append("</td></tr></table><br><br>");

        for (int i = 0; i < list.size(); i++) {
            list.set(i, sb.toString() + list.get(i));
        }
    }

    private static void genPageBuff(ArrayList<String> list, int start, String type) {
        StringBuilder buffPages = new StringBuilder("<table><tr>");
        int i = start;
        boolean next = false;
        for (; i < allowBuff.size(); i += 2) {
            if ((next) && (i % 12 == 0)) {
                buffPages.append("</tr><tr>");
            }
            if ((next) && (i % 48 == 0)) {
                break;
            }
            buffPages.append("<td>").append(buttonBuff(allowBuff.get(i), allowBuff.get(i + 1), list.size(), type)).append("</td>");
            next = true;
        }
        buffPages.append("</tr></table>");

        list.add(buffPages.toString());

        if (i + 2 <= allowBuff.size()) {
            genPageBuff(list, i, type);
        }
    }


    private static void genPagePremium(ArrayList<String> list, String type) {

        StringBuilder sb = new StringBuilder("<table><tr>");
        sb.append("<td width=70>Навигация: </td>");

        for (int i = 0; i < list.size(); i++) {
            sb.append(GenerateElement.buttonTD(String.valueOf(i + 1), "_bbs" + type + "buffer:" + i, 25, 25, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF"));
        }

        sb.append("<td>").append(GenerateElement.button("Назад", "_bbsbuffer", 60, 25, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF")).append("</td></tr></table><br><br>");

        for (int i = 0; i < list.size(); i++) {
            list.set(i, sb.toString() + list.get(i));
        }
    }

    private static void genPageBuffPremium(ArrayList<String> list, int start, String type) {
        StringBuilder buffPages = new StringBuilder("<table><tr>");
        int i = start;
        boolean next = false;
        for (; i < allowBuffPremium.size(); i += 2) {
            if ((next) && (i % 12 == 0)) {
                buffPages.append("</tr><tr>");
            }
            if ((next) && (i % 48 == 0)) {
                break;
            }
            buffPages.append("<td>").append(buttonBuff(allowBuffPremium.get(i), allowBuffPremium.get(i + 1), list.size(), type)).append("</td>");
            next = true;
        }
        buffPages.append("</tr></table>");

        list.add(buffPages.toString());

        if (i + 2 <= allowBuffPremium.size()) {
            genPageBuffPremium(list, i, type);
        }
    }

    private static boolean getCheckBuffs(int skillId, boolean premium){
        boolean success = false;
        int size = premium ? allowBuffPremium.size() : allowBuff.size();
        int i = 0;
        for (; i < size; i +=2){
            if (premium){
                if (allowBuffPremium.get(i) == skillId)
                    success = true;
            }else if (allowBuff.get(i) == skillId)
                success = true;
        }

        return success;
    }

    private static String buttonBuff(int id, int level, int page, String type) {
        Skill skill = SkillTable.getInstance().getInfo(id, level);
        StringBuilder sb = new StringBuilder("<table width=100>");
        String name = SkillTable.getInstance().getInfo(id, level).getName();
        name = name.replace("Dance of the", "D.");
        name = name.replace("Dance of", "D.");
        name = name.replace("Song of", "S.");
        name = name.replace("Improved", "I.");
        name = name.replace("Awakening", "A.");
        name = name.replace("Blessing", "Bless.");
        name = name.replace("Protection", "Protect.");
        name = name.replace("Critical", "C.");
        name = name.replace("Condition", "Con.");
        sb.append("<tr><td><center><img src=icon.skill").append(skill.getIcon()).append(" width=32 height=32><br><font color=F2C202>Level ").append(level).append("</font></center></td></tr>");
        sb.append(GenerateElement.buttonTR(name, "_bbscastbuff:" + id + ":" + level + ":" + page + ":" + type, 100, 25, "battle_news.btn_profile", "battle_news.btn_profile"));
        sb.append("</table>");
        return sb.toString();
    }

    private static void buffList(List<Buff> list, Playable playable) {
        new BuffTask(list, playable).run();
    }

    private boolean check(Player player) {
        if ((Config.ENABLE_OLYMPIAD && Olympiad.isRegisteredInComp(player)) || player.isInOlympiadMode()) {
            player.sendMessage(new CustomMessage("scripts.services.olympiad.enable", player));
            return false;
        }

        if (!Config.BUFF_DEATH && (player.isDead() || player.isAlikeDead() || player.isFakeDeath())) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "В данный момент нельзя использовать Community Buffer" : "At this point you can not use Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_ACTION && (player.isCastingNow() || player.isInCombat() || player.isAttackingNow())) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "В данный момент нельзя использовать Community Buffer" : "At this point you can not use Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_OLY && player.isInOlympiadMode()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Нельзя использовать Community Buffer находясь на стадионе Олимпиады" : "You can not use Community Buffer being on the Olympic Stadium", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_FLY && (player.isFlying() || player.isInFlyingTransform())) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Нельзя использовать Community Buffer находясь в полёте" : "You can not use Community Buffer while in flight", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_VEICHLE && player.isInBoat()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Нельзя использовать Community Buffer находясь на борту корабля" : "You can not use Community Buffer while on board ship", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_MOUNTED && player.isMounted()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Нельзя использовать Community Buffer сидя на животном" : "You can not use Community Buffer sitting on the animal", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_CANT_MOVE && (player.isMovementDisabled() || player.isParalyzed() || player.isStunned() || player.isSleeping() || player.isRooted() || player.isImmobilized())) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "В данный момент нельзя использовать Community Buffer" : "At this point you can not use Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_STORE_MODE && (player.isInStoreMode() || player.isInTrade() || player.isInOfflineMode())) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Во время трейда нельзя использовать Community Buffer" : "While trades can not use the Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_FISHING && player.isFishing()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Нельзя во время рыбалки использовать Community Buffer" : "Do not use while fishing Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_TEMP_ACTION && (player.isLogoutStarted() || player.isTeleporting()) && !player.isKoreanStyle()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "В данный момент нельзя использовать Community Buffer" : "At this point you can not use Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_DUEL && player.isInDuel()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Во время дуэли нельзя использовать Community Buffer" : "During the duel, you can not use Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_CURSED && player.isCursedWeaponEquipped()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Владелец проклятого оружия не может использовать Community Buffer" : "The owner of the cursed weapons can not use the Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_PK && player.getKarma() > 0) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Убийца игроков не может использовать Community Buffer" : "Killer players can not use the Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (Config.BUFF_LEADER && !player.isClanLeader()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Buffer может использовать только лидер клана" : "Community Buffer can use only the clan leader", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (Config.BUFF_NOBLE && !player.isNoble()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Buffer может использовать только Дворянин" : "Community Buffer can only use the Noble", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_TERITORY && player.isOnSiegeField()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Buffer нельзя использовать во время осады" : "Community Buffer can not be used during the siege", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (Config.BUFF_PEACEZONE_ONLY && !player.isInZonePeace()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Buffer можно использовать только в мирной зоне" : "Community Buffer can be used only in a peaceful area", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (!Config.BUFF_EVENTS && player.isInEvents()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Вы записаны на ивент, поэтому не можете использовать Community Buffer" : "You are recorded on the event, and therefore can not use the Community Buffer", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (player.getVarInt("jailed") > 0) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Buffer нельзя использовать в тюрьме" : "Community Buffer can not be used in prison", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (Config.PREMIUM_BUFF && !player.hasBonus()) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Buffer можно использовать только Премиум игрокам" : "Community Buffer you can only use Premium players", 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true));
            return false;
        }

        if (player.getPvpFlag() > 0 && !Config.BUFF_PVP_FLAG) {
            player.sendPacket(new ExShowScreenMessage(player.isLangRus() ? "Community Board нельзя использовать в режиме ПвП" : "Community Board сan not be used in PvP mode",5000,ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER,true));
            return false;
        }

        return true;
    }

    /**
     * Цена одного бафа зависимая от лвл игрока
     */

    private static int OneBuffs(Player player){
        if (player.getLevel() >= 1 && player.getLevel() < 19)
            return Config.ONE_BUFF_NG;
        else if (player.getLevel() >= 20 && player.getLevel() < 39)
            return Config.ONE_BUFF_D;
        else if (player.getLevel() >= 40 && player.getLevel() < 51)
            return Config.ONE_BUFF_C;
        else if (player.getLevel() >= 52 && player.getLevel() < 60)
            return Config.ONE_BUFF_B;
        else if (player.getLevel() >= 61 && player.getLevel() < 74)
            return Config.ONE_BUFF_A;
        else if (player.getLevel() >= 75 && player.getLevel() < 79)
            return Config.ONE_BUFF_S;
        else if (player.getLevel() > 80 && player.getLevel() < 86)
            return Config.ONE_BUFF_S84;

        return Config.ONE_BUFF_S84;
    }

    /**
     * Цена групп бафа зависимая от лвл игрока
     */

    private static int GroupBuffs(Player player){
        if (player.getLevel() >= 1 && player.getLevel() < 19)
            return Config.GROUP_BUFF_NG;
        else if (player.getLevel() >= 20 && player.getLevel() < 39)
            return Config.GROUP_BUFF_D;
        else if (player.getLevel() >= 40 && player.getLevel() < 51)
            return Config.GROUP_BUFF_C;
        else if (player.getLevel() >= 52 && player.getLevel() < 60)
            return Config.GROUP_BUFF_B;
        else if (player.getLevel() >= 61 && player.getLevel() < 74)
            return Config.GROUP_BUFF_A;
        else if (player.getLevel() >= 75 && player.getLevel() < 79)
            return Config.GROUP_BUFF_S;
        else if (player.getLevel() > 80 && player.getLevel() < 86)
            return Config.GROUP_BUFF_S84;

        return Config.GROUP_BUFF_S84;
    }

    private static  boolean checkItem(Player player){
        boolean result = false;
        for (ItemInstance item : player.getInventory().getItems()) {
            if (ArrayUtils.contains(Config.ALLOW_ACCESS_ITEM_ID, item.getItemId()))
                return true;
        }

        return result;
    }

    public static boolean getAccessVipBuffer(Player player){
        boolean success = false;
        int access = Config.ALLOW_ACCESS;
        switch (access){
            case 0:
                if (player.hasBonus())
                    return true;
                break;
            case 1:
                if (checkItem(player))
                    return true;
                break;
            case 2:
                if (checkItem(player) || player.hasBonus())
                    return true;
                    break;
        }

        return success;
    }
}

И схему вторую или третью сохраняешь, получается так.


Всё, разобрался.
 
Последнее редактирование:
Нет там кнопка удаления должна быть в виде крестика, а я её удалил
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху Снизу