Jump to content
  • 0

I Need Help To Fix This Java Code. L2Jserver Hi5 Stable(Trunk).


Question

Posted (edited)

I have this community board class master code, I tried to adapt it to my L2j Server and for some reason it doesn't work. I tried many different things to fix it and make it work but nothing. I got it to show the html on the community board but all it does is tell players that their class and witch level they can change classes. It is supposed to show buttons with the class available to then  when they reach the proper level to change class.

Can anyone take a look on it and see if you can help me fix it. I appreciate if anyone help.

Thank you.

 

Obs: No errors on Eclipse.

/*
 * 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.util.StringTokenizer;

import javolution.text.TextBuilder;

import com.l2jserver.Config;
import com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.items.L2Item;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;

public class ClassBBSManager extends BaseBBSManager
{
    private static ClassBBSManager _Instance = null;
    
    public static ClassBBSManager getInstance()
    {
        if (_Instance == null)
        {
            _Instance = new ClassBBSManager();
        }
        return _Instance;
    }
    
    @Override
    public void parsecmd(String command, L2PcInstance activeChar)
    {
        ClassId classId = activeChar.getClassId();
        int jobLevel = classId.level();
        int level = activeChar.getLevel();
        TextBuilder html = new TextBuilder("");
        html.append("<br>");
        html.append("<center>");
        if (Config.ALLOW_CLASS_MASTERS_LISTCB.isEmpty() || !Config.ALLOW_CLASS_MASTERS_LISTCB.contains(jobLevel))
        {
            jobLevel = 3;
        }
        if ((((level >= 20) && (jobLevel == 0)) || ((level >= 40) && (jobLevel == 1)) || ((level >= 76) && (jobLevel == 2))) && Config.ALLOW_CLASS_MASTERS_LISTCB.contains(jobLevel))
        {
            L2Item item = ItemTable.getInstance().getTemplate(Config.CLASS_MASTERS_PRICE_ITEMCB);
            html.append("Price for class is: <font color=\"LEVEL\">");
            html.append(Util.formatAdena(Config.CLASS_MASTERS_PRICE_LISTCB[jobLevel])).append("</font> <font color=\"LEVEL\">").append(item.getName()).append("</font> Really want one click class?<br>");
            for (ClassId cid : ClassId.values())
            {
                if (cid == ClassId.inspector)
                {
                    continue;
                }
                if (cid.childOf(classId) && (cid.level() == (classId.level() + 1)))
                {
                    html.append("<br><center><button value=\"").append(cid.name()).append("\" action=\"bypass -h _bbsclass;change_class;").append(cid.getId()).append(";").append(Config.CLASS_MASTERS_PRICE_LISTCB[jobLevel]).append("\" width=250 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
                }
            }
            html.append("</center>");
        }
        else
        {
            switch (jobLevel)
            {
                case 0:
                    html.append("Greetings " + activeChar.getName() + "! Your current class is <font color=F2C202>" + activeChar.getClassId().name() + "</font>.<br>");
                    html.append("Class level at: <font color=F2C202>20 level.</font><br>");
                    html.append("Class level at: <font color=F2C202>40 level.</font><br>");
                    html.append("Class level at:  <font color=F2C202>76 level.</font><br>");
                    break;
                case 1:
                    html.append("Congratulation " + activeChar.getName() + "! you are <font color=F2C202>" + activeChar.getClassId().name() + "</font>now.<br>");
                    break;
                case 2:
                    html.append("Greetings " + activeChar.getName() + "! Your current class is <font color=F2C202>" + activeChar.getClassId().name() + "</font>.<br>");
                    html.append("Class level at: <font color=F2C202>20 level.</font><br>");
                    html.append("Class level at:<font color=F2C202>40 level.</font><br>");
                    html.append("Class level at: <font color=F2C202>76 level.</font><br>");
                    break;
                case 3:
                    html.append("Greetings " + activeChar.getName() + "! Your current class is <font color=F2C202>" + activeChar.getClassId().name() + "</font>.<br>");
                    html.append("Congratulation !.<br>");
                    if (level >= 76)
                    {
                        html.append("Your level is over <font color=F2C202>76</font>! There is no more classes available to you.<br>");
                    }
                    break;
            }
        }
        NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
        adminReply.setFile(activeChar.getLang(), "data/html/CommunityBoard/5.htm");
        adminReply.replace("%classmaster%", html.toString());
        separateAndSend(adminReply.getHtm(), activeChar);
        
        if (command.startsWith("_bbsclass;change_class;"))
        {
            StringTokenizer st = new StringTokenizer(command, ";");
            st.nextToken();
            st.nextToken();
            short val = Short.parseShort(st.nextToken());
            int price = Integer.parseInt(st.nextToken());
            L2Item item = ItemTable.getInstance().getTemplate(Config.CLASS_MASTERS_PRICE_ITEMCB);
            L2ItemInstance pay = activeChar.getInventory().getItemByItemId(item.getItemId());
            if ((pay != null) && (pay.getCount() >= price))
            {
                activeChar.destroyItem("ClassMaster", pay, price, activeChar, true);
                changeClass(activeChar, val);
                parsecmd("_bbsclass;", activeChar);
            }
            else if (Config.CLASS_MASTERS_PRICE_ITEMCB == 57)
            {
                activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
            }
            else
            {
                activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
            }
        }
    }
    
    private void changeClass(L2PcInstance activeChar, short val)
    {
        if (activeChar.getClassId().level() == ClassId.values()[val].level())
        {
            return;
        }
        
        if (activeChar.getClassId().level() == 3)
        {
            activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIRD_CLASS_TRANSFER));
        }
        else
        {
            activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLASS_TRANSFER));
        }
        activeChar.setClassId(val);
        
        if (activeChar.getClassId().level() == 2)
        {
            activeChar.getInventory().addItem("bbsClassManager", 6622, 1L, activeChar, null);
        }
        
        if (activeChar.isSubClassActive())
        {
            activeChar.getSubClasses().get(Integer.valueOf(activeChar.getClassIndex())).setClassId(activeChar.getActiveClass());
        }
        else
        {
            if (activeChar.getClassId().level() == 0)
            {
                activeChar.getInventory().addItem("bbsClassManager", 8869, 15L, activeChar, null);
            }
            else if (activeChar.getClassId().level() == 1)
            {
                activeChar.getInventory().addItem("bbsClassManager", 8870, 15L, activeChar, null);
            }
            
            activeChar.setBaseClass(activeChar.getActiveClass());
        }
        
        if (activeChar.getClassId().getId() == 97)
        {
            activeChar.getInventory().addItem("bbsClassManager", 15307, 1L, activeChar, null);
        }
        else if (activeChar.getClassId().getId() == 105)
        {
            activeChar.getInventory().addItem("bbsClassManager", 15308, 1L, activeChar, null);
        }
        else if (activeChar.getClassId().getId() == 112)
        {
            activeChar.getInventory().addItem("bbsClassManager", 15309, 4L, activeChar, null);
        }
        
        activeChar.broadcastUserInfo();
    }
    
    @Override
    public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
    {
    }
}

<html>
	<body><br>
			<center>
			
			<center><table>
				<tr>
					<td  width="500" align="center" border="0" cellpadding="0" cellspacing="0" ><center>%classmaster%</center></td>
				</tr>
			</table><br><br><br><br>
			
			
					
	</body>
</html>
Edited by disorder25

3 answers to this question

Recommended Posts

  • 0
Posted

Are you sure that condition is reached ?

 

ALLOW_CLASS_MASTERS_LISTCB must contain allowed classes.

if ((((level >= 20) && (jobLevel == 0)) || ((level >= 40) && (jobLevel == 1)) || ((level >= 76) && (jobLevel == 2))) && Config.ALLOW_CLASS_MASTERS_LISTCB.contains(jobLevel))
Guest
This topic is now closed to further replies.


  • Posts

    • POLAND — New VPS Location Our new VPS location in Poland is now available. Promo code: POLAND • 40% off new VPS orders in the Poland location • Offer valid until July 29, 2026 Enter the promo code POLAND during checkout to receive your discount.
    • In your place l will join to Mobius community to get something decent or just go to Lucera 2 ( ofc no source) if you want interlude on Classic client, coz Acis not have have it yet.
    • The client and the system aren't working very well; the screen is black, and some things aren't loading.  😞 
    • LINEAGE2.SK Summer Season is Comming! GRAND OPENING - 14.08.2026 at 20:00 GMT+1  OBT - 07.08.2025 at 20:00 GMT+1   Website :https://lineage2.sk Discord : https://discord.gg/gj7AC5juGP       Server Features and Rates Xp – 20x Sp – 20x Adena – 10x Drop – 15x Spoil - 15x  Epic Raid Boss  - 1x Regular RB - 5x  Quest - 5x Fame - 2x Epaulette - 15x Manor - 15x     Special Features Somik Interface Limited AutoFarm Vote System Champions System Achievement System And more in information below     Enchant Settings  Safe Enchant: +3  Max Enchant: +16 Enchant Chance: 63%  Attribute Stone Chance: 50%  Attribute Crystal Chance: 30%     NPC Buffer all buffs, songs, dances including 3rd prof + resists Buff Slots: 24 (+4) / 12 Buff Duration: 2 Hours     Epic Bosses & Respawns Queen Ant: 24 hours +/-8h Core: 3 days +/-8h Orfen: 2 days +/-8h Baium: 5 days +/-8h Beleth: 7 days +/-8h Antharas: 7 days +/-8h Valakas: 7 days +/-8h     Instances Zones Zaken: 6 players Normal Freya: 6 players Hard Freya: 12 Players Frintezza: 6 Players Tiat: 6 Players Beleth: 12 Players     GM Shop weapon/armor/jwl (max S grade) shots/spiritshots (max S grade) mana potions (1000 MP, 10s)      Global Gatekeeper all towns including cata/necro ToI Gracia Hellbound ...     Olympiad period 7 days (Monday) no class participants min 6 base class participants min 6 max enchant +6 Start points 20     Class Transfer for Adena     Subclass Quest Not required Max Subclass 3 Subclass Max LvL 85     Events Team vs Team Capture the Flag Death Match Last Hero Korean Style Treasure Hunt      Clans All new clans start with Clan LvL 5! Clan Skills/LvL for Clan Coins     Others  max 3 windows per HWID  BoM/MoM spawned in towns Auto-learn skills Autoloot Retail LvL of Epic Bosses Cancellation return buff system (30sec) Cancellation return buff -  not effect olympiad
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..