actual freya branch
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.l2jserver.gameserver.model.quest;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
** @author JIV
|
||||
*/
|
||||
public abstract class Event extends Quest
|
||||
{
|
||||
/**
|
||||
* @param questId
|
||||
* @param name
|
||||
* @param descr
|
||||
*/
|
||||
public Event(int questId, String name, String descr)
|
||||
{
|
||||
super(questId, name, descr);
|
||||
}
|
||||
|
||||
public abstract boolean eventStart();
|
||||
|
||||
public abstract boolean eventStop();
|
||||
|
||||
public abstract boolean eventBypass(L2PcInstance activeChar, String bypass);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.l2jserver.gameserver.model.quest;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class QuestTimer
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(QuestTimer.class.getName());
|
||||
|
||||
// =========================================================
|
||||
// Schedule Task
|
||||
public class ScheduleTimerTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!getIsActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!getIsRepeating())
|
||||
{
|
||||
cancel();
|
||||
}
|
||||
getQuest().notifyEvent(getName(), getNpc(), getPlayer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// Data Field
|
||||
private boolean _isActive = true;
|
||||
private final String _name;
|
||||
private final Quest _quest;
|
||||
private final L2Npc _npc;
|
||||
private final L2PcInstance _player;
|
||||
private final boolean _isRepeating;
|
||||
private ScheduledFuture<?> _schedular;
|
||||
|
||||
// =========================================================
|
||||
// Constructor
|
||||
public QuestTimer(Quest quest, String name, long time, L2Npc npc, L2PcInstance player, boolean repeating)
|
||||
{
|
||||
_name = name;
|
||||
_quest = quest;
|
||||
_player = player;
|
||||
_npc = npc;
|
||||
_isRepeating = repeating;
|
||||
if (repeating)
|
||||
{
|
||||
_schedular = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ScheduleTimerTask(), time, time); // Prepare auto end task
|
||||
}
|
||||
else
|
||||
{
|
||||
_schedular = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleTimerTask(), time); // Prepare auto end task
|
||||
}
|
||||
}
|
||||
|
||||
public QuestTimer(Quest quest, String name, long time, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
this(quest, name, time, npc, player, false);
|
||||
}
|
||||
|
||||
public QuestTimer(QuestState qs, String name, long time)
|
||||
{
|
||||
this(qs.getQuest(), name, time, null, qs.getPlayer(), false);
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// Method - Public
|
||||
public void cancel()
|
||||
{
|
||||
_isActive = false;
|
||||
|
||||
if (_schedular != null)
|
||||
{
|
||||
_schedular.cancel(false);
|
||||
}
|
||||
|
||||
getQuest().removeQuestTimer(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* public method to compare if this timer matches with the key attributes passed.
|
||||
* @param quest : Quest instance to which the timer is attached
|
||||
* @param name : Name of the timer
|
||||
* @param npc : Npc instance attached to the desired timer (null if no npc attached)
|
||||
* @param player : Player instance attached to the desired timer (null if no player attached)
|
||||
*/
|
||||
public boolean isMatch(Quest quest, String name, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
if ((quest == null) || (name == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((quest != getQuest()) || (name.compareToIgnoreCase(getName()) != 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ((npc == getNpc()) && (player == getPlayer()));
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// Property - Public
|
||||
public final boolean getIsActive()
|
||||
{
|
||||
return _isActive;
|
||||
}
|
||||
|
||||
public final boolean getIsRepeating()
|
||||
{
|
||||
return _isRepeating;
|
||||
}
|
||||
|
||||
public final Quest getQuest()
|
||||
{
|
||||
return _quest;
|
||||
}
|
||||
|
||||
public final String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public final L2Npc getNpc()
|
||||
{
|
||||
return _npc;
|
||||
}
|
||||
|
||||
public final L2PcInstance getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.l2jserver.gameserver.model.quest;
|
||||
|
||||
/**
|
||||
* @author Luis Arias; version 2 by Fulminus This class merely enumerates the three necessary states for all quests: CREATED: a quest state is created but the quest is not yet accepted. STARTED: the player has accepted the quest. Quest is currently in progress COMPLETED: the quest has been
|
||||
* completed. In addition, this class defines two functions for lookup and inverse lookup of the state given a name. This is useful only for saving the state values into the database with a more readable form and then being able to read the string back and remap them to their correct states.
|
||||
* All quests have these and only these states.
|
||||
*/
|
||||
public class State
|
||||
{
|
||||
public final static byte CREATED = 0;
|
||||
public final static byte STARTED = 1;
|
||||
public final static byte COMPLETED = 2;
|
||||
|
||||
// discover the string representation of the state, for readable DB storage
|
||||
public static String getStateName(byte state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case 1:
|
||||
return "Started";
|
||||
case 2:
|
||||
return "Completed";
|
||||
default:
|
||||
return "Start";
|
||||
}
|
||||
}
|
||||
|
||||
// discover the state from its string representation (for reconstruction after DB read)
|
||||
public static byte getStateId(String statename)
|
||||
{
|
||||
if (statename.equals("Started"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (statename.equals("Completed"))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.l2jserver.gameserver.model.quest.jython;
|
||||
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
|
||||
public abstract class QuestJython extends Quest
|
||||
{
|
||||
/**
|
||||
* Constructor used in jython files.
|
||||
* @param questId : int designating the ID of the quest
|
||||
* @param name : String designating the name of the quest
|
||||
* @param descr : String designating the description of the quest
|
||||
*/
|
||||
public QuestJython(int questId, String name, String descr)
|
||||
{
|
||||
super(questId, name, descr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user