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

@ -202,6 +202,7 @@ import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerKarma
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.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;
@ -10066,6 +10067,11 @@ public final class L2PcInstance extends L2Playable
getSubClasses().remove(classIndex);
return false;
}
// Notify to scripts
int classId = getSubClasses().get(classIndex).getClassId();
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this);
getSubClasses().remove(classIndex);
}
finally

View File

@ -89,6 +89,7 @@ import com.l2jmobius.gameserver.model.events.impl.character.npc.attackable.OnAtt
import com.l2jmobius.gameserver.model.events.impl.character.npc.attackable.OnAttackableKill;
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.OnPlayerSummonSpawn;
@ -1229,6 +1230,16 @@ public abstract class AbstractScript extends ManagedScript
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);
}
// --------------------------------------------------------------------------------------------------
// --------------------------------Default listener register methods---------------------------------
// --------------------------------------------------------------------------------------------------

View File

@ -61,6 +61,7 @@ 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.OnPlayerMoveRequest;
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;
@ -205,6 +206,7 @@ public enum EventType
ON_PLAYER_PK_CHANGED(OnPlayerPKChanged.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_PVP_CHANGED(OnPlayerPvPChanged.class, void.class),
ON_PLAYER_PVP_KILL(OnPlayerPvPKill.class, void.class),
ON_PLAYER_RESTORE(OnPlayerRestore.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;
}
}