Essentials/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java

53 lines
1.5 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
2013-05-26 17:23:11 +02:00
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
2013-06-08 23:31:19 +02:00
import com.earth2me.essentials.utils.FormatUtil;
2011-11-18 18:42:26 +01:00
import org.bukkit.Server;
2013-05-26 17:23:11 +02:00
import org.bukkit.command.CommandSender;
2011-11-18 18:42:26 +01:00
import org.bukkit.entity.Player;
public class Commandhelpop extends EssentialsCommand
{
public Commandhelpop()
{
super("helpop");
}
@Override
2011-11-18 13:06:59 +01:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
2013-05-26 17:23:11 +02:00
{
user.setDisplayNick();
sendMessage(server, user.getSource(), user.getDisplayName(), args);
2013-05-26 17:23:11 +02:00
}
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
2013-05-26 17:23:11 +02:00
{
sendMessage(server, sender, Console.NAME, args);
}
private void sendMessage(final Server server, final CommandSource sender, final String from, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
2013-06-08 23:31:19 +02:00
final String message = _("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0)));
2013-05-26 17:23:11 +02:00
CommandSender cs = Console.getCommandSender(server);
cs.sendMessage(message);
2011-11-18 13:06:59 +01:00
for (Player onlinePlayer : server.getOnlinePlayers())
{
2011-11-18 13:06:59 +01:00
final User player = ess.getUser(onlinePlayer);
if (!player.isAuthorized("essentials.helpop.receive"))
{
continue;
}
2011-11-18 13:06:59 +01:00
player.sendMessage(message);
}
}
}