Merged Message Methods

This commit is contained in:
Olof Larsson 2015-09-03 09:32:42 +02:00
parent c8a7e9401f
commit 7b5f6acd1b
17 changed files with 205 additions and 301 deletions

View File

@ -39,7 +39,7 @@ public class DeprecatedCommand extends MassiveCommand
public void perform() public void perform()
{ {
msg("<i>Use this new command instead:"); msg("<i>Use this new command instead:");
sendMessage(target.getUseageTemplate(true)); message(target.getUseageTemplate(true));
} }
} }

View File

@ -56,7 +56,7 @@ public class HelpCommand extends MassiveCommand
} }
// Send Lines // Send Lines
sendMessage(Txt.getPage(lines, page, "Help for command \"" + parentCommand.getAliases().get(0) + "\"", sender)); message(Txt.getPage(lines, page, "Help for command \"" + parentCommand.getAliases().get(0) + "\"", sender));
} }
} }

View File

@ -1099,24 +1099,7 @@ public class MassiveCommand
// MESSAGE SENDING HELPERS // MESSAGE SENDING HELPERS
// -------------------------------------------- // // -------------------------------------------- //
// CONVENIENCE SEND MESSAGE // MSG
public boolean sendMessage(String message)
{
return Mixin.messageOne(this.sender, message);
}
public boolean sendMessage(String... messages)
{
return Mixin.messageOne(this.sender, messages);
}
public boolean sendMessage(Collection<String> messages)
{
return Mixin.messageOne(this.sender, messages);
}
// CONVENIENCE MSG
public boolean msg(String msg) public boolean msg(String msg)
{ {
@ -1133,21 +1116,21 @@ public class MassiveCommand
return Mixin.msgOne(this.sender, msgs); return Mixin.msgOne(this.sender, msgs);
} }
// CONVENIENCE RAW // MESSAGE
public boolean sendRaw(Mson mson) public boolean message(Object message)
{ {
return Mixin.messageRawOne(this.sender, mson); return Mixin.messageOne(this.sender, message);
} }
public boolean sendRaw(Mson... mson) public boolean message(Object... messages)
{ {
return Mixin.messageRawOne(this.sender, mson); return Mixin.messageOne(this.sender, messages);
} }
public boolean sendRaw(Collection<Mson> mson) public boolean message(Collection<?> messages)
{ {
return Mixin.messageRawOne(this.sender, mson); return Mixin.messageOne(this.sender, messages);
} }
// CONVENIENCE MSON // CONVENIENCE MSON

View File

@ -82,12 +82,12 @@ public class VersionCommand extends MassiveCommand
public void sendTitle() public void sendTitle()
{ {
sendMessage(Txt.titleize("Plugin Version & Information")); message(Txt.titleize("Plugin Version & Information"));
} }
public void sendEntry(String key, String value) public void sendEntry(String key, String value)
{ {
sendMessage(Txt.parse("<pink>%s: <aqua>%s", Txt.upperCaseFirst(key), value == null ? NOT_SPECIFIED : value)); message(Txt.parse("<pink>%s: <aqua>%s", Txt.upperCaseFirst(key), value == null ? NOT_SPECIFIED : value));
} }
} }

View File

@ -35,7 +35,7 @@ public class CmdMassiveCoreBufferPrint extends MassiveCommand
} }
msg("<i>Printing your buffer on the line below:"); msg("<i>Printing your buffer on the line below:");
sendMessage(buffer); message(buffer);
} }
} }

View File

@ -78,7 +78,7 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand
message += Txt.parse(" <i>(%d documents)", coll.getIds().size()); message += Txt.parse(" <i>(%d documents)", coll.getIds().size());
} }
sendMessage(message); message(message);
} }
} }

View File

@ -40,7 +40,7 @@ public class CmdMassiveCoreTest extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
sendRaw(mson("This is your ", mson("item").tooltip(me.getItemInHand()))); message(mson("This is your ", mson("item").tooltip(me.getItemInHand())));
// OLD STUFF // OLD STUFF
/*// Args /*// Args
ParticleEffect particleEffect = this.readArg(); ParticleEffect particleEffect = this.readArg();

View File

@ -50,7 +50,7 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
} }
// Send them // Send them
this.sendMessage(Txt.getPage(lines, page, "Aspect List", sender)); this.message(Txt.getPage(lines, page, "Aspect List", sender));
} }
} }

View File

@ -49,7 +49,7 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
} }
// Send them // Send them
this.sendMessage(Txt.getPage(lines, page, "Multiverse List", sender)); this.message(Txt.getPage(lines, page, "Multiverse List", sender));
} }
} }

View File

@ -5,39 +5,20 @@ import java.util.Collection;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.Predictate; import com.massivecraft.massivecore.Predictate;
import com.massivecraft.massivecore.mson.Mson;
public interface MessageMixin public interface MessageMixin
{ {
// -------------------------------------------- // // -------------------------------------------- //
// MESSAGE // MSG
// -------------------------------------------- //
// All
public boolean messageAll(String message);
public boolean messageAll(String... messages);
public boolean messageAll(Collection<String> messages);
// Predictate
public boolean messagePredictate(Predictate<CommandSender> predictate, String message);
public boolean messagePredictate(Predictate<CommandSender> predictate, String... messages);
public boolean messagePredictate(Predictate<CommandSender> predictate, Collection<String> messages);
// One
public boolean messageOne(Object sendeeObject, String message);
public boolean messageOne(Object sendeeObject, String... messages);
public boolean messageOne(Object sendeeObject, Collection<String> messages);
// -------------------------------------------- //
// PARSE MSG
// -------------------------------------------- // // -------------------------------------------- //
// All implemented in abstract!
// All // All
public boolean msgAll(String msg); public boolean msgAll(String msg);
public boolean msgAll(String msg, Object... args); public boolean msgAll(String msg, Object... args);
public boolean msgAll(Collection<String> msgs); public boolean msgAll(Collection<String> msgs);
// Predictate // Predicate
public boolean msgPredictate(Predictate<CommandSender> predictate, String msg); public boolean msgPredictate(Predictate<CommandSender> predictate, String msg);
public boolean msgPredictate(Predictate<CommandSender> predictate, String msg, Object... args); public boolean msgPredictate(Predictate<CommandSender> predictate, String msg, Object... args);
public boolean msgPredictate(Predictate<CommandSender> predictate, Collection<String> msgs); public boolean msgPredictate(Predictate<CommandSender> predictate, Collection<String> msgs);
@ -48,22 +29,22 @@ public interface MessageMixin
public boolean msgOne(Object sendeeObject, Collection<String> msgs); public boolean msgOne(Object sendeeObject, Collection<String> msgs);
// -------------------------------------------- // // -------------------------------------------- //
// RAW MESSAGE // MESSAGE
// -------------------------------------------- // // -------------------------------------------- //
// All // All
public boolean messageRawAll(Mson mson); public boolean messageAll(Object message);
public boolean messageRawAll(Mson... msons); public boolean messageAll(Object... messages);
public boolean messageRawAll(Collection<Mson> msons); public boolean messageAll(Collection<?> messages);
// Predictate // Predicate
public boolean messageRawPredictate(Predictate<CommandSender> predictate, Mson mson); public boolean messagePredictate(Predictate<CommandSender> predictate, Object message);
public boolean messageRawPredictate(Predictate<CommandSender> predictate, Mson... msons); public boolean messagePredictate(Predictate<CommandSender> predictate, Object... messages);
public boolean messageRawPredictate(Predictate<CommandSender> predictate, Collection<Mson> msons); public boolean messagePredictate(Predictate<CommandSender> predictate, Collection<?> messages);
// One // One
public boolean messageRawOne(Object sendeeObject, Mson mson); public boolean messageOne(Object sendeeObject, Object message);
public boolean messageRawOne(Object sendeeObject, Mson... msons); public boolean messageOne(Object sendeeObject, Object... messages);
public boolean messageRawOne(Object sendeeObject, Collection<Mson> msons); public boolean messageOne(Object sendeeObject, Collection<?> messages);
} }

View File

@ -7,58 +7,14 @@ import java.util.Collections;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.Predictate; import com.massivecraft.massivecore.Predictate;
import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public abstract class MessageMixinAbstract implements MessageMixin public abstract class MessageMixinAbstract implements MessageMixin
{ {
// -------------------------------------------- // // -------------------------------------------- //
// MESSAGE // MSG STRING
// -------------------------------------------- // // -------------------------------------------- //
// All implemented in abstract!
// All
@Override
public boolean messageAll(String message)
{
return this.messageAll(Collections.singleton(message));
}
@Override
public boolean messageAll(String... messages)
{
return this.messageAll(Arrays.asList(messages));
}
// Predictate
@Override
public boolean messagePredictate(Predictate<CommandSender> predictate, String message)
{
return this.messagePredictate(predictate, Collections.singleton(message));
}
@Override
public boolean messagePredictate(Predictate<CommandSender> predictate, String... messages)
{
return this.messagePredictate(predictate, Arrays.asList(messages));
}
// One
@Override
public boolean messageOne(Object sendeeObject, String message)
{
return this.messageOne(sendeeObject, Collections.singleton(message));
}
@Override
public boolean messageOne(Object sendeeObject, String... messages)
{
return this.messageOne(sendeeObject, Arrays.asList(messages));
}
// -------------------------------------------- //
// PARSE MSG
// -------------------------------------------- //
// They are all in abstract!
// All // All
@Override @Override
@ -118,46 +74,46 @@ public abstract class MessageMixinAbstract implements MessageMixin
} }
// -------------------------------------------- // // -------------------------------------------- //
// RAW MESSAGE // MESSAGE
// -------------------------------------------- // // -------------------------------------------- //
// All // All
@Override @Override
public boolean messageRawAll(Mson mson) public boolean messageAll(Object message)
{ {
return this.messageRawAll(Arrays.asList(mson)); return this.messageAll(Collections.singleton(message));
} }
@Override @Override
public boolean messageRawAll(Mson... msons) public boolean messageAll(Object... messages)
{ {
return this.messageRawAll(Arrays.asList(msons)); return this.messageAll(Arrays.asList(messages));
} }
// Predictate // Predicate
@Override @Override
public boolean messageRawPredictate(Predictate<CommandSender> predictate, Mson mson) public boolean messagePredictate(Predictate<CommandSender> predictate, Object message)
{ {
return this.messageRawPredictate(predictate, Arrays.asList(mson)); return this.messagePredictate(predictate, Collections.singleton(message));
} }
@Override @Override
public boolean messageRawPredictate(Predictate<CommandSender> predictate, Mson... msons) public boolean messagePredictate(Predictate<CommandSender> predictate, Object... messages)
{ {
return this.messageRawPredictate(predictate, Arrays.asList(msons)); return this.messagePredictate(predictate, Arrays.asList(messages));
} }
// One // One
@Override @Override
public boolean messageRawOne(Object sendeeObject, Mson mson) public boolean messageOne(Object sendeeObject, Object message)
{ {
return this.messageRawOne(sendeeObject, Arrays.asList(mson)); return this.messageOne(sendeeObject, Collections.singleton(message));
} }
@Override @Override
public boolean messageRawOne(Object sendeeObject, Mson... msons) public boolean messageOne(Object sendeeObject, Object... messages)
{ {
return this.messageRawOne(sendeeObject, Arrays.asList(msons)); return this.messageOne(sendeeObject, Arrays.asList(messages));
} }
} }

View File

@ -20,79 +20,81 @@ public class MessageMixinDefault extends MessageMixinAbstract
public static MessageMixinDefault get() { return i; } public static MessageMixinDefault get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE // MESSAGE
// -------------------------------------------- // // -------------------------------------------- //
// All
// NOTE: Targets messageOne
@Override @Override
public boolean messageAll(Collection<String> messages) public boolean messageAll(Collection<?> messages)
{ {
// Check Messages
if (messages == null) return false; if (messages == null) return false;
if (messages.isEmpty()) return false;
// Here
for (CommandSender sender : IdUtil.getLocalSenders()) for (CommandSender sender : IdUtil.getLocalSenders())
{ {
this.messageOne(sender, messages); this.messageOne(sender, messages);
} }
// Return
return true; return true;
} }
// Predicate
// NOTE: Targets messageOne
@Override @Override
public boolean messagePredictate(Predictate<CommandSender> predictate, Collection<String> messages) public boolean messagePredictate(Predictate<CommandSender> predictate, Collection<?> messages)
{ {
// Check Predicate
if (predictate == null) return false; if (predictate == null) return false;
// Check Messages
if (messages == null) return false; if (messages == null) return false;
if (messages.isEmpty()) return false;
// Here
for (CommandSender sender : IdUtil.getLocalSenders()) for (CommandSender sender : IdUtil.getLocalSenders())
{ {
if (!predictate.apply(sender)) continue; if (!predictate.apply(sender)) continue;
this.messageOne(sender, messages); this.messageOne(sender, messages);
} }
// Return
return true; return true;
} }
// One
// NOTE: The core implementation
@SuppressWarnings("unchecked")
@Override @Override
public boolean messageOne(Object sendeeObject, Collection<String> messages) public boolean messageOne(Object sendeeObject, Collection<?> messages)
{ {
// Check Sendee
CommandSender sendee = IdUtil.getSender(sendeeObject); CommandSender sendee = IdUtil.getSender(sendeeObject);
if (sendee == null) return false; if (sendee == null) return false;
// Check Messages
if (messages == null) return false; if (messages == null) return false;
sendee.sendMessage(messages.toArray(new String[0])); if (messages.isEmpty()) return false;
// Type Switch
Object first = messages.iterator().next();
if (first instanceof String)
{
// String
Collection<String> strings = (Collection<String>) messages;
sendee.sendMessage(strings.toArray(new String[0]));
return true; return true;
} }
else if (first instanceof Mson)
// Raw message aka. JsonString
@Override
public boolean messageRawAll(Collection<Mson> msons)
{ {
if (msons == null) return false; // Mson
for (CommandSender sender : IdUtil.getLocalSenders()) Collection<Mson> msons = (Collection<Mson>) messages;
if (sendee instanceof Player && NmsPacket.get().isAvailable())
{ {
this.messageRawOne(sender, msons); Player player = (Player) sendee;
}
return true;
}
@Override
public boolean messageRawPredictate(Predictate<CommandSender> predictate, Collection<Mson> msons)
{
if (predictate == null) return false;
if (msons == null) return false;
for (CommandSender sender : IdUtil.getLocalSenders())
{
if ( ! predictate.apply(sender)) continue;
this.messageRawOne(sender, msons);
}
return true;
}
@Override
public boolean messageRawOne(Object sendeeObject, Collection<Mson> msons)
{
if (msons == null) return false;
CommandSender sender = IdUtil.getSender(sendeeObject);
if (sender == null) return false;
if (sender instanceof Player && NmsPacket.get().isAvailable())
{
Player player = (Player) sender;
for (Mson mson : msons) for (Mson mson : msons)
{ {
NmsPacket.sendRaw(player, mson.toRaw()); NmsPacket.sendRaw(player, mson.toRaw());
@ -102,11 +104,15 @@ public class MessageMixinDefault extends MessageMixinAbstract
{ {
for (Mson mson : msons) for (Mson mson : msons)
{ {
sender.sendMessage(mson.toPlain(true)); sendee.sendMessage(mson.toPlain(true));
} }
} }
return true; return true;
} }
else
{
throw new IllegalArgumentException("The messages must be either String or Mson.");
}
}
} }

View File

@ -234,130 +234,100 @@ public class Mixin
// STATIC EXPOSE: MESSAGE // STATIC EXPOSE: MESSAGE
// -------------------------------------------- // // -------------------------------------------- //
// All // MSG: All
public static boolean messageAll(String message)
{
return getMessageMixin().messageAll(message);
}
public static boolean messageAll(String... messages)
{
return getMessageMixin().messageAll(messages);
}
public static boolean messageAll(Collection<String> messages)
{
return getMessageMixin().messageAll(messages);
}
// Predictate
public static boolean messagePredictate(Predictate<CommandSender> predictate, String message)
{
return getMessageMixin().messagePredictate(predictate, message);
}
public static boolean messagePredictate(Predictate<CommandSender> predictate, String... messages)
{
return getMessageMixin().messagePredictate(predictate, messages);
}
public static boolean messagePredictate(Predictate<CommandSender> predictate, Collection<String> messages)
{
return getMessageMixin().messagePredictate(predictate, messages);
}
// One
public static boolean messageOne(Object senderObject, String message)
{
return getMessageMixin().messageOne(senderObject, message);
}
public static boolean messageOne(Object senderObject, String... messages)
{
return getMessageMixin().messageOne(senderObject, messages);
}
public static boolean messageOne(Object senderObject, Collection<String> messages)
{
return getMessageMixin().messageOne(senderObject, messages);
}
// All
public static boolean msgAll(String msg) public static boolean msgAll(String msg)
{ {
return getMessageMixin().msgAll(msg); return getMessageMixin().msgAll(msg);
} }
public static boolean msgAll(String msg, Object... args) public static boolean msgAll(String msg, Object... args)
{ {
return getMessageMixin().msgAll(msg, args); return getMessageMixin().msgAll(msg, args);
} }
public static boolean msgAll(Collection<String> msgs) public static boolean msgAll(Collection<String> msgs)
{ {
return getMessageMixin().msgAll(msgs); return getMessageMixin().msgAll(msgs);
} }
// Predictate // MSG: Predicate
public static boolean msgPredictate(Predictate<CommandSender> predictate, String msg) public static boolean msgPredictate(Predictate<CommandSender> predictate, String msg)
{ {
return getMessageMixin().msgPredictate(predictate, msg); return getMessageMixin().msgPredictate(predictate, msg);
} }
public static boolean msgPredictate(Predictate<CommandSender> predictate, String msg, Object... args) public static boolean msgPredictate(Predictate<CommandSender> predictate, String msg, Object... args)
{ {
return getMessageMixin().msgPredictate(predictate, msg, args); return getMessageMixin().msgPredictate(predictate, msg, args);
} }
public static boolean msgPredictate(Predictate<CommandSender> predictate, Collection<String> msgs) public static boolean msgPredictate(Predictate<CommandSender> predictate, Collection<String> msgs)
{ {
return getMessageMixin().msgPredictate(predictate, msgs); return getMessageMixin().msgPredictate(predictate, msgs);
} }
// One // MSG: One
public static boolean msgOne(Object senderObject, String msg) public static boolean msgOne(Object sendeeObject, String msg)
{ {
return getMessageMixin().msgOne(senderObject, msg); return getMessageMixin().msgOne(sendeeObject, msg);
}
public static boolean msgOne(Object senderObject, String msg, Object... args)
{
return getMessageMixin().msgOne(senderObject, msg, args);
}
public static boolean msgOne(Object senderObject, Collection<String> msgs)
{
return getMessageMixin().msgOne(senderObject, msgs);
} }
// RAW All public static boolean msgOne(Object sendeeObject, String msg, Object... args)
public static boolean messageRawAll(Mson mson)
{ {
return getMessageMixin().messageRawAll(mson); return getMessageMixin().msgOne(sendeeObject, msg, args);
}
public static boolean messageRawAll(Mson... msons)
{
return getMessageMixin().messageRawAll(msons);
}
public static boolean messageRawAll(Collection<Mson> msons)
{
return getMessageMixin().messageRawAll(msons);
} }
// RAW Predictate public static boolean msgOne(Object sendeeObject, Collection<String> msgs)
public static boolean messageRawPredictate(Predictate<CommandSender> predictate, Mson mson)
{ {
return getMessageMixin().messageRawPredictate(predictate, mson); return getMessageMixin().msgOne(sendeeObject, msgs);
}
public static boolean messageRawPredictate(Predictate<CommandSender> predictate, Mson... msons)
{
return getMessageMixin().messageRawPredictate(predictate, msons);
}
public static boolean messageRawPredictate(Predictate<CommandSender> predictate, Collection<Mson> msons)
{
return getMessageMixin().messageRawPredictate(predictate, msons);
} }
// RAW One // MESSAGE: All
public static boolean messageRawOne(Object senderObject, Mson mson) public static boolean messageAll(Object message)
{ {
return getMessageMixin().messageRawOne(senderObject, mson); return getMessageMixin().messageAll(message);
} }
public static boolean messageRawOne(Object senderObject, Mson... msons)
public static boolean messageAll(Object... messages)
{ {
return getMessageMixin().messageRawOne(senderObject, msons); return getMessageMixin().messageAll(messages);
} }
public static boolean messageRawOne(Object senderObject, Collection<Mson> msons)
public static boolean messageAll(Collection<?> messages)
{ {
return getMessageMixin().messageRawOne(senderObject, msons); return getMessageMixin().messageAll(messages);
}
// MESSAGE: Predicate
public static boolean messagePredictate(Predictate<CommandSender> predictate, Object message)
{
return getMessageMixin().messagePredictate(predictate, message);
}
public static boolean messagePredictate(Predictate<CommandSender> predictate, Object... messages)
{
return getMessageMixin().messagePredictate(predictate, messages);
}
public static boolean messagePredictate(Predictate<CommandSender> predictate, Collection<?> messages)
{
return getMessageMixin().messagePredictate(predictate, messages);
}
// MESSAGE: One
public static boolean messageOne(Object sendeeObject, Object message)
{
return getMessageMixin().messageOne(sendeeObject, message);
}
public static boolean messageOne(Object sendeeObject, Object... messages)
{
return getMessageMixin().messageOne(sendeeObject, messages);
}
public static boolean messageOne(Object sendeeObject, Collection<?> messages)
{
return getMessageMixin().messageOne(sendeeObject, messages);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -820,25 +820,25 @@ public class Mson implements Serializable
} }
// -------------------------------------------- // // -------------------------------------------- //
// SEND // MESSAGE
// -------------------------------------------- // // -------------------------------------------- //
// All // All
public boolean sendAll() public boolean messageAll()
{ {
return Mixin.messageRawAll(this); return Mixin.messageAll(this);
} }
// Predictate // Predictate
public boolean sendPredictate(Predictate<CommandSender> predictate) public boolean messagePredictate(Predictate<CommandSender> predictate)
{ {
return Mixin.messageRawPredictate(predictate, this); return Mixin.messagePredictate(predictate, this);
} }
// One // One
public boolean sendOne(Object senderObject) public boolean messageOne(Object senderObject)
{ {
return Mixin.messageRawOne(senderObject, this); return Mixin.messageOne(senderObject, this);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -36,6 +36,7 @@ public interface Pager<T>
// MSON // MSON
// -------------------------------------------- // // -------------------------------------------- //
public List<Mson> getPageMson(int number, String title, Msonifier<T> msonifier, MassiveCommand command, List<String> args); public List<Mson> getPageMson(int number, String title, MassiveCommand command, List<String> args, Msonifier<T> msonifier);
public List<Mson> getPageMson(int number, String title, MassiveCommand command, Msonifier<T> msonifier);
} }

View File

@ -13,11 +13,13 @@ public abstract class PagerAbstract<T> implements Pager<T>
// CORE // CORE
// -------------------------------------------- // // -------------------------------------------- //
@Override
public int size() public int size()
{ {
return (int) Math.ceil((double) this.getItems().size() / this.getItemsPerPage()); return (int) Math.ceil((double) this.getItems().size() / this.getItemsPerPage());
} }
@Override
public boolean isValid(int number) public boolean isValid(int number)
{ {
if (this.isEmpty()) return false; if (this.isEmpty()) return false;
@ -26,6 +28,7 @@ public abstract class PagerAbstract<T> implements Pager<T>
return true; return true;
} }
@Override
public boolean isEmpty() public boolean isEmpty()
{ {
return this.getItems().isEmpty(); return this.getItems().isEmpty();
@ -66,11 +69,13 @@ public abstract class PagerAbstract<T> implements Pager<T>
// TXT // TXT
// -------------------------------------------- // // -------------------------------------------- //
@Override
public String getMessageEmpty() public String getMessageEmpty()
{ {
return Txt.getMessageEmpty().toPlain(true); return Txt.getMessageEmpty().toPlain(true);
} }
@Override
public String getMessageInvalid() public String getMessageInvalid()
{ {
return Txt.getMessageInvalid(this.size()).toPlain(true); return Txt.getMessageInvalid(this.size()).toPlain(true);
@ -81,7 +86,7 @@ public abstract class PagerAbstract<T> implements Pager<T>
{ {
List<String> ret = new ArrayList<String>(); List<String> ret = new ArrayList<String>();
List<Mson> msons = getPageMson(number, title, new Msonifier<T>(){ List<Mson> msons = getPageMson(number, title, null, null, new Msonifier<T>(){
@Override @Override
public Mson toMson(T item, int index) public Mson toMson(T item, int index)
@ -89,7 +94,7 @@ public abstract class PagerAbstract<T> implements Pager<T>
return Mson.mson(stringifier.toString(item, index)); return Mson.mson(stringifier.toString(item, index));
} }
}, null, null); });
for (Mson mson : msons) for (Mson mson : msons)
{ {
@ -103,7 +108,8 @@ public abstract class PagerAbstract<T> implements Pager<T>
// Mson // Mson
// -------------------------------------------- // // -------------------------------------------- //
public List<Mson> getPageMson(int number, String title, Msonifier<T> msonifier, MassiveCommand command, List<String> args) @Override
public List<Mson> getPageMson(int number, String title, MassiveCommand command, List<String> args, Msonifier<T> msonifier)
{ {
List<Mson> ret = new ArrayList<Mson>(); List<Mson> ret = new ArrayList<Mson>();
@ -140,4 +146,10 @@ public abstract class PagerAbstract<T> implements Pager<T>
return ret; return ret;
} }
@Override
public List<Mson> getPageMson(int number, String title, MassiveCommand command, Msonifier<T> msonifier)
{
return this.getPageMson(number, title, command, command.getArgs(), msonifier);
}
} }

View File

@ -59,7 +59,7 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
} }
// -------------------------------------------- // // -------------------------------------------- //
// SENDER UTIL METHOD MIRRORING // TYPE
// -------------------------------------------- // // -------------------------------------------- //
// IS // IS
@ -86,7 +86,10 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
return IdUtil.getAsConsole(this.getSender()); return IdUtil.getAsConsole(this.getSender());
} }
// -------------------------------------------- //
// ONLINE / OFFLINE // ONLINE / OFFLINE
// -------------------------------------------- //
// TODO: Update with new presence enumeration?
public boolean isOnline() public boolean isOnline()
{ {
@ -113,8 +116,11 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
return Mixin.hasPlayedBefore(this.getId()); return Mixin.hasPlayedBefore(this.getId());
} }
// -------------------------------------------- //
// DISPLAY NAME // DISPLAY NAME
// -------------------------------------------- //
// TODO: Remove this one shortly.
@Deprecated @Deprecated
public String getDisplayName() public String getDisplayName()
{ {
@ -131,24 +137,11 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
return Mixin.getDisplayNameMson(this.getId(), watcherObject); return Mixin.getDisplayNameMson(this.getId(), watcherObject);
} }
// CONVENIENCE SEND MESSAGE // -------------------------------------------- //
// MSG / MESSAGE
// -------------------------------------------- //
public boolean sendMessage(String message) // MSG
{
return Mixin.messageOne(this.getId(), message);
}
public boolean sendMessage(String... messages)
{
return Mixin.messageOne(this.getId(), messages);
}
public boolean sendMessage(Collection<String> messages)
{
return Mixin.messageOne(this.getId(), messages);
}
// CONVENIENCE MSG
public boolean msg(String msg) public boolean msg(String msg)
{ {
@ -165,24 +158,26 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
return Mixin.msgOne(this.getId(), msgs); return Mixin.msgOne(this.getId(), msgs);
} }
// CONVENIENCE SEND RAW // MESSAGE
public boolean sendRaw(Mson mson) public boolean message(Object message)
{ {
return Mixin.messageRawOne(this.getId(), mson); return Mixin.messageOne(this.getId(), message);
} }
public boolean sendRaw(Mson... msons) public boolean message(Object... messages)
{ {
return Mixin.messageRawOne(this.getId(), msons); return Mixin.messageOne(this.getId(), messages);
} }
public boolean sendRaw(Collection<Mson> msons) public boolean message(Collection<?> messages)
{ {
return Mixin.messageRawOne(this.getId(), msons); return Mixin.messageOne(this.getId(), messages);
} }
// CONVENIENCE GAME-MODE // -------------------------------------------- //
// GAME-MODE
// -------------------------------------------- //
public GameMode getGameMode(GameMode def) public GameMode getGameMode(GameMode def)
{ {