mirror of
https://github.com/essentials/Essentials.git
synced 2025-02-25 08:52:40 +01:00
New feature allows a user to ignore other players
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1474 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
e78ed3ad5d
commit
bdc72d1ae5
@ -451,7 +451,7 @@ public class Essentials extends JavaPlugin
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
sender.sendMessage(command.getUsage());
|
||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@ -663,4 +663,18 @@ public class Essentials extends JavaPlugin
|
||||
{
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public int broadcastMessage(String name, String message) {
|
||||
Player[] players = getServer().getOnlinePlayers();
|
||||
|
||||
for (Player player : players) {
|
||||
User u = getUser(player);
|
||||
if (!u.isIgnoredPlayer(name))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
return players.length;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
@ -56,6 +58,15 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.setCancelled(true);
|
||||
logger.info(Util.format("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -415,18 +415,18 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public boolean isIgnoredPlayer(String name)
|
||||
{
|
||||
return ignoredPlayers.contains(name);
|
||||
return ignoredPlayers.contains(name.toLowerCase());
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(String name, boolean set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ignoredPlayers.add(name);
|
||||
ignoredPlayers.add(name.toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(name);
|
||||
ignoredPlayers.remove(name.toLowerCase());
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ public class Commandafk extends EssentialsCommand
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
server.broadcastMessage(Util.format("userIsNotAway", user.getDisplayName()));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
} else {
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
server.broadcastMessage(Util.format("userIsAway", user.getDisplayName()));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ public class Commandantioch extends EssentialsCommand
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
server.broadcastMessage("...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
server.broadcastMessage("who being naughty in My sight, shall snuff it.");
|
||||
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
|
||||
|
||||
Location loc = user.getLocation();
|
||||
World world = ((CraftWorld)user.getWorld()).getHandle();
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
@ -21,6 +23,7 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
server.broadcastMessage(Util.format("broadcast", getFinalArg(args, 0)));
|
||||
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
|
||||
Util.format("broadcast", getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandignore extends EssentialsCommand
|
||||
{
|
||||
|
||||
public Commandignore()
|
||||
{
|
||||
super("ignore");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User u;
|
||||
try
|
||||
{
|
||||
u = getPlayer(server, args, 0);
|
||||
}
|
||||
catch(NoSuchFieldException ex)
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
String name = u.getName();
|
||||
if (user.isIgnoredPlayer(name)) {
|
||||
user.setIgnoredPlayer(name, false);
|
||||
user.sendMessage(Util.format("unignorePlayer", u.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setIgnoredPlayer(name, true);
|
||||
user.sendMessage(Util.format("ignorePlayer", u.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -57,7 +57,10 @@ public class Commandmail extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
charge(user);
|
||||
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
|
||||
}
|
||||
user.sendMessage(Util.i18n("mailSent"));
|
||||
return;
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ public class Commandme extends EssentialsCommand
|
||||
message.append(' ');
|
||||
}
|
||||
charge(user);
|
||||
server.broadcastMessage("* " + user.getDisplayName() + " " + message);
|
||||
ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message);
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ public class Commandmsg extends EssentialsCommand
|
||||
charge(sender);
|
||||
for (Player p : matches)
|
||||
{
|
||||
if (sender instanceof Player && ess.getUser(p).isIgnoredPlayer(((Player)sender).getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sender.sendMessage("[" + translatedMe + " -> " + p.getDisplayName() + "§f] " + message);
|
||||
p.sendMessage("[" + senderName + " -> " + translatedMe + "§f] " + message);
|
||||
replyTo.setReplyTo(ess.getUser(p));
|
||||
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.IReplyTo;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -36,6 +37,14 @@ public class Commandr extends EssentialsCommand
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage("[" + Util.i18n("me")+ " -> " + targetName + "] " + message);
|
||||
if (target instanceof Player)
|
||||
{
|
||||
User u = ess.getUser(target);
|
||||
if (u.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
target.sendMessage("[" + senderName + " -> " + Util.i18n("me") +"] " + message);
|
||||
replyTo.setReplyTo(target);
|
||||
if (target != sender)
|
||||
|
@ -18,6 +18,7 @@ public class Commandsuicide extends EssentialsCommand
|
||||
charge(user);
|
||||
user.setHealth(0);
|
||||
user.sendMessage(Util.i18n("suicideMessage"));
|
||||
server.broadcastMessage(Util.format("suicideSuccess",user.getDisplayName()));
|
||||
ess.broadcastMessage(user.getName(),
|
||||
Util.format("suicideSuccess",user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,13 @@ public class Commandtpa extends EssentialsCommand
|
||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
||||
}
|
||||
player.charge(this);
|
||||
p.requestTeleport(player, false);
|
||||
p.sendMessage(Util.format("teleportRequest", player.getDisplayName()));
|
||||
p.sendMessage(Util.i18n("typeTpaccept"));
|
||||
p.sendMessage(Util.i18n("typeTpdeny"));
|
||||
if (!p.isIgnoredPlayer(player.getName()))
|
||||
{
|
||||
p.requestTeleport(player, false);
|
||||
p.sendMessage(Util.format("teleportRequest", player.getDisplayName()));
|
||||
p.sendMessage(Util.i18n("typeTpaccept"));
|
||||
p.sendMessage(Util.i18n("typeTpdeny"));
|
||||
}
|
||||
player.sendMessage(Util.format("requestSent", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@ -299,4 +299,6 @@ possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}.
|
||||
typeWorldName = \u00a77You can also type the name of a specific world.
|
||||
worth = \u00a77Stack of {0} worth \u00a7c{1}\u00a77 ({2} item(s) at {3} each)
|
||||
worthMeta = \u00a77Stack of {0} with metadata of {1} worth \u00a7c{2}\u00a77 ({3} item(s) at {4} each)
|
||||
onlyPlayers = Only in-game players can use {0}.
|
||||
onlyPlayers = Only in-game players can use {0}.
|
||||
unignorePlayer = You are not ignoring player {0} anymore.
|
||||
ignorePlayer = You ignore player {0} from now on.
|
@ -300,3 +300,5 @@ typeWorldName = \u00a77You can also type the name of a specific world.
|
||||
worth = \u00a77Stack of {0} worth \u00a7c{1}\u00a77 ({2} item(s) at {3} each)
|
||||
worthMeta = \u00a77Stack of {0} with metadata of {1} worth \u00a7c{2}\u00a77 ({3} item(s) at {4} each)
|
||||
onlyPlayers = Only in-game players can use {0}.
|
||||
unignorePlayer = You are not ignoring player {0} anymore.
|
||||
ignorePlayer = You ignore player {0} from now on.
|
@ -107,6 +107,10 @@ commands:
|
||||
description: Teleport to your home.
|
||||
usage: /<command> <player>
|
||||
aliases: [ehome]
|
||||
ignore:
|
||||
description: Ignore other players.
|
||||
usage: /<command> <player>
|
||||
aliases: [eignore]
|
||||
info:
|
||||
description: Shows information set by the server owner
|
||||
usage: /<command> [chapter] [page]
|
||||
|
Loading…
x
Reference in New Issue
Block a user