Fix for pomanders on profession cancel.
This commit is contained in:
@@ -23,8 +23,11 @@ import com.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
|
||||
import com.l2jmobius.gameserver.model.L2SkillLearn;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
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.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
@@ -51,6 +54,7 @@ public final class SkillTransfer extends AbstractNpcAI
|
||||
{
|
||||
super(SkillTransfer.class.getSimpleName(), "features");
|
||||
setPlayerProfessionChangeId(this::onProfessionChange);
|
||||
setPlayerProfessionCancelId(this::onProfessionCancel);
|
||||
setOnEnterWorld(Config.SKILL_CHECK_ENABLE);
|
||||
}
|
||||
|
||||
@@ -71,6 +75,29 @@ public final class SkillTransfer extends AbstractNpcAI
|
||||
}
|
||||
}
|
||||
|
||||
public void onProfessionCancel(OnPlayerProfessionCancel event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final int index = getTransferClassIndex(player);
|
||||
|
||||
// is a transfer class
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int pomanderId = PORMANDERS[index].getId();
|
||||
// remove unsused HolyPomander
|
||||
PcInventory inv = player.getInventory();
|
||||
for (L2ItemInstance itemI : inv.getAllItemsByItemId(pomanderId))
|
||||
{
|
||||
inv.destroyItem("[HolyPomander - remove]", itemI, player, null);
|
||||
}
|
||||
// remove holy pomander variable
|
||||
final String name = HOLY_POMANDER + event.getClassId();
|
||||
player.getVariables().remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onEnterWorld(L2PcInstance player)
|
||||
{
|
||||
@@ -107,6 +134,11 @@ public final class SkillTransfer extends AbstractNpcAI
|
||||
}
|
||||
}
|
||||
}
|
||||
// SkillTransfer or HolyPomander missing
|
||||
if (count > 0)
|
||||
{
|
||||
player.getInventory().addItem("[HolyPomander - missing]", PORMANDERS[index].getId(), count, player, null);
|
||||
}
|
||||
}
|
||||
return super.onEnterWorld(player);
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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---------------------------------
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
|
@@ -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),
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user