Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Баффер для комьюнити L2Jserver Hive Five
#11
в общем химичил, химичил, получилось вот это

Код:
package com.l2jserver.gameserver.communitybbs.Manager;

import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.model.skills.L2Skill;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import com.l2jserver.gameserver.model.effects.L2Effect;

public class BuffBBSManager extends BaseBBSManager
{
  private static BuffBBSManager _instance = new BuffBBSManager();
  public int[][] allskillid_1;

  public BuffBBSManager()
  {
    Load();
  }

  public static BuffBBSManager getInstance()
  {
    if (_instance == null)
      _instance = new BuffBBSManager();
    return _instance;
  }

  public void Load()
  {
    try (Connection con = L2DatabaseFactory.getInstance().getConnection();
    Statement s = con.createStatement();
    ResultSet countt = s.executeQuery("SELECT COUNT(*) FROM communitybuff;");
    ResultSet skills = s.executeQuery("SELECT * FROM communitybuff");)
    {
      countt.next();
      this.allskillid_1 = new int[countt.getInt(1)][4];
      for (int i = 0; i < this.allskillid_1.length; i++)
      {
        skills.next();
        this.allskillid_1[i][0] = skills.getInt(2);
        this.allskillid_1[i][1] = skills.getInt(3);
        this.allskillid_1[i][2] = skills.getInt(4);
        this.allskillid_1[i][3] = skills.getInt(5);
      }

      countt.close();
      skills.close();
    }
    catch (Exception ignored)
    {
    }
  }

  public void parsecmd(String command, L2PcInstance activeChar)
  {
    String[] parts = command.split("_");
    boolean petbuff = false;

    if ((activeChar.isDead()) || (activeChar.isAlikeDead()) || (TvTEvent.isStarted()) || (activeChar.isInSiege()) || (activeChar.isCastingNow()) || (activeChar.isInCombat()) || (activeChar.isAttackingNow()) || (activeChar.isInOlympiadMode()) || (activeChar.isFlying()) || (activeChar.getKarma() > 0) || (activeChar.isInDuel()))
    {
      activeChar.sendMessage("Вы не можете использовать Бафера в данных условиях!");
      
    }
    else
    {
    if (!parts[2].startsWith("buff"))
    return;
    String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/3.htm");
    separateAndSend(content, activeChar);

    if ((parts[4] != null) && (parts[4].startsWith("Персонаж")))
    {
      petbuff = false;
    }
    if ((parts[4] != null) && (parts[4].startsWith("Питомец")))
    {
        petbuff = true;
    }
    
    if (parts[3].startsWith("FIGHERLIST"))
    {
        FIGHERLIST(activeChar, petbuff);
    }
    if (parts[3].startsWith("DANCEFIGHTERLIST"))
    {
        DANCEFIGHTERLIST(activeChar, petbuff);
    }
    if (parts[3].startsWith("MAGELIST"))
    {
        MAGELIST(activeChar, petbuff);
    }
    if (parts[3].startsWith("DANCEMAGELIST"))
    {
        DANCEMAGELIST(activeChar, petbuff);
    }
    if (parts[3].startsWith("SAVE"))
    {
        SAVE(activeChar, petbuff);
    }
    if (parts[3].startsWith("BUFF"))
    {
       BUFF(activeChar, petbuff);
    }
    if (parts[3].startsWith("CANCEL"))
    {
        CANCEL(activeChar, petbuff);
    }
    if (parts[3].startsWith("REGMP"))
    {
        REGMP(activeChar, petbuff);
    }
   [color=Red] for (int key = 0; key < this.allskillid_1.length; key++)[/color]
    {

        int skilllevel = SkillTable.getInstance().getMaxLevel(this.allskillid_1[key][0]);
        L2Skill skill = SkillTable.getInstance().getInfo(this.allskillid_1[key][0], skilllevel);
        if (parts[3].startsWith(skill.getName()))
        SKILL(activeChar, petbuff, key, skill);
    
    }
    }
  }

  private void FIGHERLIST(L2PcInstance activeChar, boolean petbuff)
  {
   [COLOR="red"] int[][] arr$ = this.allskillid_1;
    int len$ = arr$.length;[/COLOR]
    for (int i$ = 0; i$ < len$; i$++)
    {
      int[] aSkillid = arr$[i$];
      if ((aSkillid[1] == 1) || (aSkillid[1] == 3))
      {
        if (Config.MANI_BUFF)
        {
          if (activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
          {
            int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if (!petbuff)
              skill.getEffects(activeChar, activeChar);
            else
              skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
          }
          else
          {
            activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
          }
        }
        else {
          int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
          L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
          if (!petbuff)
            skill.getEffects(activeChar, activeChar);
          else
            skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
        }
      }
    }
  }

  private void DANCEFIGHTERLIST(L2PcInstance activeChar, boolean petbuff) {
    [COLOR="red"]int[][] arr$ = this.allskillid_1;
    int len$ = arr$.length;[/COLOR]
    for (int i$ = 0; i$ < len$; i$++)
    {
      int[] aSkillid = arr$[i$];
      if ((aSkillid[1] == 4) || (aSkillid[1] == 6))
      {
        if (Config.MANI_BUFF)
        {
          if (activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
          {
            int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if (!petbuff)
              skill.getEffects(activeChar, activeChar);
            else
              skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
          }
          else
          {
            activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
          }
        }
        else {
          int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
          L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
          if (!petbuff)
            skill.getEffects(activeChar, activeChar);
          else
            skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
        }
      }
    }
  }

  private void MAGELIST(L2PcInstance activeChar, boolean petbuff) {
    int[][] arr$ = this.allskillid_1;
    int len$ = arr$.length;
    for (int i$ = 0; i$ < len$; i$++)
    {
      int[] aSkillid = arr$[i$];
      if ((aSkillid[1] == 2) || (aSkillid[1] == 3))
      {
        if (Config.MANI_BUFF)
        {
          if (activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
          {
            int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if (!petbuff)
              skill.getEffects(activeChar, activeChar);
            else
              skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
          }
          else
          {
            activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
          }
        }
        else {
          int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
          L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
          if (!petbuff)
            skill.getEffects(activeChar, activeChar);
          else
            skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
        }
      }
    }
  }

  private void DANCEMAGELIST(L2PcInstance activeChar, boolean petbuff) {
    int[][] arr$ = this.allskillid_1;
    int len$ = arr$.length;
    for (int i$ = 0; i$ < len$; i$++)
    {
      int[] aSkillid = arr$[i$];
      if ((aSkillid[1] == 5) || (aSkillid[1] == 6))
      {
        if (Config.MANI_BUFF)
        {
          if (activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
          {
            int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if (!petbuff)
              skill.getEffects(activeChar, activeChar);
            else
              skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
          }
          else
          {
            activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
          }
        }
        else {
          int skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
          L2Skill skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
          if (!petbuff)
            skill.getEffects(activeChar, activeChar);
          else
            skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
        }
      }
    }
  }

  private void BUFF(L2PcInstance activeChar, boolean petbuff)
  {
    try (Connection con = L2DatabaseFactory.getInstance().getConnection();
    Statement s = con.createStatement();
    ResultSet rcln = s.executeQuery("SELECT * FROM community_skillsave WHERE charId=?;");
    PreparedStatement statement = con.prepareStatement("SELECT * FROM community_skillsave WHERE charId=?;"))    
    {      
      statement.setInt(1, activeChar.getObjectId());
      
      rcln.next();
      if (!petbuff)
      {
        char[] allskills = rcln.getString(2).toCharArray();
        if (allskills.length == this.allskillid_1.length)
        {
          for (int i = 0; i < this.allskillid_1.length; i++) {
            if (allskills[i] == '1')
              if (Config.MANI_BUFF)
              {
                if (activeChar.destroyItemByItemId(null, this.allskillid_1[i][3], this.allskillid_1[i][2], activeChar, true))
                {
                  int skilllevel = SkillTable.getInstance().getMaxLevel(this.allskillid_1[i][0]);
                  L2Skill skill = SkillTable.getInstance().getInfo(this.allskillid_1[i][0], skilllevel);
                  skill.getEffects(activeChar, activeChar);
                  activeChar.getLevel();
                }
                else
                {
                  activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
                }
              }
              else
              {
                int skilllevel = SkillTable.getInstance().getMaxLevel(this.allskillid_1[i][0]);
                L2Skill skill = SkillTable.getInstance().getInfo(this.allskillid_1[i][0], skilllevel);
                skill.getEffects(activeChar, activeChar);
              }
          }
        }
      }
      else
      {
        char[] petskills = rcln.getString(3).toCharArray();
        if (petskills.length == this.allskillid_1.length)
        {
          for (int i = 0; i < this.allskillid_1.length; i++)
          {
            if (petskills[i] == '1')
            {
              if (Config.MANI_BUFF)
              {
                if (activeChar.destroyItemByItemId(null, this.allskillid_1[i][3], this.allskillid_1[i][2], activeChar, true))
                {
                  int skilllevel = SkillTable.getInstance().getMaxLevel(this.allskillid_1[i][0]);
                  L2Skill skill = SkillTable.getInstance().getInfo(this.allskillid_1[i][0], skilllevel);
                  skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
                }
                else
                {
                  activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
                }
              }
              else
              {
                int skilllevel = SkillTable.getInstance().getMaxLevel(this.allskillid_1[i][0]);
                L2Skill skill = SkillTable.getInstance().getInfo(this.allskillid_1[i][0], skilllevel);
                skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
              }
            }
          }
        }
      }
      rcln.close();
    }
    catch (Exception ignored)
    {
      
    }

  }

  private void CANCEL(L2PcInstance activeChar, boolean petbuff)
  {
    if (!petbuff)
      activeChar.stopAllEffects();
    else
      activeChar.getSummon().stopAllEffects();
  }

  private void REGMP(L2PcInstance activeChar, boolean petbuff)
  {
    if (!petbuff)
      activeChar.setCurrentMp(activeChar.getMaxMp());
    else
      activeChar.getSummon().setCurrentMp(activeChar.getSummon().getMaxMp());
  }

  private void SKILL(L2PcInstance activeChar, boolean petbuff, int key, L2Skill skill)
  {
    if (Config.MANI_BUFF)
    {
      if (activeChar.destroyItemByItemId(null, this.allskillid_1[key][3], this.allskillid_1[key][2], activeChar, true))
      {
        if (!petbuff) {
          skill.getEffects(activeChar, activeChar);
        }
        else {
          skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
        }
      }
      else {
        activeChar.sendPacket(new ExShowScreenMessage("К сожалению у Вас недостаточно Аден!", 3000));
      }

    }
    else if (!petbuff)
      skill.getEffects(activeChar, activeChar);
    else
      skill.getEffects(activeChar.getSummon(), activeChar.getSummon());
  }

  private void SAVE(L2PcInstance activeChar, boolean petbuff)
  {
    try (Connection con = L2DatabaseFactory.getInstance().getConnection();
    Statement s = con.createStatement();
    ResultSet rset = s.executeQuery("SELECT COUNT(*) FROM community_skillsave WHERE charId=?;");
    PreparedStatement stat = con.prepareStatement("SELECT COUNT(*) FROM community_skillsave WHERE charId=?;"))    
    {
      stat.setInt(1, activeChar.getObjectId());
      rset.next();
      String allbuff = "";
      if (!petbuff)
      {
        L2Effect[] skill = activeChar.getAllEffects1();
        boolean flag = true;
        int[][] arr$ = this.allskillid_1;
        int len$ = arr$.length;
        for (int i$ = 0; i$ < len$; i$++)
        {
          int[] aSkillid = arr$[i$];
          for (int j = 0; j < skill.length; j++)
          {
            if (aSkillid[0] == skill[j].getId())
            {
              allbuff = allbuff + 1;
              flag = false;
            }
            if ((j == skill.length - 1) && (flag))
              allbuff = allbuff + 0;
          }
          flag = true;
        }
        if (rset.getInt(1) == 0)
        {
          PreparedStatement statement1 = con.prepareStatement("INSERT INTO community_skillsave (charId,skills) values (?,?)");
          statement1.setInt(1, activeChar.getObjectId());
          statement1.setString(2, allbuff);
          statement1.execute();
          statement1.close();
        }
        else
        {
          PreparedStatement statement = con.prepareStatement("UPDATE community_skillsave SET skills=? WHERE charId=?;");
          statement.setString(1, allbuff);
          statement.setInt(2, activeChar.getObjectId());
          statement.execute();
          statement.close();
        }
      }
      else
      {
        L2Effect[] skill = activeChar.getSummon().getAllEffects1();
        boolean flag = true;
        int[][] arr$ = this.allskillid_1;
        int len$ = arr$.length;
        for (int i$ = 0; i$ < len$; i$++)
        {
          int[] aSkillid = arr$[i$];
          for (int j = 0; j < skill.length; j++)
          {
            if (aSkillid[0] == skill[j].getId())
            {
              allbuff = allbuff + 1;
              flag = false;
            }
            if ((j == skill.length - 1) && (flag))
              allbuff = allbuff + 0;
          }
          flag = true;
        }
        if (rset.getInt(1) == 0)
        {
          PreparedStatement statement1 = con.prepareStatement("INSERT INTO community_skillsave (charId,pet) values (?,?)");
          statement1.setInt(1, activeChar.getObjectId());
          statement1.setString(2, allbuff);
          statement1.execute();
          statement1.close();
        }
        else
        {
          PreparedStatement statement = con.prepareStatement("UPDATE community_skillsave SET pet=? WHERE charId=?;");
          statement.setString(1, allbuff);
          statement.setInt(2, activeChar.getObjectId());
          statement.execute();
          statement.close();
        }
      }
      rset.close();
      stat.close();
    }
    catch (Exception ignored)
    {

    }

  }

  public void parsewrite(String s, String s1, String s2, String s3, String s4, L2PcInstance l2pcinstance)
  {
  }
}

теперь оно ругается на выделенные строки, не подскажите в чем проблема?
Ответ
#12
"Открываю посмотреть, что не так, а у них там в коде - надристано!" ©
Ответ
#13
xArhangelSx, вам есть еще куда стремится, путь не близок
Ответ
#14
KID Написал:xArhangelSx, вам есть еще куда стремится, путь не близок
а я где-то писал что я силен в java? что мне стремится много еще это я и так знаю

Добавлено через 21 минуту
уже не надо
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Проблемы с заливкой таблиц в бд l2jserver HF dbinst_gs a6y 3 1,901 10-08-2017, 11:01 PM
Последний пост: a6y
  проблема с npc сборка l2jserver HF p5 rufus666999 1 1,106 02-03-2016, 06:31 PM
Последний пост: rufus666999
  L2JServer High Five Ljucifer 4 3,528 05-10-2015, 11:31 AM
Последний пост: Donatte
  L2jServer Компиляция AirRebbit 6 2,039 09-21-2014, 09:04 AM
Последний пост: DRIAD
  Баффер kaloy 0 1,197 06-24-2014, 02:51 PM
Последний пост: kaloy
  Гмшоп и баффер для l2jFrozen AndruliKxD 0 1,075 03-14-2014, 10:29 PM
Последний пост: AndruliKxD
  L2jServer Gracia (CT2) 5970 не могу настроить клиент kalexi 12 11,630 02-25-2014, 01:27 PM
Последний пост: Jocker
  Пет Баффер Xuk 0 877 10-24-2013, 05:10 PM
Последний пост: Xuk
  Где находятся скрипты РБ в l2jserver Сантехник 8 2,676 08-14-2013, 02:19 PM
Последний пост: Scream
  компиляция l2jserver Skilz 0 1,258 07-28-2013, 02:34 PM
Последний пост: Skilz

Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)