mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 18:14:38 +02:00
Stripping vanilla colours from /msg
This commit is contained in:
@@ -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 java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -34,11 +35,11 @@ public class Commandmsg extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = getFinalArg(args, 1);
|
final String message = Util.stripColor(getFinalArg(args, 1));
|
||||||
String translatedMe = _("me");
|
final String translatedMe = _("me");
|
||||||
|
|
||||||
IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
|
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
|
||||||
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase(Console.NAME))
|
if (args[0].equalsIgnoreCase(Console.NAME))
|
||||||
{
|
{
|
||||||
@@ -50,38 +51,38 @@ public class Commandmsg extends EssentialsCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Player> matches = server.matchPlayer(args[0]);
|
final List<Player> matchedPlayers = server.matchPlayer(args[0]);
|
||||||
|
|
||||||
if (matches.isEmpty())
|
if (matchedPlayers.isEmpty())
|
||||||
{
|
{
|
||||||
throw new Exception(_("playerNotFound"));
|
throw new Exception(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Player p : matches)
|
for (Player matchedPlayer : matchedPlayers)
|
||||||
{
|
{
|
||||||
final User u = ess.getUser(p);
|
final User u = ess.getUser(matchedPlayer);
|
||||||
if (u.isHidden())
|
if (u.isHidden())
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == matches.size())
|
if (i == matchedPlayers.size())
|
||||||
{
|
{
|
||||||
throw new Exception(_("playerNotFound"));
|
throw new Exception(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : matches)
|
for (Player matchedPlayer : matchedPlayers)
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("msgFormat", translatedMe, p.getDisplayName(), message));
|
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
|
||||||
final User u = ess.getUser(p);
|
final User matchedUser = ess.getUser(matchedPlayer);
|
||||||
if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden()))
|
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p.sendMessage(_("msgFormat", senderName, translatedMe, message));
|
matchedPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message));
|
||||||
replyTo.setReplyTo(ess.getUser(p));
|
replyTo.setReplyTo(ess.getUser(matchedPlayer));
|
||||||
ess.getUser(p).setReplyTo(sender);
|
ess.getUser(matchedPlayer).setReplyTo(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,7 +125,10 @@ public abstract class EssentialsChatPlayer extends PlayerListener
|
|||||||
if (!user.equals(sender))
|
if (!user.equals(sender))
|
||||||
{
|
{
|
||||||
final Location playerLoc = user.getLocation();
|
final Location playerLoc = user.getLocation();
|
||||||
if (playerLoc.getWorld() != world) { continue; }
|
if (playerLoc.getWorld() != world)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final double delta = playerLoc.distanceSquared(loc);
|
final double delta = playerLoc.distanceSquared(loc);
|
||||||
|
|
||||||
if (delta > radius)
|
if (delta > radius)
|
||||||
|
Reference in New Issue
Block a user