mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-04 19:46:27 +00:00
Stripping vanilla colour from /helpop and /mail
Adding support for &k in EssChat Adding support for colour in /msg and /r - New perm: essentials.msg.color
This commit is contained in:
parent
1d5a09a03e
commit
1f2c669eca
6 changed files with 51 additions and 9 deletions
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -22,7 +23,7 @@ public class Commandhelpop extends EssentialsCommand
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String message = _("helpOp", user.getDisplayName(), getFinalArg(args, 0));
|
final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
|
||||||
logger.log(Level.INFO, message);
|
logger.log(Level.INFO, message);
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
@ -58,7 +59,7 @@ public class Commandmail extends EssentialsCommand
|
||||||
}
|
}
|
||||||
if (!u.isIgnoredPlayer(user.getName()))
|
if (!u.isIgnoredPlayer(user.getName()))
|
||||||
{
|
{
|
||||||
u.addMail(user.getName() + ": " + getFinalArg(args, 2));
|
u.addMail(user.getName() + ": " + Util.stripColor(getFinalArg(args, 2)));
|
||||||
}
|
}
|
||||||
user.sendMessage(_("mailSent"));
|
user.sendMessage(_("mailSent"));
|
||||||
return;
|
return;
|
||||||
|
@ -69,7 +70,7 @@ public class Commandmail extends EssentialsCommand
|
||||||
{
|
{
|
||||||
throw new Exception(_("noPerm","essentials.mail.sendall"));
|
throw new Exception(_("noPerm","essentials.mail.sendall"));
|
||||||
}
|
}
|
||||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + getFinalArg(args, 1)));
|
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||||
user.sendMessage(_("mailSent"));
|
user.sendMessage(_("mailSent"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,8 +29,12 @@ public class Commandme extends EssentialsCommand
|
||||||
String message = getFinalArg(args, 0);
|
String message = getFinalArg(args, 0);
|
||||||
if (user.isAuthorized("essentials.chat.color"))
|
if (user.isAuthorized("essentials.chat.color"))
|
||||||
{
|
{
|
||||||
message = message.replaceAll("&([0-9a-f])", "§$1");
|
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
message = Util.stripColor(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
|
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class Commandmsg extends EssentialsCommand
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = getFinalArg(args, 1);
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
{
|
{
|
||||||
User user = ess.getUser(sender);
|
User user = ess.getUser(sender);
|
||||||
|
@ -33,9 +34,20 @@ public class Commandmsg extends EssentialsCommand
|
||||||
{
|
{
|
||||||
throw new Exception(_("voiceSilenced"));
|
throw new Exception(_("voiceSilenced"));
|
||||||
}
|
}
|
||||||
|
if (user.isAuthorized("essentials.msg.color"))
|
||||||
|
{
|
||||||
|
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = Util.stripColor(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||||
}
|
}
|
||||||
|
|
||||||
final String message = Util.stripColor(getFinalArg(args, 1));
|
|
||||||
final String translatedMe = _("me");
|
final String translatedMe = _("me");
|
||||||
|
|
||||||
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
|
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.IReplyTo;
|
import com.earth2me.essentials.IReplyTo;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -24,9 +25,31 @@ public class Commandr extends EssentialsCommand
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String message = getFinalArg(args, 0);
|
String message = getFinalArg(args, 0);
|
||||||
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
|
IReplyTo replyTo;
|
||||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
String senderName;
|
||||||
|
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
User user = ess.getUser(sender);
|
||||||
|
if (user.isAuthorized("essentials.msg.color"))
|
||||||
|
{
|
||||||
|
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = Util.stripColor(message);
|
||||||
|
}
|
||||||
|
replyTo = user;
|
||||||
|
senderName = user.getDisplayName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = message.replaceAll("&([0-9a-fk])", "§$1");
|
||||||
|
replyTo = Console.getConsoleReplyTo();
|
||||||
|
senderName = Console.NAME;
|
||||||
|
}
|
||||||
|
|
||||||
final CommandSender target = replyTo.getReplyTo();
|
final CommandSender target = replyTo.getReplyTo();
|
||||||
final String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME;
|
final String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
|
||||||
final User user = ess.getUser(event.getPlayer());
|
final User user = ess.getUser(event.getPlayer());
|
||||||
if (user.isAuthorized("essentials.chat.color"))
|
if (user.isAuthorized("essentials.chat.color"))
|
||||||
{
|
{
|
||||||
event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1"));
|
event.setMessage(event.getMessage().replaceAll("&([0-9a-fk])", "\u00a7$1"));
|
||||||
} else {
|
} else {
|
||||||
event.setMessage(Util.stripColor(event.getMessage()));
|
event.setMessage(Util.stripColor(event.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue