Minor quest related improvements.

This commit is contained in:
MobiusDevelopment 2019-08-24 09:35:13 +00:00
parent 79d7a6c199
commit fc9a2c6644
4 changed files with 13 additions and 145 deletions

View File

@ -73,10 +73,7 @@ public class Quest extends ManagedScript
private final String _prefixPath; // used only for admin_quest_reload
private final String _descr;
private final byte _initialState = State.CREATED;
// NOTE: questItemIds will be overriden by child classes. Ideally, it should be protected instead of public.
// However, quest scripts written in Jython will have trouble with protected, as Jython only knows private and public...
// In fact, protected will typically be considered private thus breaking the scripts. Leave this as public as a workaround.
public int[] questItemIds = null;
protected int[] questItemIds = null;
// Dimensional Diamond Rewards by Class for 2nd class transfer quest (35)
protected static final Map<Integer, Integer> DF_REWARD_35 = new HashMap<>();

View File

@ -32,19 +32,8 @@ import org.l2jmobius.gameserver.model.spawn.Spawn;
public class QuestSpawn
{
private final Logger LOGGER = Quest.LOGGER;
private static QuestSpawn instance;
public static QuestSpawn getInstance()
{
if (instance == null)
{
instance = new QuestSpawn();
}
return instance;
}
public class DeSpawnScheduleTimerTask implements Runnable
private class DeSpawnScheduleTimerTask implements Runnable
{
NpcInstance _npc = null;
@ -149,4 +138,14 @@ public class QuestSpawn
return null;
}
public static QuestSpawn getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final QuestSpawn INSTANCE = new QuestSpawn();
}
}

View File

@ -1,128 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.model.quest;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
public class QuestStateManager
{
public class ScheduleTimerTask implements Runnable
{
@Override
public void run()
{
try
{
cleanUp();
ThreadPool.schedule(new ScheduleTimerTask(), 60000);
}
catch (Throwable t)
{
}
}
}
private List<QuestState> _questStates = new ArrayList<>();
public QuestStateManager()
{
ThreadPool.schedule(new ScheduleTimerTask(), 60000);
}
/**
* Add QuestState for the specified player instance
* @param quest
* @param player
* @param state
*/
public void addQuestState(Quest quest, PlayerInstance player, byte state)
{
QuestState qs = getQuestState(player);
if (qs == null)
{
qs = new QuestState(quest, player, state);
}
}
/**
* Remove all QuestState for all player instance that does not exist
*/
public void cleanUp()
{
for (int i = getQuestStates().size() - 1; i >= 0; i--)
{
if (getQuestStates().get(i).getPlayer() == null)
{
removeQuestState(getQuestStates().get(i));
getQuestStates().remove(i);
}
}
}
/**
* Remove QuestState instance
* @param qs
*/
private void removeQuestState(QuestState qs)
{
qs = null;
}
/**
* Return QuestState for specified player instance
* @param player
* @return
*/
public QuestState getQuestState(PlayerInstance player)
{
for (int i = 0; i < getQuestStates().size(); i++)
{
if ((getQuestStates().get(i).getPlayer() != null) && (getQuestStates().get(i).getPlayer().getObjectId() == player.getObjectId()))
{
return getQuestStates().get(i);
}
}
return null;
}
/**
* Return all QuestState
* @return
*/
public List<QuestState> getQuestStates()
{
if (_questStates == null)
{
_questStates = new ArrayList<>();
}
return _questStates;
}
public static QuestStateManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final QuestStateManager INSTANCE = new QuestStateManager();
}
}

View File

@ -17,7 +17,7 @@
package org.l2jmobius.gameserver.model.quest;
/**
* @author Luis Arias Functions in this class are used in python files
* @author Luis Arias
*/
public class State
{