Sync with L2jServer HighFive Feb 23rd 2015.

This commit is contained in:
mobius
2015-02-24 00:08:58 +00:00
parent ab37ff06dc
commit 79bc90ca26
68 changed files with 797 additions and 64 deletions

View File

@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.instancemanager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Duel;
@ -28,12 +28,11 @@ import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
public final class DuelManager
{
private final List<Duel> _duels;
private final Map<Integer, Duel> _duels = new ConcurrentHashMap<>();
private int _currentDuelId = 0x90;
protected DuelManager()
{
_duels = new ArrayList<>();
}
private int getNextDuelId()
@ -48,14 +47,7 @@ public final class DuelManager
public Duel getDuel(int duelId)
{
for (Duel duel : _duels)
{
if (duel.getId() == duelId)
{
return duel;
}
}
return null;
return _duels.get(duelId);
}
public void addDuel(L2PcInstance playerA, L2PcInstance playerB, int partyDuel)
@ -112,9 +104,8 @@ public final class DuelManager
return;
}
}
final Duel duel = new Duel(playerA, playerB, partyDuel, getNextDuelId());
_duels.add(duel);
final int duelId = getNextDuelId();
_duels.put(duelId, new Duel(playerA, playerB, partyDuel, duelId));
}
public void removeDuel(Duel duel)

View File

@ -7097,6 +7097,9 @@ public final class L2PcInstance extends L2Playable
player.setPledgeType(rset.getInt("subpledge"));
// player.setApprentice(rset.getInt("apprentice"));
// Set Hero status if it applies
player.setHero(Hero.getInstance().isHero(objectId));
if (clanId > 0)
{
player.setClan(ClanTable.getInstance().getClan(clanId));
@ -7230,12 +7233,6 @@ public final class L2PcInstance extends L2Playable
return null;
}
// Set Hero status if it applies
if (Hero.getInstance().isHero(objectId))
{
player.setHero(true);
}
// Retrieve from the database all items of this L2PcInstance and add them to _inventory
player.getInventory().restore();
player.getFreight().restore();

View File

@ -21,6 +21,7 @@ package com.l2jserver.gameserver.model.entity;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -54,6 +55,8 @@ public class Duel
public static final int DUELSTATE_WINNER = 3;
public static final int DUELSTATE_INTERRUPTED = 4;
private static final PlaySound B04_S01 = new PlaySound(1, "B04_S01", 0, 0, 0, 0, 0);
private final int _duelId;
private L2PcInstance _playerA;
private L2PcInstance _playerB;
@ -63,7 +66,7 @@ public class Duel
private int _countdown = 4;
private boolean _finished = false;
private List<PlayerCondition> _playerConditions;
private final List<PlayerCondition> _playerConditions = new CopyOnWriteArrayList<>();
public Duel(L2PcInstance playerA, L2PcInstance playerB, int partyDuel, int duelId)
{
@ -82,15 +85,13 @@ public class Duel
_duelEndTime.add(Calendar.SECOND, 120);
}
_playerConditions = new ArrayList<>();
setFinished(false);
if (_partyDuel)
{
// increase countdown so that start task can teleport players
_countdown++;
// inform players that they will be portet shortly
// inform players that they will be ported shortly
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IN_A_MOMENT_YOU_WILL_BE_TRANSPORTED_TO_THE_SITE_WHERE_THE_DUEL_WILL_TAKE_PLACE);
broadcastToTeam1(sm);
broadcastToTeam2(sm);
@ -358,9 +359,7 @@ public class Duel
if ((_playerA == null) || (_playerB == null) || _playerA.isInDuel() || _playerB.isInDuel())
{
// clean up
_playerConditions.clear();
_playerConditions = null;
DuelManager.getInstance().removeDuel(this);
return;
}
@ -420,9 +419,8 @@ public class Duel
}
// play sound
PlaySound ps = new PlaySound(1, "B04_S01", 0, 0, 0, 0, 0);
broadcastToTeam1(ps);
broadcastToTeam2(ps);
broadcastToTeam1(B04_S01);
broadcastToTeam2(B04_S01);
// start duelling task
ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleDuelTask(this), 1000);
@ -435,13 +433,13 @@ public class Duel
{
if (_partyDuel)
{
for (L2PcInstance temp : _playerA.getParty().getMembers())
for (L2PcInstance player : _playerA.getParty().getMembers())
{
_playerConditions.add(new PlayerCondition(temp, _partyDuel));
_playerConditions.add(new PlayerCondition(player, _partyDuel));
}
for (L2PcInstance temp : _playerB.getParty().getMembers())
for (L2PcInstance player : _playerB.getParty().getMembers())
{
_playerConditions.add(new PlayerCondition(temp, _partyDuel));
_playerConditions.add(new PlayerCondition(player, _partyDuel));
}
}
else
@ -490,10 +488,7 @@ public class Duel
}
// restore player conditions
for (PlayerCondition cond : _playerConditions)
{
cond.restoreCondition();
}
_playerConditions.forEach(c -> c.restoreCondition());
}
/**
@ -735,7 +730,6 @@ public class Duel
{
// clean up
_playerConditions.clear();
_playerConditions = null;
DuelManager.getInstance().removeDuel(this);
return;
}
@ -780,7 +774,7 @@ public class Duel
break;
case Canceled:
stopFighting();
// dont restore hp, mp, cp
// Don't restore hp, mp, cp
restorePlayerConditions(true);
// TODO: is there no other message for a canceled duel?
// send SystemMessage
@ -817,7 +811,6 @@ public class Duel
// clean up
_playerConditions.clear();
_playerConditions = null;
DuelManager.getInstance().removeDuel(this);
}
@ -898,7 +891,7 @@ public class Duel
*/
public void doSurrender(L2PcInstance player)
{
// already recived a surrender request
// already received a surrender request
if (_surrenderRequest != 0)
{
return;
@ -1012,14 +1005,14 @@ public class Duel
*/
public void onRemoveFromParty(L2PcInstance player)
{
// if it isnt a party duel ignore this
// if it isn't a party duel ignore this
if (!_partyDuel)
{
return;
}
// this player is leaving his party during party duel
// if hes either playerA or playerB cancel the duel and port the players back
// if he's either playerA or playerB cancel the duel and port the players back
if ((player == _playerA) || (player == _playerB))
{
for (PlayerCondition cond : _playerConditions)
@ -1034,14 +1027,11 @@ public class Duel
else
// teleport the player back & delete his PlayerCondition record
{
for (PlayerCondition cond : _playerConditions)
final PlayerCondition cond = _playerConditions.stream().filter(c -> c.getPlayer() == player).findFirst().orElse(null);
if (cond != null)
{
if (cond.getPlayer() == player)
{
cond.teleportBack();
_playerConditions.remove(cond);
break;
}
cond.teleportBack();
_playerConditions.remove(cond);
}
player.setIsInDuel(0);
}
@ -1049,13 +1039,10 @@ public class Duel
public void onBuff(L2PcInstance player, Skill debuff)
{
for (PlayerCondition cond : _playerConditions)
final PlayerCondition cond = _playerConditions.stream().filter(c -> c.getPlayer() == player).findFirst().orElse(null);
if (cond != null)
{
if (cond.getPlayer() == player)
{
cond.registerDebuff(debuff);
return;
}
cond.registerDebuff(debuff);
}
}
}