Handle party chat correctly

This commit is contained in:
Keir Nellyer 2016-08-10 16:57:44 +01:00
parent cbdce80483
commit ff7a427787
6 changed files with 19 additions and 30 deletions

View File

@ -6,7 +6,8 @@ package mineplex.core.chatsnap;
public enum MessageType
{
CHAT(0),
PM(1);
PM(1),
PARTY(2);
private final int _id;

View File

@ -29,9 +29,9 @@ public class Snapshot implements Comparable<Snapshot>
this(MessageType.PM, senderId, Collections.singletonList(recipientId), message, LocalDateTime.now());
}
public Snapshot(int senderId, Collection<Integer> recipientIds, String message)
public Snapshot(MessageType messageType, int senderId, Collection<Integer> recipientIds, String message)
{
this(MessageType.CHAT, senderId, recipientIds, message, LocalDateTime.now());
this(messageType, senderId, recipientIds, message, LocalDateTime.now());
}
public Snapshot(MessageType messageType, int senderId, Collection<Integer> recipientIds, String message, LocalDateTime time)

View File

@ -58,10 +58,17 @@ public class SnapshotPlugin extends MiniPlugin
public Snapshot createSnapshot(AsyncPlayerChatEvent e)
{
MessageType messageType = MessageType.CHAT;
int senderId = _clientManager.getAccountId(e.getPlayer());
Set<Integer> recipientIds = getAccountIds(e.getRecipients());
recipientIds.remove(senderId);
return new Snapshot(senderId, recipientIds, e.getMessage());
if (e.getFormat().contains("Party"))
{
messageType = MessageType.PARTY;
}
return new Snapshot(messageType, senderId, recipientIds, e.getMessage());
}
public Snapshot createSnapshot(PrivateMessageEvent e)

View File

@ -7,8 +7,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.stream.Collectors;

View File

@ -1,29 +1,10 @@
<?php class Message
{
public static $TYPE_DISPLAY_NAMES = array("Chat", "PM");
public static $TYPE_DISPLAY_NAMES = array("Chat", "PM", "Party");
const TYPE_CHAT = 0;
const TYPE_PM = 1;
/**
* @param $type
* @return int
*/
public static function getTypeFromString($type)
{
if (strcmp($type, "CHAT") == 0)
{
return self::TYPE_CHAT;
}
else if (strcmp($type, "PM") == 0)
{
return self::TYPE_PM;
}
else
{
return -1;
}
}
const TYPE_PARTY = 2;
/** @var User */
private $sender;

View File

@ -455,17 +455,19 @@
$reportCreationTime = $report->getTimeCreated();
$age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone())));
if ($displayAmount == 0): ?>
if($displayAmount == 0): ?>
<span class="black">No chat log available for this report.</span>
<?php else:
for ($i = 0; $i < $displayAmount; $i++):
for($i = 0; $i < $displayAmount; $i++):
$message = $messages[$i];
$typeId = $message->getType();
$typeDisplayName = Message::$TYPE_DISPLAY_NAMES[$typeId];
$isPM = $typeId == Message::TYPE_PM;
if ($isPM): ?>
if($isPM): ?>
<span class="label label-primary chat pm" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
<?php elseif($typeId == Message::TYPE_PARTY): ?>
<span class="label label-warning chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
<?php else: ?>
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
<?php endif; ?>