Jump to content
  • 0

Question

Posted

Hi all

im trying to adapt a community buffer to h5

the problem is some class l2skill and skilltable doesnt exist

i tryied to change l2skill for skill, getinfo for getskill and skilltable for skilldata but still error i think it is more complicated than that

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://l2jpsproject.eu/>.
 */
package com.l2jserver.gameserver.communitybbs.Managers;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.L2Skill;

/**
 * @RobikBobik
 */
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()
	{
		
		Connection connn = null;
		try
		{
			connn = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement count = connn.prepareStatement("SELECT COUNT(*) FROM communitybuff");
			ResultSet countt = count.executeQuery();
			countt.next();
			allskillid_1 = new int[countt.getInt(1)][4];
			PreparedStatement table = connn.prepareStatement("SELECT * FROM communitybuff");
			ResultSet skills = table.executeQuery();
			for (int i = 0; i < allskillid_1.length; i++)
			{
				skills.next();
				allskillid_1[i][0] = skills.getInt(2);
				allskillid_1[i][1] = skills.getInt(3);
				allskillid_1[i][2] = skills.getInt(4);
				allskillid_1[i][3] = skills.getInt(5);
			}
			
			count.close();
			countt.close();
			skills.close();
			table.close();
			connn.close();
		}
		catch (Exception ignored)
		{
		}
	}
	
	@Override
	public void parsecmd(String command, L2PcInstance activeChar)
	{
		String[] parts = command.split("_");
		boolean petbuff = false;
		
		if (!(parts[2].startsWith("buff")))
		{
			return;
		}
		
		if ((parts[4] != null) && parts[4].startsWith(" Player"))
		{
			petbuff = false;
		}
		if ((parts[4] != null) && parts[4].startsWith(" Pet"))
		{
			petbuff = true;
		}
		
		if (parts[3].startsWith("FIGHERLIST"))
		{
			FIGHERLIST(activeChar, petbuff);
		}
		
		if (parts[3].startsWith("MAGELIST"))
		{
			MAGELIST(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);
		}
		
		if (parts[3].startsWith("REGHP"))
		{
			REGHP(activeChar, petbuff);
		}
		
		if (parts[3].startsWith("REGCP"))
		{
			REGCP(activeChar, petbuff);
		}
		
		for (int key = 0; key < allskillid_1.length; key++)
		{
			L2Skill skill;
			int skilllevel;
			
			skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[key][0]);
			skill = SkillTable.getInstance().getInfo(allskillid_1[key][0], skilllevel);
			if (parts[3].startsWith(skill.getName()))
			{
				SKILL(activeChar, petbuff, key, skill);
			}
		}
	}
	
	private void FIGHERLIST(L2PcInstance activeChar, boolean petbuff)
	{
		int arr$[][] = allskillid_1;
		int len$ = arr$.length;
		for (int i$ = 0; i$ < len$; i$++)
		{
			int aSkillid[] = arr$[i$];
			if ((aSkillid[1] != 1) && (aSkillid[1] != 3))
			{
				continue;
			}
			L2Skill skill;
			int skilllevel;
			if (Config.BUFF_COST)
			{
				if (activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
				{
					skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
					skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
					if (!petbuff)
					{
						skill.applyEffects(activeChar, activeChar);
					}
					else
					{
						skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
					}
				}
				else
				{
					activeChar.sendMessage("You don't have adena for using service.");
				}
				continue;
			}
			skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
			skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
			if (!petbuff)
			{
				skill.applyEffects(activeChar, activeChar);
			}
			else
			{
				skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
			}
		}
		
	}
	
	private void MAGELIST(L2PcInstance activeChar, boolean petbuff)
	{
		int arr$[][] = allskillid_1;
		int len$ = arr$.length;
		for (int i$ = 0; i$ < len$; i$++)
		{
			int aSkillid[] = arr$[i$];
			if ((aSkillid[1] != 2) && (aSkillid[1] != 3))
			{
				continue;
			}
			L2Skill skill;
			int skilllevel;
			if (Config.BUFF_COST)
			{
				if (activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
				{
					skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
					skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
					if (!petbuff)
					{
						skill.applyEffects(activeChar, activeChar);
					}
					else
					{
						skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
					}
				}
				else
				{
					activeChar.sendMessage("You don't have adena for using service.");
				}
				continue;
			}
			skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
			skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
			if (!petbuff)
			{
				skill.applyEffects(activeChar, activeChar);
			}
			else
			{
				skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
			}
		}
		
	}
	
	private void BUFF(L2PcInstance activeChar, boolean petbuff)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT * FROM community_skillsave WHERE charId=?;");
			statement.setInt(1, activeChar.getObjectId());
			ResultSet rcln = statement.executeQuery();
			rcln.next();
			if (!petbuff)
			{
				char allskills[] = rcln.getString(2).toCharArray();
				if (allskills.length == allskillid_1.length)
				{
					for (int i = 0; i < allskillid_1.length; i++)
					{
						if (allskills[i] == '1')
						{
							if (Config.BUFF_COST)
							{
								if (activeChar.destroyItemByItemId(null, allskillid_1[i][3], allskillid_1[i][2], activeChar, true))
								{
									int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
									L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
									skill.applyEffects(activeChar, activeChar);
									activeChar.getLevel();
								}
								else
								{
									activeChar.sendMessage("You don't have adena for using service.");
								}
							}
							else
							{
								int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
								L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
								skill.applyEffects(activeChar, activeChar);
							}
						}
					}
					
				}
			}
			else
			{
				char petskills[] = rcln.getString(3).toCharArray();
				if (petskills.length == allskillid_1.length)
				{
					for (int i = 0; i < allskillid_1.length; i++)
					{
						if (petskills[i] != '1')
						{
							continue;
						}
						if (Config.BUFF_COST)
						{
							if (activeChar.destroyItemByItemId(null, allskillid_1[i][3], allskillid_1[i][2], activeChar, true))
							{
								int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
								L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
								skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
							}
							else
							{
								activeChar.sendMessage("You don't have adena for using service.");
							}
						}
						else
						{
							int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
							L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
							skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
						}
					}
					
				}
			}
			rcln.close();
			statement.close();
		}
		catch (Exception ignored)
		{
			try
			{
				if (con != null)
				{
					con.close();
				}
			}
			catch (SQLException e)
			{
				e.printStackTrace();
			}
			
		}
		try
		{
			if (con != null)
			{
				con.close();
			}
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}
	}
	
	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 REGHP(L2PcInstance activeChar, boolean petbuff)
	{
		if (!petbuff)
		{
			activeChar.setCurrentHp(activeChar.getMaxHp());
		}
		else
		{
			activeChar.getSummon().setCurrentHp(activeChar.getSummon().getMaxHp());
		}
	}
	
	private void REGCP(L2PcInstance activeChar, boolean petbuff)
	{
		if (!petbuff)
		{
			activeChar.setCurrentCp(activeChar.getMaxCp());
		}
		else
		{
			activeChar.getSummon().setCurrentCp(activeChar.getSummon().getMaxCp());
		}
	}
	
	private void SKILL(L2PcInstance activeChar, boolean petbuff, int key, L2Skill skill)
	{
		if (Config.BUFF_COST)
		{
			if (activeChar.destroyItemByItemId(null, allskillid_1[key][3], allskillid_1[key][2], activeChar, true))
			{
				if (!petbuff)
				{
					skill.applyEffects(activeChar, activeChar);
				}
				else
				{
					skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
				}
			}
			else
			{
				activeChar.sendMessage("You don't have adena for using service.");
			}
		}
		else if (!petbuff)
		{
			skill.applyEffects(activeChar, activeChar);
		}
		else
		{
			skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
		}
	}
	
	/*
	 * private void SAVE(L2PcInstance activeChar, boolean petbuff) { Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement stat = con.prepareStatement("SELECT COUNT(*) FROM community_skillsave WHERE charId=?;"); stat.setInt(1,
	 * activeChar.getObjectId()); ResultSet rset = stat.executeQuery(); rset.next(); String allbuff = ""; if (!petbuff) { L2Effect skill[] = activeChar.getAllEffectsCB(); boolean flag = true; int arr$[][] = 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 = (new StringBuilder()).append(allbuff).append(1).toString(); flag = false; } if ((j == (skill.length - 1)) && flag) { allbuff = (new StringBuilder()).append(allbuff).append(0).toString(); } }
	 * 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().getAllEffectsCB(); boolean flag = true; int arr$[][] = 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 = (new
	 * StringBuilder()).append(allbuff).append(1).toString(); flag = false; } if ((j == (skill.length - 1)) && flag) { allbuff = (new StringBuilder()).append(allbuff).append(0).toString(); } } 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) { try { if (con != null) {
	 * con.close(); } } catch (SQLException e) { e.printStackTrace(); } } try { if (con != null) { con.close(); } } catch (SQLException e) { e.printStackTrace(); } }
	 */
	@Override
	public void parsewrite(String s, String s1, String s2, String s3, String s4, L2PcInstance l2pcinstance)
	{
	}
}

Thank You For Your Help

5 answers to this question

Recommended Posts

  • 0
Posted
		catch (Exception ignored)
		{
			try
			{
				if (con != null)
				{
					con.close();
				}
			}
			catch (SQLException e)
			{
				e.printStackTrace();
			}
			
		}
		try
		{
			if (con != null)
			{
				con.close();
			}
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}

Masterpiece! :troll:

  • 0
Posted (edited)
	private void REGMP(L2PcInstance activeChar, boolean petbuff)
	{
		if (!petbuff)
		{
			activeChar.setCurrentMp(activeChar.getMaxMp());
		}
		else
		{
			activeChar.getSummon().setCurrentMp(activeChar.getSummon().getMaxMp());
		}
	}
	
	private void REGHP(L2PcInstance activeChar, boolean petbuff)
	{
		if (!petbuff)
		{
			activeChar.setCurrentHp(activeChar.getMaxHp());
		}
		else
		{
			activeChar.getSummon().setCurrentHp(activeChar.getSummon().getMaxHp());
		}
	}
	
	private void REGCP(L2PcInstance activeChar, boolean petbuff)
	{
		if (!petbuff)
		{
			activeChar.setCurrentCp(activeChar.getMaxCp());
		}
		else
		{
			activeChar.getSummon().setCurrentCp(activeChar.getSummon().getMaxCp());
		}
	}
	
	private void SKILL(L2PcInstance activeChar, boolean petbuff, int key, L2Skill skill)
	{
		if (Config.BUFF_COST)
		{
			if (activeChar.destroyItemByItemId(null, allskillid_1[key][3], allskillid_1[key][2], activeChar, true))
			{
				if (!petbuff)
				{
					skill.applyEffects(activeChar, activeChar);
				}
				else
				{
					skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
				}
			}
			else
			{
				activeChar.sendMessage("You don't have adena for using service.");
			}
		}
		else if (!petbuff)
		{
			skill.applyEffects(activeChar, activeChar);
		}
		else
		{
			skill.applyEffects(activeChar.getSummon(), activeChar.getSummon());
		}
	}
	

 

 

1432384939474.jpg

Edited by LightFusion

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • A New Chapter Begins We're Rebuilding – Join Our Staff Team After many years of activity, growth, and challenges, it’s finally time for our community to restructure and move forward. We’re ready to turn a new page and evolve into something greater — but we can’t do it without the help of passionate and committed people. That’s why we’re now opening up staff applications for those who want to actively shape the future of our community. If you have the motivation, time, and patience to contribute to something meaningful, this is your chance to step in and make a real impact. What We're Looking For We’re building a fresh and dedicated team of individuals who are ready to support and grow this project. Open roles include: Moderators – to keep the forum clean, safe, and organized Gaming Moderators – to help manage gaming boards (e.g., Lineage, GTA FiveM) Content Creators – to post updates, guides, and articles Community Managers – to engage users and drive activity Technical Staff – for development, backend, and server work We’re not focusing only on Lineage anymore. Our vision is expanding to new areas — including GTA FiveM and other multiplayer games you might have expertise in. If you have a good idea, a server plan, or something new to suggest — we’re open to it. Now’s the time to bring it forward. Requirements We’re looking for individuals who have: A history of activity on the forum (preferred) Available time to contribute consistently A sense of teamwork and responsibility A genuine interest in gaming and community building If you're interested, just send a private message to me or Celestine. (or just reply here) Tell us a few things about yourself and how you’d like to contribute. Let’s bring this community back to life. Let’s rebuild something great — together.   M M G A 
    • Lineage2Network - Interlude Reimagined   Embark on a revitalized journey through the classic Interlude era with Lineage2.Network. Our server is meticulously crafted by veteran players to deliver a seamless and engaging experience, blending the nostalgia of the Chaotic Chronicle with modern enhancements.     Server details   Chronicle: Interlude + Classic Rates: EXP x30 | Adena x10 | Drop x10 | Spoil x10     Server features   Daily Missions - complete special tasks for daily rewards Attendance Rewards - get rewards for online time Custom Events - TVT, DM, CTF NPC buffer duration - 2 hours   Mana Potions - restores 1000 MP, 10s cooldown Ring of Core additional stats: +1 STR Earring of Orfen additional stats: +1 INT Shadow Earring of Zaken - 7 days Shadow Ring of Queen Ant - 7 days   Max buff count - 24 (20 + 4 with Divine Inspiration) Noblesse, Heroic Valor, Flames of Invincibility and Celestial Shield don't take buff slot Reworked Cancel, Mage and Warrior Banes – removed buffs reappear after 30s Block Buffs - block all incoming buffs except from self/party Sweeper Festival added to Spoiler class   Subclass – retail or purchasable Noblesse – retail or purchasable up to Barakiel; collect 8 fragments for full staff 1st & 2nd class free, 3rd needs 700 Halisha Marks or is purchasable New Olympiad System: new stadiums with NPC buffer,  1 week period.     Key dates     Beta Launch: April 14, 2025 Official Launch: May 9, 2025     Check out full server details in our website And visit our discord   Join us and be part of community where classic gameplay meets innovative updates. Whether you're a solo adventurer or part of a formidable clan, Lineage2.Network offers a dynamic and balanced environment for all.  
  • Topics

×
×
  • Create New...