Merge pull request #7545 from deathbeam/add-layout-message

Add raid layout message
This commit is contained in:
Tomas Slusny
2019-01-26 11:35:10 +00:00
committed by GitHub
7 changed files with 114 additions and 29 deletions

View File

@@ -62,6 +62,7 @@ import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.StackFormatter; import net.runelite.client.util.StackFormatter;
import static net.runelite.client.util.Text.sanitize;
import net.runelite.http.api.chat.ChatClient; import net.runelite.http.api.chat.ChatClient;
import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint; import net.runelite.http.api.hiscore.HiscoreEndpoint;
@@ -792,19 +793,6 @@ public class ChatCommandsPlugin extends Plugin
return shortest; return shortest;
} }
/**
* Cleans the ironman status icon from playername string if present and
* corrects spaces.
*
* @param lookup Playername to lookup.
* @return Cleaned playername.
*/
private static String sanitize(String lookup)
{
String cleaned = lookup.contains("<img") ? lookup.substring(lookup.lastIndexOf('>') + 1) : lookup;
return cleaned.replace('\u00A0', ' ');
}
/** /**
* Looks up the ironman status of the local player. Does NOT work on other players. * Looks up the ironman status of the local player. Does NOT work on other players.
* *

View File

@@ -134,4 +134,49 @@ public class Raid
return builder.toString(); return builder.toString();
} }
public String toRoomString()
{
final StringBuilder sb = new StringBuilder();
for (Room r : getLayout().getRooms())
{
final int position = r.getPosition();
final RaidRoom room = getRoom(position);
if (room == null || !(room.getType() == RaidRoom.Type.COMBAT || room.getType() == RaidRoom.Type.PUZZLE))
{
continue;
}
switch (room.getType())
{
case PUZZLE:
final RaidRoom.Puzzle puzzle = room.getPuzzle();
sb.append(puzzle.getName());
if (puzzle == RaidRoom.Puzzle.UNKNOWN)
{
sb.append(" (puzzle)");
}
sb.append(", ");
break;
case COMBAT:
final RaidRoom.Boss boss = room.getBoss();
sb.append(boss.getName());
if (boss == RaidRoom.Boss.UNKNOWN)
{
sb.append(" (combat)");
}
sb.append(", ");
break;
}
}
final String roomsString = sb.toString();
return roomsString.substring(0, roomsString.length() - 2);
}
} }

View File

@@ -151,4 +151,15 @@ public interface RaidsConfig extends Config
{ {
return ""; return "";
} }
@ConfigItem(
position = 11,
keyName = "layoutMessage",
name = "Send raid layout message when entering raid",
description = "Sends game message with raid layout on entering new raid"
)
default boolean layoutMessage()
{
return true;
}
} }

View File

@@ -86,7 +86,7 @@ public class RaidsOverlay extends Overlay
} }
Color color = Color.WHITE; Color color = Color.WHITE;
String layout = plugin.getRaid().getLayout().toCode().replaceAll("#", "").replaceAll("¤", ""); String layout = plugin.getRaid().getLayout().toCodeString();
if (config.enableLayoutWhitelist() && !plugin.getLayoutWhitelist().contains(layout.toLowerCase())) if (config.enableLayoutWhitelist() && !plugin.getLayoutWhitelist().contains(layout.toLowerCase()))
{ {

View File

@@ -242,21 +242,21 @@ public class RaidsPlugin extends Plugin
double percentage = personalPoints / (totalPoints / 100.0); double percentage = personalPoints / (totalPoints / 100.0);
String chatMessage = new ChatMessageBuilder() String chatMessage = new ChatMessageBuilder()
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append("Total points: ") .append("Total points: ")
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append(POINTS_FORMAT.format(totalPoints)) .append(POINTS_FORMAT.format(totalPoints))
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append(", Personal points: ") .append(", Personal points: ")
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append(POINTS_FORMAT.format(personalPoints)) .append(POINTS_FORMAT.format(personalPoints))
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append(" (") .append(" (")
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append(DECIMAL_FORMAT.format(percentage)) .append(DECIMAL_FORMAT.format(percentage))
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append("%)") .append("%)")
.build(); .build();
chatMessageManager.queue(QueuedMessage.builder() chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CLANCHAT_INFO) .type(ChatMessageType.CLANCHAT_INFO)
@@ -302,6 +302,7 @@ public class RaidsPlugin extends Plugin
raid.updateLayout(layout); raid.updateLayout(layout);
RotationSolver.solve(raid.getCombatRooms()); RotationSolver.solve(raid.getCombatRooms());
overlay.setScoutOverlayShown(true); overlay.setScoutOverlayShown(true);
sendRaidLayoutMessage();
} }
else if (!config.scoutOverlayAtBank()) else if (!config.scoutOverlayAtBank())
{ {
@@ -316,6 +317,28 @@ public class RaidsPlugin extends Plugin
} }
} }
private void sendRaidLayoutMessage()
{
if (!config.layoutMessage())
{
return;
}
final String layout = getRaid().getLayout().toCodeString();
final String rooms = getRaid().toRoomString();
final String raidData = "[" + layout + "]: " + rooms;
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CLANCHAT_INFO)
.runeLiteFormattedMessage(new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT)
.append("Layout: ")
.append(ChatColorType.NORMAL)
.append(raidData)
.build())
.build());
}
private void updateInfoBoxState() private void updateInfoBoxState()
{ {
if (timer == null) if (timer == null)

View File

@@ -62,4 +62,9 @@ public class Layout
return builder.toString(); return builder.toString();
} }
public String toCodeString()
{
return toCode().replaceAll("#", "").replaceAll("¤", "");
}
} }

View File

@@ -146,4 +146,17 @@ public class Text
return out.toString(); return out.toString();
} }
/**
* Cleans the ironman status icon from playername string if present and
* corrects spaces.
*
* @param name Playername to lookup.
* @return Cleaned playername.
*/
public static String sanitize(String name)
{
String cleaned = name.contains("<img") ? name.substring(name.lastIndexOf('>') + 1) : name;
return cleaned.replace('\u00A0', ' ');
}
} }