TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java

49 lines
1.7 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
2013-05-26 15:23:11 +00:00
import com.earth2me.essentials.Console;
import com.earth2me.essentials.User;
2013-06-08 21:31:19 +00:00
import com.earth2me.essentials.utils.FormatUtil;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
import java.util.List;
2015-04-15 04:06:16 +00:00
import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
public class Commandhelpop extends EssentialsCommand {
public Commandhelpop() {
super("helpop");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
user.setDisplayNick();
final String message = sendMessage(server, user.getSource(), user.getDisplayName(), args);
if (!user.isAuthorized("essentials.helpop.receive")) {
user.sendMessage(message);
}
}
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
sendMessage(server, sender, Console.NAME, args);
}
2015-04-15 04:06:16 +00:00
private String sendMessage(final Server server, final CommandSource sender, final String from, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
final String message = tl("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0)));
server.getLogger().log(Level.INFO, message);
ess.broadcastMessage("essentials.helpop.receive", message);
return message;
}
@Override
protected List<String> getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) {
return null; // Use vanilla handler for message
}
}