diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/ai/others/SecondClassChange.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/ai/others/SecondClassChange.java new file mode 100644 index 0000000000..6e23ea822b --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/ai/others/SecondClassChange.java @@ -0,0 +1,91 @@ +/* + * This file is part of the L2J Mobius project. + * + * 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 . + */ +package ai.others; + +import org.l2jmobius.Config; +import org.l2jmobius.gameserver.data.xml.impl.CategoryData; +import org.l2jmobius.gameserver.enums.CategoryType; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.ListenerRegisterType; +import org.l2jmobius.gameserver.model.events.annotations.RegisterEvent; +import org.l2jmobius.gameserver.model.events.annotations.RegisterType; +import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerLevelChanged; +import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerLogin; +import org.l2jmobius.gameserver.network.serverpackets.classchange.ExRequestClassChangeUi; + +import ai.AbstractNpcAI; + +/** + * Second class change has only level requirement. + * @author Mobius + */ +public class SecondClassChange extends AbstractNpcAI +{ + private static final int LEVEL_REQUIREMENT = 40; + + @RegisterEvent(EventType.ON_PLAYER_LEVEL_CHANGED) + @RegisterType(ListenerRegisterType.GLOBAL_PLAYERS) + public void OnPlayerLevelChanged(OnPlayerLevelChanged event) + { + if (Config.DISABLE_TUTORIAL) + { + return; + } + + final PlayerInstance player = event.getPlayer(); + if (player == null) + { + return; + } + + if ((player.getLevel() < LEVEL_REQUIREMENT) || !CategoryData.getInstance().isInCategory(CategoryType.SECOND_CLASS_GROUP, player.getClassId().getId())) + { + return; + } + + player.sendPacket(ExRequestClassChangeUi.STATIC_PACKET); + } + + @RegisterEvent(EventType.ON_PLAYER_LOGIN) + @RegisterType(ListenerRegisterType.GLOBAL_PLAYERS) + public void OnPlayerLogin(OnPlayerLogin event) + { + if (Config.DISABLE_TUTORIAL) + { + return; + } + + final PlayerInstance player = event.getPlayer(); + if (player == null) + { + return; + } + + if ((player.getLevel() < LEVEL_REQUIREMENT) || !CategoryData.getInstance().isInCategory(CategoryType.SECOND_CLASS_GROUP, player.getClassId().getId())) + { + return; + } + + player.sendPacket(ExRequestClassChangeUi.STATIC_PACKET); + } + + public static void main(String[] args) + { + new SecondClassChange(); + } +}