Остальное сами правьте под себя
package scripts.commands.voicedcommandhandlers;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.datatables.xml.CharTemplateData;
import net.sf.l2j.gameserver.model.base.ClassId;
import net.sf.l2j.gameserver.model.base.ClassLevel;
import net.sf.l2j.gameserver.model.base.PlayerClass;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
public class ClassMass implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS = { "classmaster","change_class"};
public boolean useVoicedCommand(String command, L2PcInstance player, String target)
{
if (command.equalsIgnoreCase("classmaster"))
{
ClassId classId = player.getClassId();
int jobLevel = 0;
int level = player.getLevel();
ClassLevel lvl = PlayerClass.values()[classId.getId()].getLevel();
switch (lvl)
{
case First:jobLevel = 1;break;
case Second:jobLevel = 2;break;
case Third:jobLevel = 3;break;
default:jobLevel = 4;
}
if (player.isGM()) showChatWindowChooseClass(player);
else if (((level >= 20 && jobLevel == 1) || (level >= 40 && jobLevel == 2)) && Config.ALLOW_CLASS_MASTER)
showChatWindow(player, classId.getId());
else if (level >= 76 && Config.ALLOW_CLASS_MASTER && classId.getId() < 88)
{
for (int i = 0; i < SECONDN_CLASS_IDS.length; i++)
{
if (classId.getId() == SECONDN_CLASS_IDS)
{
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
StringBuilder sb = new StringBuilder();
sb.append("<html><body<table width=200>");
sb.append("<tr><td><center>" + CharTemplateData.getInstance().getClassNameById(player.getClassId().getId()) + " Class Master:</center></td></tr>");
sb.append("<tr><td><br></td></tr>");
sb.append("<tr><td><a action=\"bypass -h npc_" + getObjectId() + "_change_class " + (88 + i) + "\">Advance to " + CharTemplateData.getInstance().getClassNameById(88 + i) + "</a></td></tr>");
sb.append("<tr><td><br></td></tr>");
sb.append("</table></body></html>");
html.setHtml(sb.toString());
player.sendPacket(html);
break;
}
}
}
else
{
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
StringBuilder sb = new StringBuilder();
sb.append("<html><body>");
switch (jobLevel)
{
case 1:
sb.append("Come back here when you reach level 20 to change your class.<br>");
break;
case 2:
sb.append("Come back here when you reach level 40 to change your class.<br>");
break;
case 3:
sb.append("There are no more class changes for you.<br>");
break;
}
for (Quest q : Quest.findAllEvents())
sb.append("Event: <a action=\"bypass -h Quest " + q.getName() + "\">" + q.getDescr() + "</a><br>");
sb.append("</body></html>");
html.setHtml(sb.toString());
player.sendPacket(html);
}
player.sendPacket(ActionFailed.STATIC_PACKET);
}
else if (command.startsWith("change_class"))
{
int val = Integer.parseInt(command.substring(13));
ClassId classId = player.getClassId();
int level = player.getLevel();
int jobLevel = 0;
int newJobLevel = 0;
ClassLevel lvlnow = PlayerClass.values()[classId.getId()].getLevel();
if (player.isGM())
{
changeClass(player, val);
player.rewardSkills();
if (val >= 88)
player.sendPacket(SystemMessageId.THIRD_CLASS_TRANSFER);
else
player.sendPacket(SystemMessageId.CLASS_TRANSFER);
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
StringBuilder sb = new StringBuilder();
sb.append("<html><body>");
sb.append("You have now become a <font color=\"LEVEL\">" + CharTemplateData.getInstance().getClassNameById(player.getClassId().getId()) + "</font>.");
sb.append("</body></html>");
html.setHtml(sb.toString());
player.sendPacket(html);
return;
}
switch (lvlnow)
{
case First:
jobLevel = 1;
break;
case Second:
jobLevel = 2;
break;
case Third:
jobLevel = 3;
break;
default:
jobLevel = 4;
}
if (jobLevel == 4)
return; // no more job changes
ClassLevel lvlnext = PlayerClass.values()[val].getLevel();
switch (lvlnext)
{
case First:
newJobLevel = 1;
break;
case Second:
newJobLevel = 2;
break;
case Third:
newJobLevel = 3;
break;
default:
newJobLevel = 4;
}
// prevents changing between same level jobs
if (newJobLevel != jobLevel + 1)
return;
if (level < 20 && newJobLevel > 1)
return;
if (level < 40 && newJobLevel > 2)
return;
if (level < 75 && newJobLevel > 3)
return;
changeClass(player, val);
player.rewardSkills();
if (val >= 88)
player.sendPacket(SystemMessageId.THIRD_CLASS_TRANSFER); // system sound 3rd occupation
else
player.sendPacket(SystemMessageId.CLASS_TRANSFER); // system sound for 1st and 2nd occupation
player.broadcastPacket(new MagicSkillUse(player, player, 5103, 1, 1000, 0));
HtmlShow(player);
checks(player);
checkAutoEq(player,newJobLevel);
}
return true;
}
private void changeClass(L2PcInstance player, int val)
{
final ClassId currentClassId = player.getClassId();
if (getMinLevel(currentClassId.level()) > player.getLevel())
return;
if (!validateClassId(currentClassId, val))
return;
player.setClassId(val);
if (player.isSubClassActive()){player.getSubClasses().get(player.getClassIndex()).setClassId(player.getActiveClass());}
else
{
ClassId classId = ClassId.getClassIdByOrdinal(player.getActiveClass());
if (classId.getParent() != null){while (classId.level() == 0){classId = classId.getParent();}}
player.setBaseClass(classId);
}
player.broadcastUserInfo();
}
public String[] getVoicedCommandList(){return VOICED_COMMANDS;}
}