Java Code Examples for net.runelite.api.ChatMessageType#equals()
The following examples show how to use
net.runelite.api.ChatMessageType#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlayerPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
void taskLookup(ChatMessage chatMessage, String message) { if (!config.taskCommand()) { return; } ChatMessageType type = chatMessage.getType(); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = Text.removeTags(chatMessage.getName()) .replace('\u00A0', ' '); } net.runelite.http.api.chat.Task task; try { task = chatClient.getTask(player); } catch (IOException ex) { log.debug("unable to lookup slayer task", ex); return; } if (task == null) { return; } if (TASK_STRING_VALIDATION.matcher(task.getTask()).find() || task.getTask().length() > TASK_STRING_MAX_LENGTH || TASK_STRING_VALIDATION.matcher(task.getLocation()).find() || task.getLocation().length() > TASK_STRING_MAX_LENGTH || Task.getTask(task.getTask()) == null || !Task.LOCATIONS.contains(task.getLocation())) { log.debug("Validation failed for task name or location: {}", task); return; } int killed = task.getInitialAmount() - task.getAmount(); StringBuilder sb = new StringBuilder(); sb.append(task.getTask()); if (!Strings.isNullOrEmpty(task.getLocation())) { sb.append(" (").append(task.getLocation()).append(")"); } sb.append(": "); if (killed < 0) { sb.append(task.getAmount()).append(" left"); } else { sb.append(killed).append('/').append(task.getInitialAmount()).append(" killed"); } String response = new ChatMessageBuilder() .append(ChatColorType.NORMAL) .append("Slayer Task: ") .append(ChatColorType.HIGHLIGHT) .append(sb.toString()) .build(); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }
Example 2
Source File: ChatCommandsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void killCountLookup(ChatMessage chatMessage, String message) { if (!config.killcount()) { return; } if (message.length() <= KILLCOUNT_COMMAND_STRING.length()) { return; } ChatMessageType type = chatMessage.getType(); String search = message.substring(KILLCOUNT_COMMAND_STRING.length() + 1); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = Text.sanitize(chatMessage.getName()); } search = longBossName(search); final int kc; try { kc = chatClient.getKc(player, search); } catch (IOException ex) { log.debug("unable to lookup killcount", ex); return; } String response = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append(search) .append(ChatColorType.NORMAL) .append(" kill count: ") .append(ChatColorType.HIGHLIGHT) .append(Integer.toString(kc)) .build(); log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }
Example 3
Source File: RaidsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void lookupRaid(ChatMessage chatMessage, String s) { ChatMessageType type = chatMessage.getType(); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = sanitize(chatMessage.getName()); } LayoutRoom[] layout; try { layout = chatClient.getLayout(player); } catch (IOException ex) { log.debug("unable to lookup layout", ex); return; } if (layout == null || layout.length == 0) { return; } String layoutMessage = Joiner.on(", ").join(Arrays.stream(layout) .map(l -> RaidRoom.valueOf(l.name())) .filter(room -> room.getType() == RoomType.COMBAT || room.getType() == RoomType.PUZZLE) .map(RaidRoom::getName) .toArray()); String response = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append("Layout: ") .append(ChatColorType.NORMAL) .append(layoutMessage) .build(); log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }
Example 4
Source File: SlayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
void taskLookup(ChatMessage chatMessage, String message) { if (!config.taskCommand()) { return; } ChatMessageType type = chatMessage.getType(); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = Text.removeTags(chatMessage.getName()) .replace('\u00A0', ' '); } net.runelite.http.api.chat.Task task; try { task = chatClient.getTask(player); } catch (IOException ex) { log.debug("unable to lookup slayer task", ex); return; } if (TASK_STRING_VALIDATION.matcher(task.getTask()).find() || task.getTask().length() > TASK_STRING_MAX_LENGTH || TASK_STRING_VALIDATION.matcher(task.getLocation()).find() || task.getLocation().length() > TASK_STRING_MAX_LENGTH || Task.getTask(task.getTask()) == null || !Task.LOCATIONS.contains(task.getLocation())) { log.debug("Validation failed for task name or location: {}", task); return; } int killed = task.getInitialAmount() - task.getAmount(); StringBuilder sb = new StringBuilder(); sb.append(task.getTask()); if (!Strings.isNullOrEmpty(task.getLocation())) { sb.append(" (").append(task.getLocation()).append(")"); } sb.append(": "); if (killed < 0) { sb.append(task.getAmount()).append(" left"); } else { sb.append(killed).append('/').append(task.getInitialAmount()).append(" killed"); } String response = new ChatMessageBuilder() .append(ChatColorType.NORMAL) .append("Slayer Task: ") .append(ChatColorType.HIGHLIGHT) .append(sb.toString()) .build(); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }
Example 5
Source File: ChatCommandsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void killCountLookup(ChatMessage chatMessage, String message) { if (!config.killcount()) { return; } if (message.length() <= KILLCOUNT_COMMAND_STRING.length()) { return; } ChatMessageType type = chatMessage.getType(); String search = message.substring(KILLCOUNT_COMMAND_STRING.length() + 1); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = Text.sanitize(chatMessage.getName()); } search = longBossName(search); final int kc; try { kc = chatClient.getKc(player, search); } catch (IOException ex) { log.debug("unable to lookup killcount", ex); return; } String response = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append(search) .append(ChatColorType.NORMAL) .append(" kill count: ") .append(ChatColorType.HIGHLIGHT) .append(Integer.toString(kc)) .build(); log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }
Example 6
Source File: RaidsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void lookupRaid(ChatMessage chatMessage, String s) { ChatMessageType type = chatMessage.getType(); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = sanitize(chatMessage.getName()); } LayoutRoom[] layout; try { layout = chatClient.getLayout(player); } catch (IOException ex) { log.debug("unable to lookup layout", ex); return; } if (layout == null || layout.length == 0) { return; } String layoutMessage = Joiner.on(", ").join(Arrays.stream(layout) .map(l -> RaidRoom.valueOf(l.name())) .filter(room -> room.getType() == RoomType.COMBAT || room.getType() == RoomType.PUZZLE) .map(RaidRoom::getName) .toArray()); if (layoutMessage.length() > MAX_LAYOUT_LEN) { log.debug("layout message too long! {}", layoutMessage.length()); return; } String response = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) .append("Layout: ") .append(ChatColorType.NORMAL) .append(layoutMessage) .build(); log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }