Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

View File

@@ -0,0 +1,227 @@
/*
* 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.instancezone.conditions;
import java.util.List;
import java.util.function.BiConsumer;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Abstract instance condition
* @author malyelfik
*/
public abstract class Condition
{
private final InstanceTemplate _template;
private final StatsSet _parameters;
private final boolean _leaderOnly;
private final boolean _showMessageAndHtml;
private SystemMessageId _systemMsg = null;
private BiConsumer<SystemMessage, L2PcInstance> _systemMsgParams = null;
/**
* Create new condition
* @param template template of instance where condition will be registered.
* @param parameters parameters of current condition
* @param onlyLeader flag which means if only leader should be affected (leader means player who wants to enter not group leader!)
* @param showMessageAndHtml if {@code true} and HTML message is defined then both are send, otherwise only HTML or message is send
*/
public Condition(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
_template = template;
_parameters = parameters;
_leaderOnly = onlyLeader;
_showMessageAndHtml = showMessageAndHtml;
}
/**
* Gets parameters of condition.
* @return set of parameters
*/
protected final StatsSet getParameters()
{
return _parameters;
}
/**
* Template of instance where condition is registered.
* @return instance template
*/
public InstanceTemplate getInstanceTemplate()
{
return _template;
}
/**
* Check if condition is valid for enter group {@code group}.
* @param npc instance of NPC which was used to enter into instance
* @param group group which contain players which wants to enter
* @param htmlCallback HTML callback function used to display fail HTML to player
* @return {@code true} when all conditions met, otherwise {@code false}
*/
public boolean validate(L2Npc npc, List<L2PcInstance> group, BiConsumer<L2PcInstance, String> htmlCallback)
{
for (L2PcInstance member : group)
{
if (!test(member, npc, group))
{
sendMessage(group, member, htmlCallback);
return false;
}
if (_leaderOnly)
{
break;
}
}
return true;
}
/**
* Send fail message to enter player group.
* @param group group which contain players from enter group
* @param member player which doesn't meet condition
* @param htmlCallback HTML callback function used to display fail HTML to player
*/
private void sendMessage(List<L2PcInstance> group, L2PcInstance member, BiConsumer<L2PcInstance, String> htmlCallback)
{
// Send HTML message if condition has any
final String html = _parameters.getString("html", null);
if ((html != null) && (htmlCallback != null))
{
// Send HTML only to player who make request to enter
htmlCallback.accept(group.get(0), html);
// Stop execution if only one message is allowed
if (!_showMessageAndHtml)
{
return;
}
}
// Send text message if condition has any
final String message = _parameters.getString("message", null);
if (message != null)
{
if (_leaderOnly)
{
member.sendMessage(message);
}
else
{
group.forEach(p -> p.sendMessage(message));
}
return;
}
// Send system message if condition has any
if (_systemMsg != null)
{
final SystemMessage msg = SystemMessage.getSystemMessage(_systemMsg);
if (_systemMsgParams != null)
{
_systemMsgParams.accept(msg, member);
}
if (_leaderOnly)
{
member.sendPacket(msg);
}
else
{
group.forEach(p -> p.sendPacket(msg));
}
}
}
/**
* Apply condition effect to enter player group.<br>
* This method is called when all instance conditions are met.
* @param group group of players which wants to enter into instance
*/
public void applyEffect(List<L2PcInstance> group)
{
for (L2PcInstance member : group)
{
onSuccess(member);
if (_leaderOnly)
{
break;
}
}
}
/**
* Set system message which should be send to player when validation fails.
* @param msg identification code of system message
*/
protected void setSystemMessage(SystemMessageId msg)
{
_systemMsg = msg;
}
/**
* Set system message which should be send to player when validation fails.<br>
* This method also allows set system message parameters like <i>player name, item name, ...</i>.
* @param msg identification code of system message
* @param params function which set parameters to system message
*/
protected void setSystemMessage(SystemMessageId msg, BiConsumer<SystemMessage, L2PcInstance> params)
{
setSystemMessage(msg);
_systemMsgParams = params;
}
/**
* Test condition for player.<br>
* <i>Calls {@link Condition#test(L2PcInstance, L2Npc)} by default.</i>
* @param player instance of player which should meet condition
* @param npc instance of NPC used to enter into instance
* @param group group of players which wants to enter
* @return {@code true} on success, {@code false} on fail
*/
protected boolean test(L2PcInstance player, L2Npc npc, List<L2PcInstance> group)
{
return test(player, npc);
}
/**
* Test condition for player.
* @param player instance of player which should meet condition
* @param npc instance of NPC used to enter into instance
* @return {@code true} on success, {@code false} on fail
*/
protected boolean test(L2PcInstance player, L2Npc npc)
{
return true;
}
/**
* Apply condition effects to player.<br>
* This method is called when all instance conditions are met.
* @param player player which should be affected
*/
protected void onSuccess(L2PcInstance player)
{
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Command channel condition
* @author malyelfik
*/
public final class ConditionCommandChannel extends Condition
{
public ConditionCommandChannel(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
setSystemMessage(SystemMessageId.YOU_CANNOT_ENTER_BECAUSE_YOU_ARE_NOT_ASSOCIATED_WITH_THE_CURRENT_COMMAND_CHANNEL);
}
@Override
public boolean test(L2PcInstance player, L2Npc npc)
{
return player.isInCommandChannel();
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.AbstractPlayerGroup;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Command channel leader condition
* @author malyelfik
*/
public final class ConditionCommandChannelLeader extends Condition
{
public ConditionCommandChannelLeader(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
setSystemMessage(SystemMessageId.ONLY_A_PARTY_LEADER_CAN_MAKE_THE_REQUEST_TO_ENTER);
}
@Override
public boolean test(L2PcInstance player, L2Npc npc)
{
final AbstractPlayerGroup group = player.getCommandChannel();
return (group != null) && group.isLeader(player);
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Distance instance condition
* @author malyelfik
*/
public final class ConditionDistance extends Condition
{
public ConditionDistance(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, onlyLeader, showMessageAndHtml);
setSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED, (message, player) -> message.addCharName(player));
}
@Override
public boolean test(L2PcInstance player, L2Npc npc)
{
final int distance = getParameters().getInt("distance", 1000);
return player.isInsideRadius(npc, distance, true, true);
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.instancezone.conditions;
import java.util.List;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance enter group max size
* @author malyelfik
*/
public final class ConditionGroupMax extends Condition
{
public ConditionGroupMax(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
setSystemMessage(SystemMessageId.YOU_CANNOT_ENTER_DUE_TO_THE_PARTY_HAVING_EXCEEDED_THE_LIMIT);
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc, List<L2PcInstance> group)
{
return group.size() <= getLimit();
}
public int getLimit()
{
return getParameters().getInt("limit");
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.instancezone.conditions;
import java.util.List;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance enter group min size
* @author malyelfik
*/
public final class ConditionGroupMin extends Condition
{
public ConditionGroupMin(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
setSystemMessage(SystemMessageId.YOU_MUST_HAVE_A_MINIMUM_OF_S1_PEOPLE_TO_ENTER_THIS_INSTANCED_ZONE, (msg, player) -> msg.addInt(getLimit()));
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc, List<L2PcInstance> group)
{
return group.size() >= getLimit();
}
public int getLimit()
{
return getParameters().getInt("limit");
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.enums.ResidenceType;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
/**
* Instance residence condition
* @author malyelfik
*/
public final class ConditionHasResidence extends Condition
{
public ConditionHasResidence(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, onlyLeader, showMessageAndHtml);
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc)
{
final L2Clan clan = player.getClan();
if (clan == null)
{
return false;
}
final StatsSet params = getParameters();
final int id = params.getInt("id");
boolean test = false;
switch (params.getEnum("type", ResidenceType.class))
{
case CASTLE:
test = clan.getCastleId() == id;
break;
case FORTRESS:
test = clan.getFortId() == id;
break;
case CLANHALL:
test = clan.getHideoutId() == id;
break;
}
return test;
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance item condition
* @author malyelfik
*/
public final class ConditionItem extends Condition
{
private final int _itemId;
private final long _count;
private final boolean _take;
public ConditionItem(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, onlyLeader, showMessageAndHtml);
// Load params
_itemId = parameters.getInt("id");
_count = parameters.getLong("count");
_take = parameters.getBoolean("take", false);
// Set message
setSystemMessage(SystemMessageId.C1_S_ITEM_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED, (msg, player) -> msg.addCharName(player));
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc)
{
return player.getInventory().getInventoryItemCount(_itemId, -1) >= _count;
}
@Override
protected void onSuccess(L2PcInstance player)
{
if (_take)
{
player.destroyItemByItemId("InstanceConditionDestroy", _itemId, _count, null, true);
}
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance level condition
* @author malyelfik
*/
public final class ConditionLevel extends Condition
{
private final int _min;
private final int _max;
public ConditionLevel(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, onlyLeader, showMessageAndHtml);
// Load params
_min = parameters.getInt("min", 1);
_max = parameters.getInt("max", Integer.MAX_VALUE);
// Set message
setSystemMessage(SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY, (msg, player) -> msg.addCharName(player));
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc)
{
return (player.getLevel() >= _min) && (player.getLevel() <= _max);
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
/**
* Instance no party condition
* @author St3eT
*/
public final class ConditionNoParty extends Condition
{
public ConditionNoParty(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
}
@Override
public boolean test(L2PcInstance player, L2Npc npc)
{
return !player.isInParty();
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance party condition
* @author malyelfik
*/
public final class ConditionParty extends Condition
{
public ConditionParty(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
setSystemMessage(SystemMessageId.YOU_ARE_NOT_CURRENTLY_IN_A_PARTY_SO_YOU_CANNOT_ENTER);
}
@Override
public boolean test(L2PcInstance player, L2Npc npc)
{
return player.isInParty();
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance party leader condition
* @author malyelfik
*/
public final class ConditionPartyLeader extends Condition
{
public ConditionPartyLeader(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, true, showMessageAndHtml);
setSystemMessage(SystemMessageId.ONLY_A_PARTY_LEADER_CAN_MAKE_THE_REQUEST_TO_ENTER);
}
@Override
public boolean test(L2PcInstance player, L2Npc npc)
{
return player.isInParty() && player.getParty().isLeader(player);
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.model.quest.Quest;
import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance quest condition
* @author malyelfik
*/
public final class ConditionQuest extends Condition
{
public ConditionQuest(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, onlyLeader, showMessageAndHtml);
// Set message
setSystemMessage(SystemMessageId.C1_S_QUEST_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED, (message, player) -> message.addCharName(player));
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc)
{
final int id = getParameters().getInt("id");
final Quest q = QuestManager.getInstance().getQuest(id);
if (q == null)
{
return false;
}
final QuestState qs = player.getQuestState(q.getName());
if (qs == null)
{
return false;
}
final int cond = getParameters().getInt("cond", -1);
return (cond != -1) ? qs.isCond(cond) : true;
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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.instancezone.conditions;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Instance reenter conditions
* @author malyelfik
*/
public final class ConditionReenter extends Condition
{
public ConditionReenter(InstanceTemplate template, StatsSet parameters, boolean onlyLeader, boolean showMessageAndHtml)
{
super(template, parameters, onlyLeader, showMessageAndHtml);
setSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET, (message, player) -> message.addCharName(player));
}
@Override
protected boolean test(L2PcInstance player, L2Npc npc)
{
final int instanceId = getParameters().getInt("instanceId", getInstanceTemplate().getId());
return System.currentTimeMillis() > InstanceManager.getInstance().getInstanceTime(player, instanceId);
}
}