theatre: MErge nested if statements

This commit is contained in:
sdburns1998
2019-07-07 21:40:59 +02:00
parent 5a32de3039
commit 9259430894
5 changed files with 75 additions and 109 deletions

View File

@@ -134,15 +134,12 @@ public class BloatHandler extends RoomHandler
@Subscribe @Subscribe
public void onVarbitChanged(VarbitChanged event) public void onVarbitChanged(VarbitChanged event)
{ {
if (client.getVar(Varbits.BLOAT_DOOR) == 1) if (client.getVar(Varbits.BLOAT_DOOR) == 1 && !bloatFlag)
{
if (!bloatFlag)
{ {
bloatTimer = 0; bloatTimer = 0;
bloatFlag = true; bloatFlag = true;
} }
} }
}
public void onNpcSpawned(NpcSpawned event) public void onNpcSpawned(NpcSpawned event)
{ {

View File

@@ -240,14 +240,11 @@ public class MaidenHandler extends RoomHandler
{ {
NPC npc = event.getNpc(); NPC npc = event.getNpc();
if (npc.getName() != null && npc.getName().equals("Nylocas Matomenos")) if (npc.getName() != null && npc.getName().equals("Nylocas Matomenos") && npc.getId() == -1)
{
if (npc.getId() == -1)
{ {
nylos.removeIf(c -> c.getNpc() == npc); nylos.removeIf(c -> c.getNpc() == npc);
} }
} }
}
public void onChatMessage(ChatMessage event) public void onChatMessage(ChatMessage event)
{ {

View File

@@ -105,9 +105,7 @@ public class VerzikHandler extends RoomHandler
if (id == TheatreConstant.VERZIK_ID_P1) if (id == TheatreConstant.VERZIK_ID_P1)
{ {
if (plugin.isP1attacks()) if (plugin.isP1attacks() && this.versikCounter >= 0)
{
if (this.versikCounter >= 0)
{ {
String str = Integer.toString(versikCounter); String str = Integer.toString(versikCounter);
@@ -117,12 +115,9 @@ public class VerzikHandler extends RoomHandler
renderTextLocation(graphics, str, 20, Font.BOLD, Color.CYAN, point); renderTextLocation(graphics, str, 20, Font.BOLD, Color.CYAN, point);
} }
} }
}
else if (id == TheatreConstant.VERZIK_ID_P2) else if (id == TheatreConstant.VERZIK_ID_P2)
{ {
if (plugin.isP2attacks()) if (plugin.isP2attacks() && this.versikCounter >= 0)
{
if (this.versikCounter >= 0)
{ {
String str = Integer.toString(versikCounter); String str = Integer.toString(versikCounter);
@@ -132,13 +127,8 @@ public class VerzikHandler extends RoomHandler
renderTextLocation(graphics, str, 20, Font.BOLD, Color.CYAN, point); renderTextLocation(graphics, str, 20, Font.BOLD, Color.CYAN, point);
} }
} }
}
else if (id == TheatreConstant.VERZIK_ID_P3) else if (id == TheatreConstant.VERZIK_ID_P3 && plugin.isP3attacks() && versikCounter > 0 && versikCounter < 8)
{
if (plugin.isP3attacks())
{
if (versikCounter > 0 && versikCounter < 8)
{ {
String str = Math.max(versikCounter, 0) + "";// + " | " + model.getModelHeight();// + " | " + model.getRadius(); String str = Math.max(versikCounter, 0) + "";// + " | " + model.getModelHeight();// + " | " + model.getRadius();
@@ -148,23 +138,16 @@ public class VerzikHandler extends RoomHandler
renderTextLocation(graphics, str, 15, Font.BOLD, Color.WHITE, point); renderTextLocation(graphics, str, 15, Font.BOLD, Color.WHITE, point);
} }
} }
}
}
if (plugin.isVerzikTankTile()) if (plugin.isVerzikTankTile() && id == TheatreConstant.VERZIK_ID_P3)
{
if (id == TheatreConstant.VERZIK_ID_P3)
{ {
WorldPoint wp = new WorldPoint(npc.getWorldLocation().getX() + 3, npc.getWorldLocation().getY() + 3, client.getPlane()); WorldPoint wp = new WorldPoint(npc.getWorldLocation().getX() + 3, npc.getWorldLocation().getY() + 3, client.getPlane());
drawTile2(graphics, wp, new Color(75, 0, 130), 2, 255, 0); drawTile2(graphics, wp, new Color(75, 0, 130), 2, 255, 0);
//renderNpcOverlay(graphics, boss, new Color(75, 0, 130), 1, 255, 0); //renderNpcOverlay(graphics, boss, new Color(75, 0, 130), 1, 255, 0);
} }
}
if (plugin.isShowVerzikYellows()) if (plugin.isShowVerzikYellows() && this.yellows > 0)
{
if (this.yellows > 0)
{ {
String text = Integer.toString(this.yellows); String text = Integer.toString(this.yellows);
@@ -179,7 +162,6 @@ public class VerzikHandler extends RoomHandler
} }
} }
} }
}
if (plugin.isShowCrabTargets()) if (plugin.isShowCrabTargets())
{ {
@@ -336,13 +318,10 @@ public class VerzikHandler extends RoomHandler
this.yellows--; this.yellows--;
} }
if (npc != null) if (npc != null && npc.getAnimation() == 8117)
{
if (npc.getAnimation() == 8117)
{ {
redCrabsTimer = redCrabsTimer - 1; redCrabsTimer = redCrabsTimer - 1;
} }
}
boolean foundVerzik = false; boolean foundVerzik = false;

View File

@@ -95,13 +95,10 @@ public class NyloHandler extends RoomHandler
long minutes = seconds / 60L; long minutes = seconds / 60L;
seconds = seconds % 60; seconds = seconds % 60;
if (this.startTime != 0) if (this.startTime != 0 && plugin.isExtraTimers())
{
if (plugin.isExtraTimers())
{ {
this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'The Nylocas - Waves' completed! Duration: <col=ff0000>" + minutes + ":" + twoDigitString(seconds), null); this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'The Nylocas - Waves' completed! Duration: <col=ff0000>" + minutes + ":" + twoDigitString(seconds), null);
} }
}
System.out.println("Stopping Nylocas Room"); System.out.println("Stopping Nylocas Room");
} }
@@ -267,9 +264,7 @@ public class NyloHandler extends RoomHandler
this.pillars.put(npc, 100); this.pillars.put(npc, 100);
this.recalculateLocal(); this.recalculateLocal();
} }
else if (npc.getName() != null) else if (npc.getName() != null && this.plugin.getRoom() == TheatreRoom.NYLOCAS)
{
if (this.plugin.getRoom() == TheatreRoom.NYLOCAS)
{ {
Pattern p = Pattern.compile("Nylocas (Hagios|Toxobolos|Ischyros)"); Pattern p = Pattern.compile("Nylocas (Hagios|Toxobolos|Ischyros)");
Matcher m = p.matcher(npc.getName()); Matcher m = p.matcher(npc.getName());
@@ -288,7 +283,6 @@ public class NyloHandler extends RoomHandler
} }
} }
} }
}
public void onNpcDespawned(NpcDespawned event) public void onNpcDespawned(NpcDespawned event)
{ {

View File

@@ -158,9 +158,9 @@ public class XarpusHandler extends RoomHandler
public void onVarbitChanged(VarbitChanged event) public void onVarbitChanged(VarbitChanged event)
{ {
if (client.getVar(Varbits.MULTICOMBAT_AREA) == 1 || client.getVarbitValue(client.getVarps(), TheatreConstant.DOOR_VARP) == 2) if ((client.getVar(Varbits.MULTICOMBAT_AREA) == 1 ||
{ client.getVarbitValue(client.getVarps(), TheatreConstant.DOOR_VARP) == 2) &&
if (!xarpusFlag) !xarpusFlag)
{ {
int players = client.getPlayers().size(); int players = client.getPlayers().size();
@@ -188,7 +188,6 @@ public class XarpusHandler extends RoomHandler
xarpusFlag = true; xarpusFlag = true;
} }
} }
}
public void onNpcSpawned(NpcSpawned event) public void onNpcSpawned(NpcSpawned event)
{ {