Minor code improvements.

This commit is contained in:
MobiusDev
2016-12-11 20:32:47 +00:00
parent 6a2ccc62e4
commit 70f0330eb0
182 changed files with 1006 additions and 1328 deletions

View File

@@ -247,7 +247,7 @@ public final class Alarm extends AbstractNpcAI
* @param memoState the memo state, if memo state is less than zero, only quest state is checked
* @return {@code true} if the player has the memo state, {@code false} otherwise
*/
private static final boolean verifyMemoState(L2PcInstance player, int questId, int memoState)
private static boolean verifyMemoState(L2PcInstance player, int questId, int memoState)
{
QuestState qs = null;
switch (questId)
@@ -272,7 +272,7 @@ public final class Alarm extends AbstractNpcAI
* @param questId the quest ID
* @param memoState the memo state
*/
private static final void setMemoState(L2PcInstance player, int questId, int memoState)
private static void setMemoState(L2PcInstance player, int questId, int memoState)
{
QuestState qs = null;
switch (questId)
@@ -301,7 +301,7 @@ public final class Alarm extends AbstractNpcAI
* @param slot the slot
* @return the memo state ex
*/
private static final int getMemoStateEx(L2PcInstance player, int questId, int slot)
private static int getMemoStateEx(L2PcInstance player, int questId, int slot)
{
QuestState qs = null;
switch (questId)
@@ -327,7 +327,7 @@ public final class Alarm extends AbstractNpcAI
* @param slot the slot
* @param memoStateEx the memo state ex
*/
private static final void setMemoStateEx(L2PcInstance player, int questId, int slot, int memoStateEx)
private static void setMemoStateEx(L2PcInstance player, int questId, int slot, int memoStateEx)
{
QuestState qs = null;
switch (questId)

View File

@@ -205,18 +205,15 @@ public final class DenOfEvil extends AbstractNpcAI
final Skill skill = SkillData.getInstance().getSkill(6149, 1);
skill.applyEffects(character, character);
}
else
else if (character.doDie(null)) // mobs die
{
if (character.doDie(null)) // mobs die
if (character.isNpc())
{
if (character.isNpc())
// respawn eye
final L2Npc npc = (L2Npc) character;
if (CommonUtil.contains(EYE_IDS, npc.getId()))
{
// respawn eye
final L2Npc npc = (L2Npc) character;
if (CommonUtil.contains(EYE_IDS, npc.getId()))
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
}
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
}
}
}

View File

@@ -32,17 +32,17 @@ import ai.AbstractNpcAI;
public final class LairOfAntharas extends AbstractNpcAI
{
// NPC
final private static int KNORIKS = 22857;
final private static int DRAGON_KNIGHT = 22844;
final private static int DRAGON_KNIGHT2 = 22845;
final private static int ELITE_DRAGON_KNIGHT = 22846;
private static final int KNORIKS = 22857;
private static final int DRAGON_KNIGHT = 22844;
private static final int DRAGON_KNIGHT2 = 22845;
private static final int ELITE_DRAGON_KNIGHT = 22846;
final private static int DRAGON_GUARD = 22852;
final private static int DRAGON_MAGE = 22853;
private static final int DRAGON_GUARD = 22852;
private static final int DRAGON_MAGE = 22853;
// Misc
final private static int KNIGHT_CHANCE = 30;
final private static int KNORIKS_CHANCE = 60;
final private static int KNORIKS_CHANCE2 = 50;
private static final int KNIGHT_CHANCE = 30;
private static final int KNORIKS_CHANCE = 60;
private static final int KNORIKS_CHANCE2 = 50;
private LairOfAntharas()
{

View File

@@ -360,18 +360,15 @@ public final class Valakas extends AbstractNpcAI
callSkillAI(npc);
}
}
else
else if (event.equalsIgnoreCase("valakas_unlock"))
{
if (event.equalsIgnoreCase("valakas_unlock"))
{
final L2Npc valakas = addSpawn(VALAKAS, -105200, -253104, -15264, 32768, false, 0);
GrandBossManager.getInstance().addBoss((L2GrandBossInstance) valakas);
GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
}
else if (event.equalsIgnoreCase("remove_players"))
{
ZONE.oustAllPlayers();
}
final L2Npc valakas = addSpawn(VALAKAS, -105200, -253104, -15264, 32768, false, 0);
GrandBossManager.getInstance().addBoss((L2GrandBossInstance) valakas);
GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
}
else if (event.equalsIgnoreCase("remove_players"))
{
ZONE.oustAllPlayers();
}
return super.onAdvEvent(event, npc, player);
}

View File

@@ -198,9 +198,9 @@ public final class FourSepulchers extends AbstractNpcAI implements IGameXmlReade
STORED_PROGRESS.put(3, 1);
STORED_PROGRESS.put(4, 1);
}
private final static int PARTY_MEMBER_COUNT = 4;
private final static int ENTRY_DELAY = 3; // minutes
private final static int TIME_ATTACK = 60; // minutes
private static final int PARTY_MEMBER_COUNT = 4;
private static final int ENTRY_DELAY = 3; // minutes
private static final int TIME_ATTACK = 60; // minutes
private FourSepulchers()
{

View File

@@ -246,20 +246,17 @@ public final class Antharas extends AbstractNpcAI
}
}
}
else if (!hasQuestItems(player, STONE))
{
htmltext = "13001-03.html";
}
else
{
if (!hasQuestItems(player, STONE))
player.teleToLocation(179700 + getRandom(700), 113800 + getRandom(2100), -7709);
if (getStatus() != WAITING)
{
htmltext = "13001-03.html";
}
else
{
player.teleToLocation(179700 + getRandom(700), 113800 + getRandom(2100), -7709);
if (getStatus() != WAITING)
{
setStatus(WAITING);
startQuestTimer("SPAWN_ANTHARAS", Config.ANTHARAS_WAIT_TIME * 60000, null, null);
}
setStatus(WAITING);
startQuestTimer("SPAWN_ANTHARAS", Config.ANTHARAS_WAIT_TIME * 60000, null, null);
}
}
return htmltext;

View File

@@ -29,7 +29,7 @@ import ai.AbstractNpcAI;
public final class MithrilMinesTeleporter extends AbstractNpcAI
{
// NPC
private final static int TELEPORT_CRYSTAL = 32652;
private static final int TELEPORT_CRYSTAL = 32652;
// Location
private static final Location[] LOCS =
{

View File

@@ -31,7 +31,7 @@ import quests.Q00240_ImTheOnlyOneYouCanTrust.Q00240_ImTheOnlyOneYouCanTrust;
public final class StakatoNestTeleporter extends AbstractNpcAI
{
// Locations
private final static Location[] LOCS =
private static final Location[] LOCS =
{
new Location(80456, -52322, -5640),
new Location(88718, -46214, -4640),
@@ -40,7 +40,7 @@ public final class StakatoNestTeleporter extends AbstractNpcAI
new Location(87682, -43291, -4128)
};
// NPC
private final static int KINTAIJIN = 32640;
private static final int KINTAIJIN = 32640;
private StakatoNestTeleporter()
{

View File

@@ -67,14 +67,14 @@ public final class Raina extends AbstractNpcAI
// Items
private static final int SUBCLASS_CERTIFICATE = 30433;
private static final int CHAOS_POMANDER = 37375;
private final static int ABELIUS_POWER = 32264;
private final static int SAPYROS_POWER = 32265;
private final static int ASHAGEN_POWER = 32266;
private final static int CRANIGG_POWER = 32267;
private final static int SOLTKREIG_POWER = 32268;
private final static int NAVIAROPE_POWER = 32269;
private final static int LEISTER_POWER = 32270;
private final static int LAKCIS_POWER = 32271;
private static final int ABELIUS_POWER = 32264;
private static final int SAPYROS_POWER = 32265;
private static final int ASHAGEN_POWER = 32266;
private static final int CRANIGG_POWER = 32267;
private static final int SOLTKREIG_POWER = 32268;
private static final int NAVIAROPE_POWER = 32269;
private static final int LEISTER_POWER = 32270;
private static final int LAKCIS_POWER = 32271;
// Misc
private static final Set<PlayerClass> mainSubclassSet;
private static final Set<PlayerClass> neverSubclassed = EnumSet.of(PlayerClass.Overlord, PlayerClass.Warsmith);

View File

@@ -317,12 +317,9 @@ public final class QueenAnt extends AbstractNpcAI
curse = CommonSkill.RAID_CURSE.getSkill();
}
}
else
else if (!character.hasAbnormalType(CommonSkill.RAID_CURSE2.getSkill().getAbnormalType()) && (getRandom(4) == 0))
{
if (!character.hasAbnormalType(CommonSkill.RAID_CURSE2.getSkill().getAbnormalType()) && (getRandom(4) == 0))
{
curse = CommonSkill.RAID_CURSE2.getSkill();
}
curse = CommonSkill.RAID_CURSE2.getSkill();
}
if (curse != null)

View File

@@ -139,7 +139,7 @@ public final class CastleAmbassador extends AbstractNpcAI
}
htmltext = getHtm(player.getHtmlPrefix(), htmltext);
htmltext = htmltext.replace("%castleName%", String.valueOf(fortresss.getCastleByAmbassador(npc.getId()).getName()));
htmltext = htmltext.replace("%castleName%", fortresss.getCastleByAmbassador(npc.getId()).getName());
return htmltext;
}

View File

@@ -1100,8 +1100,8 @@ public final class CastleChamberlain extends AbstractNpcAI
else
{
final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-25.html");
html.replace("%owner_name%", String.valueOf(player.getName()));
html.replace("%feud_name%", String.valueOf(String.valueOf(1001000 + castle.getResidenceId())));
html.replace("%owner_name%", player.getName());
html.replace("%feud_name%", String.valueOf(1001000 + castle.getResidenceId()));
player.sendPacket(html);
giveItems(player, CROWN, 1);
}

View File

@@ -169,16 +169,13 @@ public final class CastleTeleporter extends AbstractNpcAI
final Siege siege = npc.getCastle().getSiege();
htmltext = (npc.isScriptValue(0)) ? (siege.isInProgress() && (siege.getControlTowerCount() == 0)) ? "CastleTeleporter-05.html" : "CastleTeleporter-04.html" : "CastleTeleporter-06.html";
}
else if ((npc.getCastle().getOwnerId() == player.getClanId()) && (player.getClanId() != 0) && (player.getSiegeState() == 2)) // Deffender
{
htmltext = getHtmlName(npc) + ".html";
}
else
{
if ((npc.getCastle().getOwnerId() == player.getClanId()) && (player.getClanId() != 0) && (player.getSiegeState() == 2)) // Deffender
{
htmltext = getHtmlName(npc) + ".html";
}
else
{
htmltext = getHtmlName(npc) + "-no.html";
}
htmltext = getHtmlName(npc) + "-no.html";
}
return htmltext;
}

View File

@@ -490,10 +490,10 @@ public final class ClanHallManager extends AbstractNpcAI
{
if (func != null)
{
htmltext = htmltext.replaceAll("%" + name + "recovery%", String.valueOf((int) func.getTemplate().getValue()) + "%");
htmltext = htmltext.replaceAll("%" + name + "recovery%", (int) func.getTemplate().getValue() + "%");
htmltext = htmltext.replaceAll("%" + name + "price%", "<fstring p1=\"" + func.getTemplate().getCost().getCount() + "\" p2=\"" + func.getTemplate().getDurationAsDays() + "\">" + NpcStringId.FONT_COLOR_FFAABB_S1_FONT_ADENA_S2_DAY_S.getId() + "</fstring>");
htmltext = htmltext.replace("%" + name + "expire%", "Withdraw the fee for the next time at " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(func.getExpiration())));
htmltext = htmltext.replaceAll("%" + name + "deactive%", "[<a action=\"bypass -h Quest ClanHallManager manageFunctions removeFunction confirm " + func.getType().toString() + "\">Deactivate</a>]");
htmltext = htmltext.replaceAll("%" + name + "deactive%", "[<a action=\"bypass -h Quest ClanHallManager manageFunctions removeFunction confirm " + func.getType() + "\">Deactivate</a>]");
}
else
{

View File

@@ -73,12 +73,12 @@ public final class MentorGuide extends AbstractNpcAI implements IGameXmlReader
private static final int MENTEE_HEADPHONE = 34759;
private static final int DIPLOMA = 33805;
// Skills
private final static SkillHolder[] MENTEE_BUFFS =
private static final SkillHolder[] MENTEE_BUFFS =
{
new SkillHolder(9233, 1), // Mentor's Guidance
};
// Skills
private final static SkillHolder[] MENTEE_BUFFS_WITHOUT_MENTOR_ONLINE =
private static final SkillHolder[] MENTEE_BUFFS_WITHOUT_MENTOR_ONLINE =
{
new SkillHolder(9227, 1), // Mentor's Poem of Horn
new SkillHolder(9228, 1), // Mentor's Poem of Drum

View File

@@ -290,23 +290,20 @@ public final class Minigame extends AbstractNpcAI
startQuestTimer("end", 4000, room.getManager(), null);
}
}
else
else if (room.getAttemptNumber() == MAX_ATTEMPTS)
{
if (room.getAttemptNumber() == MAX_ATTEMPTS)
{
room.getManager().broadcastSay(ChatType.NPC_GENERAL, NpcStringId.I_VE_FAILED_ANY_FURTHER_ATTEMPTS_WOULD_BE_WASTEFUL);
room.burnThemAll();
startQuestTimer("off", 2000, room.getManager(), null);
room.getParticipant().removeListenerIf(EventType.ON_CREATURE_SKILL_USE, listener -> listener.getOwner() == room);
startQuestTimer("end", 4000, room.getManager(), null);
}
else if (room.getAttemptNumber() < MAX_ATTEMPTS)
{
room.getManager().broadcastSay(ChatType.NPC_GENERAL, NpcStringId.TOO_BAD_I_WILL_NOT_GIVE_UP_ON_THIS_THOUGH);
room.burnThemAll();
startQuestTimer("off", 2000, room.getManager(), null);
room.setAttemptNumber(room.getAttemptNumber() + 1);
}
room.getManager().broadcastSay(ChatType.NPC_GENERAL, NpcStringId.I_VE_FAILED_ANY_FURTHER_ATTEMPTS_WOULD_BE_WASTEFUL);
room.burnThemAll();
startQuestTimer("off", 2000, room.getManager(), null);
room.getParticipant().removeListenerIf(EventType.ON_CREATURE_SKILL_USE, listener -> listener.getOwner() == room);
startQuestTimer("end", 4000, room.getManager(), null);
}
else if (room.getAttemptNumber() < MAX_ATTEMPTS)
{
room.getManager().broadcastSay(ChatType.NPC_GENERAL, NpcStringId.TOO_BAD_I_WILL_NOT_GIVE_UP_ON_THIS_THOUGH);
room.burnThemAll();
startQuestTimer("off", 2000, room.getManager(), null);
room.setAttemptNumber(room.getAttemptNumber() + 1);
}
}
}

View File

@@ -57,18 +57,15 @@ public final class MysteriousWizard extends AbstractNpcAI
{
htmltext = "33980.html";
}
else
else if (qs != null)
{
if (qs != null)
if (qs.isCond(6))
{
if (qs.isCond(6))
{
htmltext = "33980-05.html";
}
else if (qs.isCond(7))
{
htmltext = "33980-04.html";
}
htmltext = "33980-05.html";
}
else if (qs.isCond(7))
{
htmltext = "33980-04.html";
}
}
return htmltext;

View File

@@ -156,16 +156,13 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
player.sendPacket(SystemMessageId.UNABLE_TO_PROCESS_THIS_REQUEST_UNTIL_YOUR_INVENTORY_S_WEIGHT_AND_SLOT_COUNT_ARE_LESS_THAN_80_PERCENT_OF_CAPACITY);
}
else if (event.equals("register1v1"))
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
else
{
if (event.equals("register1v1"))
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
else
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.CLASSED);
}
OlympiadManager.getInstance().registerNoble(player, CompetitionType.CLASSED);
}
break;
}
@@ -340,42 +337,39 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
activeChar.sendPacket(new ExOlympiadMatchList());
}
else if ((olymanager == null) || (olymanager.getId() != MANAGER) || (!activeChar.inObserverMode() && !activeChar.isInsideRadius(olymanager, 300, false, false)))
{
return false;
}
else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
{
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_OBSERVE_A_OLYMPIAD_GAMES_MATCH_WHILE_YOU_ARE_ON_THE_WAITING_LIST);
return false;
}
else if (!Olympiad.getInstance().inCompPeriod())
{
activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
return false;
}
else if (activeChar.isOnEvent())
{
activeChar.sendMessage("You can not observe games while registered on an event");
return false;
}
else
{
if ((olymanager == null) || (olymanager.getId() != MANAGER) || (!activeChar.inObserverMode() && !activeChar.isInsideRadius(olymanager, 300, false, false)))
final int arenaId = Integer.parseInt(command.substring(12).trim());
final OlympiadGameTask nextArena = OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
if (nextArena != null)
{
return false;
}
else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
{
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_OBSERVE_A_OLYMPIAD_GAMES_MATCH_WHILE_YOU_ARE_ON_THE_WAITING_LIST);
return false;
}
else if (!Olympiad.getInstance().inCompPeriod())
{
activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
return false;
}
else if (activeChar.isOnEvent())
{
activeChar.sendMessage("You can not observe games while registered on an event");
return false;
}
else
{
final int arenaId = Integer.parseInt(command.substring(12).trim());
final OlympiadGameTask nextArena = OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
if (nextArena != null)
final List<Location> spectatorSpawns = nextArena.getStadium().getZone().getSpectatorSpawns();
if (spectatorSpawns.isEmpty())
{
final List<Location> spectatorSpawns = nextArena.getStadium().getZone().getSpectatorSpawns();
if (spectatorSpawns.isEmpty())
{
_LOG.warning(getClass().getSimpleName() + ": Zone: " + nextArena.getStadium().getZone() + " doesn't have specatator spawns defined!");
return false;
}
final Location loc = spectatorSpawns.get(Rnd.get(spectatorSpawns.size()));
activeChar.enterOlympiadObserverMode(loc, arenaId);
_LOG.warning(getClass().getSimpleName() + ": Zone: " + nextArena.getStadium().getZone() + " doesn't have specatator spawns defined!");
return false;
}
final Location loc = spectatorSpawns.get(Rnd.get(spectatorSpawns.size()));
activeChar.enterOlympiadObserverMode(loc, arenaId);
}
}
return true;

View File

@@ -94,14 +94,11 @@ public final class PrisonGuards extends AbstractNpcAI
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.IT_S_NOT_EASY_TO_OBTAIN);
}
}
else
else if (!player.isAffectedBySkill(TIMER) && (npc.calculateDistance(npc.getSpawn().getLocation(), false, false) < 2000))
{
if (!player.isAffectedBySkill(TIMER) && (npc.calculateDistance(npc.getSpawn().getLocation(), false, false) < 2000))
{
npc.setTarget(player);
npc.doCast(STONE.getSkill());
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.YOU_RE_OUT_OF_YOUR_MIND_COMING_HERE);
}
npc.setTarget(player);
npc.doCast(STONE.getSkill());
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.YOU_RE_OUT_OF_YOUR_MIND_COMING_HERE);
}
return super.onAttack(npc, player, damage, isSummon);
}

View File

@@ -29,14 +29,14 @@ import ai.AbstractNpcAI;
public final class TeleportWithCharm extends AbstractNpcAI
{
// NPCs
private final static int WHIRPY = 30540;
private final static int TAMIL = 30576;
private static final int WHIRPY = 30540;
private static final int TAMIL = 30576;
// Items
private final static int ORC_GATEKEEPER_CHARM = 1658;
private final static int DWARF_GATEKEEPER_TOKEN = 1659;
private static final int ORC_GATEKEEPER_CHARM = 1658;
private static final int DWARF_GATEKEEPER_TOKEN = 1659;
// Locations
private final static Location ORC_TELEPORT = new Location(-80826, 149775, -3043);
private final static Location DWARF_TELEPORT = new Location(-80826, 149775, -3043);
private static final Location ORC_TELEPORT = new Location(-80826, 149775, -3043);
private static final Location DWARF_TELEPORT = new Location(-80826, 149775, -3043);
private TeleportWithCharm()
{

View File

@@ -46,8 +46,8 @@ public final class GateOfUnlimitedSummoning extends AbstractNpcAI
}
// Skills
final static private int GATE_ROOT = 11289;
final static private int GATE_VORTEX = 11291;
private static final int GATE_ROOT = 11289;
private static final int GATE_VORTEX = 11291;
private GateOfUnlimitedSummoning()
{