use of com.earth2me.essentials.messaging.IMessageRecipient in project Essentials by drtshock.
the class Commandmsg method run.
@Override
public void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty()) {
throw new NotEnoughArgumentsException();
}
String message = getFinalArg(args, 1);
boolean canWildcard;
if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer());
if (user.isMuted()) {
throw new Exception(tl("voiceSilenced"));
}
message = FormatUtil.formatMessage(user, "essentials.msg", message);
canWildcard = user.isAuthorized("essentials.msg.multiple");
} else {
message = FormatUtil.replaceFormat(message);
canWildcard = true;
}
// Sending messages to console
if (args[0].equalsIgnoreCase(Console.NAME)) {
IMessageRecipient messageSender = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : Console.getInstance();
messageSender.sendMessage(Console.getInstance(), message);
return;
}
loopOnlinePlayers(server, sender, canWildcard, canWildcard, args[0], new String[] { message });
}
use of com.earth2me.essentials.messaging.IMessageRecipient in project Essentials by drtshock.
the class Commandmsg method updatePlayer.
@Override
protected void updatePlayer(final Server server, final CommandSource sender, final User messageReceiver, final String[] args) {
IMessageRecipient messageSender = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : Console.getInstance();
// args[0] is the message.
messageSender.sendMessage(messageReceiver, args[0]);
}
use of com.earth2me.essentials.messaging.IMessageRecipient in project Essentials by EssentialsX.
the class Commandr method run.
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
String message = getFinalArg(args, 0);
IMessageRecipient messageSender;
if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer());
if (user.isMuted()) {
throw new Exception(tl("voiceSilenced"));
}
message = FormatUtil.formatMessage(user, "essentials.msg", message);
messageSender = user;
} else {
message = FormatUtil.replaceFormat(message);
messageSender = Console.getInstance();
}
final IMessageRecipient target = messageSender.getReplyRecipient();
// Check to make sure the sender does have a quick-reply recipient
if (target == null) {
throw new Exception(tl("foreverAlone"));
}
messageSender.sendMessage(target, message);
}
use of com.earth2me.essentials.messaging.IMessageRecipient in project Essentials by EssentialsX.
the class Commandmsg method updatePlayer.
@Override
protected void updatePlayer(final Server server, final CommandSource sender, final User messageReceiver, final String[] args) {
IMessageRecipient messageSender = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : Console.getInstance();
// args[0] is the message.
messageSender.sendMessage(messageReceiver, args[0]);
}
use of com.earth2me.essentials.messaging.IMessageRecipient in project Essentials by drtshock.
the class Commandr method run.
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
String message = getFinalArg(args, 0);
IMessageRecipient messageSender;
if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer());
if (user.isMuted()) {
throw new Exception(tl("voiceSilenced"));
}
message = FormatUtil.formatMessage(user, "essentials.msg", message);
messageSender = user;
} else {
message = FormatUtil.replaceFormat(message);
messageSender = Console.getInstance();
}
final IMessageRecipient target = messageSender.getReplyRecipient();
// Check to make sure the sender does have a quick-reply recipient
if (target == null) {
throw new Exception(tl("foreverAlone"));
}
messageSender.sendMessage(target, message);
}
Aggregations