Fixed probable giveResidentialSkills NPE.

This commit is contained in:
MobiusDevelopment
2022-04-01 21:02:39 +00:00
parent 7733d3f253
commit d520ed36e8
100 changed files with 970 additions and 247 deletions

View File

@@ -103,6 +103,10 @@ public class CastleManager
public Castle getCastleByOwner(Clan clan)
{
if (clan == null)
{
return null;
}
for (Castle temp : _castles)
{
if (temp.getOwnerId() == clan.getId())

View File

@@ -80,6 +80,10 @@ public class FortManager
public Fort getFortByOwner(Clan clan)
{
if (clan == null)
{
return null;
}
for (Fort f : _forts)
{
if (f.getOwnerClan() == clan)

View File

@@ -61,6 +61,8 @@ import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import org.l2jmobius.gameserver.model.interfaces.INamable;
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.siege.Castle;
import org.l2jmobius.gameserver.model.siege.Fort;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
@@ -423,6 +425,7 @@ public class Clan implements IIdentifiable, INamable
LOGGER.warning("Member Object ID: " + objectId + " not found in clan while trying to remove");
return;
}
final int leadssubpledge = getLeaderSubPledge(objectId);
if (leadssubpledge != 0)
{
@@ -491,16 +494,23 @@ public class Clan implements IIdentifiable, INamable
removeSkillEffects(player);
// remove Residential skills
if (player.getClan().getCastleId() > 0)
if (getCastleId() > 0)
{
CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
final Castle castle = CastleManager.getInstance().getCastleByOwner(this);
if (castle != null)
{
castle.removeResidentialSkills(player);
}
}
if (player.getClan().getFortId() > 0)
if (getFortId() > 0)
{
FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
final Fort fort = FortManager.getInstance().getFortByOwner(this);
if (fort != null)
{
fort.removeResidentialSkills(player);
}
}
player.sendSkillList();
player.setClan(null);
// players leaving from clan academy have no penalty

View File

@@ -61,6 +61,7 @@ import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.residences.AuctionableHall;
import org.l2jmobius.gameserver.model.sevensigns.SevenSigns;
import org.l2jmobius.gameserver.model.siege.Castle;
import org.l2jmobius.gameserver.model.siege.Fort;
import org.l2jmobius.gameserver.model.siege.FortSiege;
import org.l2jmobius.gameserver.model.siege.Siege;
@@ -242,14 +243,15 @@ public class EnterWorld implements IClientIncomingPacket
boolean showClanNotice = false;
// Clan related checks are here
if (player.getClan() != null)
final Clan clan = player.getClan();
if (clan != null)
{
player.sendPacket(new PledgeSkillList(player.getClan()));
player.sendPacket(new PledgeSkillList(clan));
notifyClanMembers(player);
notifySponsorOrApprentice(player);
final AuctionableHall clanHall = ClanHallTable.getInstance().getClanHallByOwner(player.getClan());
final AuctionableHall clanHall = ClanHallTable.getInstance().getClanHallByOwner(clan);
if (clanHall != null)
{
if (!clanHall.getPaid())
@@ -265,13 +267,13 @@ public class EnterWorld implements IClientIncomingPacket
continue;
}
if (siege.checkIsAttacker(player.getClan()))
if (siege.checkIsAttacker(clan))
{
player.setSiegeState((byte) 1);
player.setSiegeSide(siege.getCastle().getResidenceId());
}
else if (siege.checkIsDefender(player.getClan()))
else if (siege.checkIsDefender(clan))
{
player.setSiegeState((byte) 2);
player.setSiegeSide(siege.getCastle().getResidenceId());
@@ -285,13 +287,13 @@ public class EnterWorld implements IClientIncomingPacket
continue;
}
if (siege.checkIsAttacker(player.getClan()))
if (siege.checkIsAttacker(clan))
{
player.setSiegeState((byte) 1);
player.setSiegeSide(siege.getFort().getResidenceId());
}
else if (siege.checkIsDefender(player.getClan()))
else if (siege.checkIsDefender(clan))
{
player.setSiegeState((byte) 2);
player.setSiegeSide(siege.getFort().getResidenceId());
@@ -305,7 +307,7 @@ public class EnterWorld implements IClientIncomingPacket
continue;
}
if (hall.isRegistered(player.getClan()))
if (hall.isRegistered(clan))
{
player.setSiegeState((byte) 1);
player.setSiegeSide(hall.getId());
@@ -313,21 +315,29 @@ public class EnterWorld implements IClientIncomingPacket
}
}
player.sendPacket(new PledgeShowMemberListAll(player.getClan(), player));
player.sendPacket(new PledgeStatusChanged(player.getClan()));
player.sendPacket(new PledgeShowMemberListAll(clan, player));
player.sendPacket(new PledgeStatusChanged(clan));
// Residential skills support
if (player.getClan().getCastleId() > 0)
if (clan.getCastleId() > 0)
{
CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
final Castle castle = CastleManager.getInstance().getCastleByOwner(clan);
if (castle != null)
{
castle.giveResidentialSkills(player);
}
}
if (player.getClan().getFortId() > 0)
if (clan.getFortId() > 0)
{
FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
final Fort fort = FortManager.getInstance().getFortByOwner(clan);
if (fort != null)
{
fort.giveResidentialSkills(player);
}
}
showClanNotice = player.getClan().isNoticeEnabled();
showClanNotice = clan.isNoticeEnabled();
}
if (TerritoryWarManager.getInstance().getRegisteredTerritoryId(player) > 0)