Merged with released L2J-Unity files.
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.matching;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.ExManagePartyRoomMemberType;
|
||||
import com.l2jmobius.gameserver.enums.MatchingMemberType;
|
||||
import com.l2jmobius.gameserver.enums.MatchingRoomType;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
|
||||
import com.l2jmobius.gameserver.model.L2CommandChannel;
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExDissmissMPCCRoom;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExMPCCRoomInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExMPCCRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExManageMpccRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class CommandChannelMatchingRoom extends MatchingRoom
|
||||
{
|
||||
public CommandChannelMatchingRoom(String title, int loot, int minlvl, int maxlvl, int maxmem, L2PcInstance leader)
|
||||
{
|
||||
super(title, loot, minlvl, maxlvl, maxmem, leader);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRoomCreation(L2PcInstance player)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THE_COMMAND_CHANNEL_MATCHING_ROOM_WAS_CREATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyInvalidCondition(L2PcInstance player)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_COMMAND_CHANNEL_MATCHING_ROOM_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyNewMember(L2PcInstance player)
|
||||
{
|
||||
// Update others player
|
||||
getMembers().stream().filter(p -> p != player).forEach(p ->
|
||||
{
|
||||
p.sendPacket(new ExManageMpccRoomMember(p, this, ExManagePartyRoomMemberType.ADD_MEMBER));
|
||||
});
|
||||
|
||||
// Send SystemMessage to others player
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ENTERED_THE_COMMAND_CHANNEL_MATCHING_ROOM);
|
||||
sm.addPcName(player);
|
||||
getMembers().stream().filter(p -> p != player).forEach(sm::sendTo);
|
||||
|
||||
// Update new player
|
||||
player.sendPacket(new ExMPCCRoomInfo(this));
|
||||
player.sendPacket(new ExMPCCRoomMember(player, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyRemovedMember(L2PcInstance player, boolean kicked, boolean leaderChanged)
|
||||
{
|
||||
getMembers().forEach(p ->
|
||||
{
|
||||
p.sendPacket(new ExMPCCRoomInfo(this));
|
||||
p.sendPacket(new ExMPCCRoomMember(player, this));
|
||||
});
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(kicked ? SystemMessageId.YOU_WERE_EXPELLED_FROM_THE_COMMAND_CHANNEL_MATCHING_ROOM : SystemMessageId.YOU_EXITED_FROM_THE_COMMAND_CHANNEL_MATCHING_ROOM);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disbandRoom()
|
||||
{
|
||||
getMembers().forEach(p ->
|
||||
{
|
||||
p.sendPacket(SystemMessageId.THE_COMMAND_CHANNEL_MATCHING_ROOM_WAS_CANCELLED);
|
||||
p.sendPacket(ExDissmissMPCCRoom.STATIC_PACKET);
|
||||
p.setMatchingRoom(null);
|
||||
p.broadcastUserInfo(UserInfoType.CLAN);
|
||||
MatchingRoomManager.getInstance().addToWaitingList(p);
|
||||
});
|
||||
|
||||
getMembers().clear();
|
||||
|
||||
MatchingRoomManager.getInstance().removeMatchingRoom(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchingRoomType getRoomType()
|
||||
{
|
||||
return MatchingRoomType.COMMAND_CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchingMemberType getMemberType(L2PcInstance player)
|
||||
{
|
||||
if (isLeader(player))
|
||||
{
|
||||
return MatchingMemberType.COMMAND_CHANNEL_LEADER;
|
||||
}
|
||||
|
||||
final L2Party playerParty = player.getParty();
|
||||
|
||||
if (playerParty == null)
|
||||
{
|
||||
return MatchingMemberType.WAITING_PLAYER_NO_PARTY;
|
||||
}
|
||||
|
||||
final L2Party leaderParty = getLeader().getParty();
|
||||
if (leaderParty != null)
|
||||
{
|
||||
final L2CommandChannel cc = leaderParty.getCommandChannel();
|
||||
if ((leaderParty == playerParty) || ((cc != null) && cc.getPartys().contains(playerParty)))
|
||||
{
|
||||
return MatchingMemberType.COMMAND_CHANNEL_PARTY_MEMBER;
|
||||
}
|
||||
}
|
||||
|
||||
return MatchingMemberType.WAITING_PARTY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* 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.matching;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.MatchingMemberType;
|
||||
import com.l2jmobius.gameserver.enums.MatchingRoomType;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public abstract class MatchingRoom implements IIdentifiable
|
||||
{
|
||||
private final int _id;
|
||||
private String _title;
|
||||
private int _loot;
|
||||
private int _minLvl;
|
||||
private int _maxLvl;
|
||||
private int _maxCount;
|
||||
private volatile Set<L2PcInstance> _members;
|
||||
private L2PcInstance _leader;
|
||||
|
||||
public MatchingRoom(String title, int loot, int minlvl, int maxlvl, int maxmem, L2PcInstance leader)
|
||||
{
|
||||
_id = MatchingRoomManager.getInstance().addMatchingRoom(this);
|
||||
_title = title;
|
||||
_loot = loot;
|
||||
_minLvl = minlvl;
|
||||
_maxLvl = maxlvl;
|
||||
_maxCount = maxmem;
|
||||
_leader = leader;
|
||||
|
||||
addMember(_leader);
|
||||
onRoomCreation(leader);
|
||||
}
|
||||
|
||||
public Set<L2PcInstance> getMembers()
|
||||
{
|
||||
if (_members == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_members == null)
|
||||
{
|
||||
_members = ConcurrentHashMap.newKeySet(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _members;
|
||||
}
|
||||
|
||||
public void addMember(L2PcInstance player)
|
||||
{
|
||||
if ((player.getLevel() < _minLvl) || (player.getLevel() > _maxLvl) || ((_members != null) && (_members.size() >= _maxCount)))
|
||||
{
|
||||
notifyInvalidCondition(player);
|
||||
return;
|
||||
}
|
||||
|
||||
getMembers().add(player);
|
||||
MatchingRoomManager.getInstance().removeFromWaitingList(player);
|
||||
notifyNewMember(player);
|
||||
player.setMatchingRoom(this);
|
||||
player.broadcastUserInfo(UserInfoType.CLAN);
|
||||
}
|
||||
|
||||
public void deleteMember(L2PcInstance player, boolean kicked)
|
||||
{
|
||||
boolean leaderChanged = false;
|
||||
|
||||
if (player == _leader)
|
||||
{
|
||||
if (getMembers().isEmpty())
|
||||
{
|
||||
MatchingRoomManager.getInstance().removeMatchingRoom(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
final Iterator<L2PcInstance> iter = getMembers().iterator();
|
||||
if (iter.hasNext())
|
||||
{
|
||||
_leader = iter.next();
|
||||
iter.remove();
|
||||
leaderChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getMembers().remove(player);
|
||||
}
|
||||
|
||||
player.setMatchingRoom(null);
|
||||
player.broadcastUserInfo(UserInfoType.CLAN);
|
||||
MatchingRoomManager.getInstance().addToWaitingList(player);
|
||||
|
||||
notifyRemovedMember(player, kicked, leaderChanged);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getLootType()
|
||||
{
|
||||
return _loot;
|
||||
}
|
||||
|
||||
public int getMinLvl()
|
||||
{
|
||||
return _minLvl;
|
||||
}
|
||||
|
||||
public int getMaxLvl()
|
||||
{
|
||||
return _maxLvl;
|
||||
}
|
||||
|
||||
public int getLocation()
|
||||
{
|
||||
return MapRegionManager.getInstance().getBBs(_leader.getLocation());
|
||||
}
|
||||
|
||||
public int getMembersCount()
|
||||
{
|
||||
return _members == null ? 0 : _members.size();
|
||||
}
|
||||
|
||||
public int getMaxMembers()
|
||||
{
|
||||
return _maxCount;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
public L2PcInstance getLeader()
|
||||
{
|
||||
return _leader;
|
||||
}
|
||||
|
||||
public boolean isLeader(L2PcInstance player)
|
||||
{
|
||||
return player == _leader;
|
||||
}
|
||||
|
||||
public void setMinLvl(int minLvl)
|
||||
{
|
||||
_minLvl = minLvl;
|
||||
}
|
||||
|
||||
public void setMaxLvl(int maxLvl)
|
||||
{
|
||||
_maxLvl = maxLvl;
|
||||
}
|
||||
|
||||
public void setLootType(int loot)
|
||||
{
|
||||
_loot = loot;
|
||||
}
|
||||
|
||||
public void setMaxMembers(int maxCount)
|
||||
{
|
||||
_maxCount = maxCount;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
_title = title;
|
||||
}
|
||||
|
||||
protected abstract void onRoomCreation(L2PcInstance player);
|
||||
|
||||
protected abstract void notifyInvalidCondition(L2PcInstance player);
|
||||
|
||||
protected abstract void notifyNewMember(L2PcInstance player);
|
||||
|
||||
protected abstract void notifyRemovedMember(L2PcInstance player, boolean kicked, boolean leaderChanged);
|
||||
|
||||
public abstract void disbandRoom();
|
||||
|
||||
public abstract MatchingRoomType getRoomType();
|
||||
|
||||
public abstract MatchingMemberType getMemberType(L2PcInstance player);
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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.matching;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.MatchingMemberType;
|
||||
import com.l2jmobius.gameserver.enums.MatchingRoomType;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExClosePartyRoom;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ListPartyWaiting;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartyRoomInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public final class PartyMatchingRoom extends MatchingRoom
|
||||
{
|
||||
public PartyMatchingRoom(String title, int loot, int minlvl, int maxlvl, int maxmem, L2PcInstance leader)
|
||||
{
|
||||
super(title, loot, minlvl, maxlvl, maxmem, leader);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRoomCreation(L2PcInstance player)
|
||||
{
|
||||
player.broadcastUserInfo(UserInfoType.CLAN);
|
||||
player.sendPacket(new ListPartyWaiting(player.getLevel(), -1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyInvalidCondition(L2PcInstance player)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIREMENTS_TO_ENTER_THAT_PARTY_ROOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyNewMember(L2PcInstance player)
|
||||
{
|
||||
// Update others player
|
||||
getMembers().stream().filter(p -> p != player).forEach(p ->
|
||||
{
|
||||
p.sendPacket(new ExPartyRoomMember(p, this));
|
||||
});
|
||||
|
||||
// Send SystemMessage to others player
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ENTERED_THE_PARTY_ROOM);
|
||||
sm.addPcName(player);
|
||||
getMembers().stream().filter(p -> p != player).forEach(sm::sendTo);
|
||||
|
||||
// Update new player
|
||||
player.sendPacket(new PartyRoomInfo(this));
|
||||
player.sendPacket(new ExPartyRoomMember(player, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyRemovedMember(L2PcInstance player, boolean kicked, boolean leaderChanged)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(kicked ? SystemMessageId.C1_HAS_BEEN_KICKED_FROM_THE_PARTY_ROOM : SystemMessageId.C1_HAS_LEFT_THE_PARTY_ROOM);
|
||||
sm.addPcName(player);
|
||||
|
||||
getMembers().forEach(p ->
|
||||
{
|
||||
p.sendPacket(new PartyRoomInfo(this));
|
||||
p.sendPacket(new ExPartyRoomMember(player, this));
|
||||
p.sendPacket(sm);
|
||||
p.sendPacket(SystemMessageId.THE_LEADER_OF_THE_PARTY_ROOM_HAS_CHANGED);
|
||||
});
|
||||
|
||||
final SystemMessage sm2 = SystemMessage.getSystemMessage(kicked ? SystemMessageId.YOU_HAVE_BEEN_OUSTED_FROM_THE_PARTY_ROOM : SystemMessageId.YOU_HAVE_EXITED_THE_PARTY_ROOM);
|
||||
player.sendPacket(sm2);
|
||||
player.sendPacket(ExClosePartyRoom.STATIC_PACKET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disbandRoom()
|
||||
{
|
||||
getMembers().forEach(p ->
|
||||
{
|
||||
p.sendPacket(SystemMessageId.THE_PARTY_ROOM_HAS_BEEN_DISBANDED);
|
||||
p.sendPacket(ExClosePartyRoom.STATIC_PACKET);
|
||||
p.setMatchingRoom(null);
|
||||
p.broadcastUserInfo(UserInfoType.CLAN);
|
||||
MatchingRoomManager.getInstance().addToWaitingList(p);
|
||||
});
|
||||
|
||||
getMembers().clear();
|
||||
|
||||
MatchingRoomManager.getInstance().removeMatchingRoom(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchingRoomType getRoomType()
|
||||
{
|
||||
return MatchingRoomType.PARTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchingMemberType getMemberType(L2PcInstance player)
|
||||
{
|
||||
if (isLeader(player))
|
||||
{
|
||||
return MatchingMemberType.PARTY_LEADER;
|
||||
}
|
||||
|
||||
final L2Party leaderParty = getLeader().getParty();
|
||||
final L2Party playerParty = player.getParty();
|
||||
if ((leaderParty != null) && (playerParty != null) && (playerParty == leaderParty))
|
||||
{
|
||||
return MatchingMemberType.PARTY_MEMBER;
|
||||
}
|
||||
|
||||
return MatchingMemberType.WAITING_PLAYER;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user