- Хроники
- Chaotic Throne: High Five
- Исходники
- Отсутствуют
- Сборка
- l2j-dev
Значит, в скриптах я полный ноль.
Коротко, нужно чтобы выводило бафф вот тут:
Но вместо бафа тут показывает %content%, как его вывести на эту страницу?
Вот скрипт:
Коротко, нужно чтобы выводило бафф вот тут:
Но вместо бафа тут показывает %content%, как его вывести на эту страницу?
Вот скрипт:
package services.community.custom;
import gnu.trove.list.array.TIntArrayList;
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.Effect;
import org.mmocore.gameserver.model.Playable;
import org.mmocore.gameserver.model.Player;
import org.mmocore.gameserver.model.Skill;
import org.mmocore.gameserver.model.components.player.community.Buff;
import org.mmocore.gameserver.model.entity.olympiad.Olympiad;
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);
private static ArrayList<String> pageBuffPlayer;
private static ArrayList<String> pageBuffPet;
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<>();
genPageBuff(pageBuffPlayer, 0, "Player");
genPage(pageBuffPlayer, "player");
genPageBuff(pageBuffPet, 0, "Pet");
genPage(pageBuffPet, "pet");
BuffScheme.load();
for (Integer id : BuffScheme.buffSchemes.keySet()) {
buffSchemesEn.append(GenerateElement.button(BuffScheme.buffSchemes.get(id).getNameEn(), "_bbscastgroupbuff " + id + " $Who", 169, 25, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF")).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", 169, 25, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF")).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 : 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 (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 (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 = allowBuff.indexOf(id);
if ((playable != null) && (check != -1) && (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%", pageBuffPlayer.get(page));
} else if ("Pet".equals(type)) {
html = html.replace("%content%", 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 (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) != 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();
int check = allowBuff.indexOf(skill.getId());
level = level > allowBuff.get(check + 1) ? allowBuff.get(check + 1) : level;
if (check != -1) {
buffs.append(id).append(",").append(level).append(";");
scheme.addBuff(id, level);
}
}
player.setScheme(name, scheme);
CharacterBuffsDAO.getInstance().insert(player, buffs.toString(), name);
}
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 : player.getScheme(name).getBuffs().entrySet()) {
if (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);
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 (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, "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 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 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, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF"));
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;
}
}
import gnu.trove.list.array.TIntArrayList;
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.Effect;
import org.mmocore.gameserver.model.Playable;
import org.mmocore.gameserver.model.Player;
import org.mmocore.gameserver.model.Skill;
import org.mmocore.gameserver.model.components.player.community.Buff;
import org.mmocore.gameserver.model.entity.olympiad.Olympiad;
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);
private static ArrayList<String> pageBuffPlayer;
private static ArrayList<String> pageBuffPet;
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<>();
genPageBuff(pageBuffPlayer, 0, "Player");
genPage(pageBuffPlayer, "player");
genPageBuff(pageBuffPet, 0, "Pet");
genPage(pageBuffPet, "pet");
BuffScheme.load();
for (Integer id : BuffScheme.buffSchemes.keySet()) {
buffSchemesEn.append(GenerateElement.button(BuffScheme.buffSchemes.get(id).getNameEn(), "_bbscastgroupbuff " + id + " $Who", 169, 25, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF")).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", 169, 25, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF")).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 : 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 (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 (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 = allowBuff.indexOf(id);
if ((playable != null) && (check != -1) && (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%", pageBuffPlayer.get(page));
} else if ("Pet".equals(type)) {
html = html.replace("%content%", 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 (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) != 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();
int check = allowBuff.indexOf(skill.getId());
level = level > allowBuff.get(check + 1) ? allowBuff.get(check + 1) : level;
if (check != -1) {
buffs.append(id).append(",").append(level).append(";");
scheme.addBuff(id, level);
}
}
player.setScheme(name, scheme);
CharacterBuffsDAO.getInstance().insert(player, buffs.toString(), name);
}
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 : player.getScheme(name).getBuffs().entrySet()) {
if (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);
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 (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, "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 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 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, "L2UI_CT1.Button_DF_Down", "L2UI_CT1.Button_DF"));
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;
}
}