Handle party chat correctly
This commit is contained in:
parent
cbdce80483
commit
ff7a427787
@ -6,7 +6,8 @@ package mineplex.core.chatsnap;
|
|||||||
public enum MessageType
|
public enum MessageType
|
||||||
{
|
{
|
||||||
CHAT(0),
|
CHAT(0),
|
||||||
PM(1);
|
PM(1),
|
||||||
|
PARTY(2);
|
||||||
|
|
||||||
private final int _id;
|
private final int _id;
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ public class Snapshot implements Comparable<Snapshot>
|
|||||||
this(MessageType.PM, senderId, Collections.singletonList(recipientId), message, LocalDateTime.now());
|
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)
|
public Snapshot(MessageType messageType, int senderId, Collection<Integer> recipientIds, String message, LocalDateTime time)
|
||||||
|
@ -58,10 +58,17 @@ public class SnapshotPlugin extends MiniPlugin
|
|||||||
|
|
||||||
public Snapshot createSnapshot(AsyncPlayerChatEvent e)
|
public Snapshot createSnapshot(AsyncPlayerChatEvent e)
|
||||||
{
|
{
|
||||||
|
MessageType messageType = MessageType.CHAT;
|
||||||
int senderId = _clientManager.getAccountId(e.getPlayer());
|
int senderId = _clientManager.getAccountId(e.getPlayer());
|
||||||
Set<Integer> recipientIds = getAccountIds(e.getRecipients());
|
Set<Integer> recipientIds = getAccountIds(e.getRecipients());
|
||||||
recipientIds.remove(senderId);
|
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)
|
public Snapshot createSnapshot(PrivateMessageEvent e)
|
||||||
|
@ -7,8 +7,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionStage;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -1,29 +1,10 @@
|
|||||||
<?php class Message
|
<?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_CHAT = 0;
|
||||||
const TYPE_PM = 1;
|
const TYPE_PM = 1;
|
||||||
|
const TYPE_PARTY = 2;
|
||||||
/**
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var User */
|
/** @var User */
|
||||||
private $sender;
|
private $sender;
|
||||||
|
@ -466,6 +466,8 @@
|
|||||||
|
|
||||||
if($isPM): ?>
|
if($isPM): ?>
|
||||||
<span class="label label-primary chat pm" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
|
<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: ?>
|
<?php else: ?>
|
||||||
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
|
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user