Fix for pomanders on profession cancel.

This commit is contained in:
MobiusDev
2018-04-06 02:36:17 +00:00
parent b224d80373
commit 8fcb49c449
35 changed files with 728 additions and 24 deletions

View File

@ -204,6 +204,7 @@ import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogou
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMenteeStatus;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMentorStatus;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPKChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionCancel;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionChange;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPKill;
@ -9692,6 +9693,10 @@ public final class L2PcInstance extends L2Playable
_log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e);
return false;
}
// Notify to scripts
int classId = getSubClasses().get(classIndex).getClassId();
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this);
}
finally
{

View File

@ -97,6 +97,7 @@ import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcSpawn;
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcTeleport;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionCancel;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionChange;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSkillLearn;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSummonAgathion;
@ -1377,6 +1378,16 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
return registerConsumer(callback, EventType.ON_PLAYER_PROFESSION_CHANGE, ListenerRegisterType.GLOBAL);
}
/**
* Provides instant callback operation when player's cancel profession
* @param callback
* @return
*/
protected final List<AbstractEventListener> setPlayerProfessionCancelId(Consumer<OnPlayerProfessionCancel> callback)
{
return registerConsumer(callback, EventType.ON_PLAYER_PROFESSION_CANCEL, ListenerRegisterType.GLOBAL);
}
/**
* Provides instant callback operation when instance world created
* @param callback

View File

@ -95,6 +95,7 @@ import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMento
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMoveRequest;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPKChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPressTutorialMark;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionCancel;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionChange;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPKill;
@ -256,6 +257,7 @@ public enum EventType
ON_PLAYER_PRESS_TUTORIAL_MARK(OnPlayerPressTutorialMark.class, void.class),
ON_PLAYER_MOVE_REQUEST(OnPlayerMoveRequest.class, void.class, TerminateReturn.class),
ON_PLAYER_PROFESSION_CHANGE(OnPlayerProfessionChange.class, void.class),
ON_PLAYER_PROFESSION_CANCEL(OnPlayerProfessionCancel.class, void.class),
ON_PLAYER_CHANGE_TO_AWAKENED_CLASS(OnPlayerChangeToAwakenedClass.class, void.class),
ON_PLAYER_PVP_CHANGED(OnPlayerPvPChanged.class, void.class),
ON_PLAYER_PVP_KILL(OnPlayerPvPKill.class, void.class),

View File

@ -0,0 +1,53 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.events.impl.character.player;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.impl.IBaseEvent;
/**
* @author Krunchy
* @since 2.6.0.0
*/
public class OnPlayerProfessionCancel implements IBaseEvent
{
private final L2PcInstance _activeChar;
private final int _classId;
public OnPlayerProfessionCancel(L2PcInstance activeChar, int classId)
{
_activeChar = activeChar;
_classId = classId;
}
public L2PcInstance getActiveChar()
{
return _activeChar;
}
public int getClassId()
{
return _classId;
}
@Override
public EventType getType()
{
return EventType.ON_PLAYER_PROFESSION_CANCEL;
}
}