MassiveCore - Object Titles and Mixed Messages
This commit is contained in:
parent
e7a397668b
commit
0a297211bf
@ -67,7 +67,6 @@ public class MessageMixinDefault extends MessageMixinAbstract
|
|||||||
|
|
||||||
// One
|
// One
|
||||||
// NOTE: The core implementation
|
// NOTE: The core implementation
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public boolean messageOne(Object sendeeObject, Collection<?> messages)
|
public boolean messageOne(Object sendeeObject, Collection<?> messages)
|
||||||
{
|
{
|
||||||
@ -79,41 +78,34 @@ public class MessageMixinDefault extends MessageMixinAbstract
|
|||||||
if (messages == null) return false;
|
if (messages == null) return false;
|
||||||
if (messages.isEmpty()) return false;
|
if (messages.isEmpty()) return false;
|
||||||
|
|
||||||
// Type Switch
|
// For each Message
|
||||||
Object first = messages.iterator().next();
|
for (Object message : messages)
|
||||||
if (first instanceof String)
|
|
||||||
{
|
{
|
||||||
// String
|
if (message instanceof String)
|
||||||
Collection<String> strings = (Collection<String>) messages;
|
{
|
||||||
sendee.sendMessage(strings.toArray(new String[0]));
|
String string = (String)message;
|
||||||
return true;
|
sendee.sendMessage(string);
|
||||||
}
|
}
|
||||||
else if (first instanceof Mson)
|
else if (message instanceof Mson)
|
||||||
{
|
{
|
||||||
// Mson
|
Mson mson = (Mson)message;
|
||||||
Collection<Mson> msons = (Collection<Mson>) messages;
|
|
||||||
if (sendee instanceof Player && NmsPacket.get().isAvailable())
|
if (sendee instanceof Player && NmsPacket.get().isAvailable())
|
||||||
{
|
{
|
||||||
Player player = (Player) sendee;
|
Player player = (Player) sendee;
|
||||||
for (Mson mson : msons)
|
|
||||||
{
|
|
||||||
NmsPacket.sendRaw(player, mson.toRaw());
|
NmsPacket.sendRaw(player, mson.toRaw());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
for (Mson mson : msons)
|
|
||||||
{
|
{
|
||||||
sendee.sendMessage(mson.toPlain(true));
|
sendee.sendMessage(mson.toPlain(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String desc = first == null ? "null" : first.getClass().getSimpleName();
|
String desc = (message == null ? "null" : message.getClass().getSimpleName());
|
||||||
throw new IllegalArgumentException(desc + " is neither String nor Mson.");
|
throw new IllegalArgumentException(desc + " is neither String nor Mson.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user