From 65f84c25fe8f2642d2f8d5d5e99e7b6de6b60436 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 2 Mar 2013 15:56:11 +0100 Subject: [PATCH] new senderId sources and minor message mixin fix. --- .../mcore/mixin/MessageMixinDefault.java | 5 +--- .../SenderIdSourceMixinOnlinePlayerIds.java | 30 +++++++++++++++++++ .../SenderIdSourceMixinOnlineSenderIds.java | 30 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlinePlayerIds.java create mode 100644 src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlineSenderIds.java diff --git a/src/com/massivecraft/mcore/mixin/MessageMixinDefault.java b/src/com/massivecraft/mcore/mixin/MessageMixinDefault.java index cc9c9a41..99af186f 100644 --- a/src/com/massivecraft/mcore/mixin/MessageMixinDefault.java +++ b/src/com/massivecraft/mcore/mixin/MessageMixinDefault.java @@ -49,10 +49,7 @@ public class MessageMixinDefault extends MessageMixinAbstract { if (sendee == null) return false; if (messages == null) return false; - for (String message : messages) - { - sendee.sendMessage(message); - } + sendee.sendMessage(messages.toArray(new String[0])); return true; } diff --git a/src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlinePlayerIds.java b/src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlinePlayerIds.java new file mode 100644 index 00000000..aa2af0ac --- /dev/null +++ b/src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlinePlayerIds.java @@ -0,0 +1,30 @@ +package com.massivecraft.mcore.store; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.massivecraft.mcore.mixin.Mixin; + +public class SenderIdSourceMixinOnlinePlayerIds implements SenderIdSource +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static SenderIdSourceMixinOnlinePlayerIds i = new SenderIdSourceMixinOnlinePlayerIds(); + public static SenderIdSourceMixinOnlinePlayerIds get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public Collection> getSenderIdCollections() + { + List> ret = new ArrayList>(); + ret.add(Mixin.getOnlinePlayerIds()); + return ret; + } + +} diff --git a/src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlineSenderIds.java b/src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlineSenderIds.java new file mode 100644 index 00000000..613a81a1 --- /dev/null +++ b/src/com/massivecraft/mcore/store/SenderIdSourceMixinOnlineSenderIds.java @@ -0,0 +1,30 @@ +package com.massivecraft.mcore.store; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.massivecraft.mcore.mixin.Mixin; + +public class SenderIdSourceMixinOnlineSenderIds implements SenderIdSource +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static SenderIdSourceMixinOnlineSenderIds i = new SenderIdSourceMixinOnlineSenderIds(); + public static SenderIdSourceMixinOnlineSenderIds get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public Collection> getSenderIdCollections() + { + List> ret = new ArrayList>(); + ret.add(Mixin.getOnlineSenderIds()); + return ret; + } + +}