82 lines
2.3 KiB
Java
82 lines
2.3 KiB
Java
/*
|
|
* Copyright (C) 2014 cnaude
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package com.cnaude.purpleirc.Commands;
|
|
|
|
import com.cnaude.purpleirc.PurpleIRC;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
/**
|
|
*
|
|
* @author cnaude
|
|
*/
|
|
public class Say implements IRCCommandInterface {
|
|
|
|
private final PurpleIRC plugin;
|
|
private final String usage = "[bot] [channel] [message]";
|
|
private final String desc = "Make the bot speak.";
|
|
private final String name = "say";
|
|
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
|
|
|
/**
|
|
*
|
|
* @param plugin
|
|
*/
|
|
public Say(PurpleIRC plugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param sender
|
|
* @param args
|
|
*/
|
|
@Override
|
|
public void dispatch(CommandSender sender, String[] args) {
|
|
if (args.length >= 4) {
|
|
String bot = plugin.botify(args[1]);
|
|
String channelName = args[2];
|
|
if (plugin.ircBots.containsKey(bot)) {
|
|
String msg = "";
|
|
for (int i = 3; i < args.length; i++) {
|
|
msg = msg + " " + args[i];
|
|
}
|
|
plugin.ircBots.get(bot).asyncIRCMessage(channelName, msg.substring(1));
|
|
} else {
|
|
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
|
|
}
|
|
} else {
|
|
sender.sendMessage(fullUsage);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String name() {
|
|
return name;
|
|
}
|
|
|
|
@Override
|
|
public String desc() {
|
|
return desc;
|
|
}
|
|
|
|
@Override
|
|
public String usage() {
|
|
return usage;
|
|
}
|
|
}
|