Fixes, added game roles, commands in mcchat, smaller additions #26

Merged
NorbiPeti merged 10 commits from dev into master 2017-04-15 12:02:57 +00:00
2 changed files with 46 additions and 1 deletions
Showing only changes of commit 519e0f468e - Show all commits

View file

@ -10,7 +10,7 @@ public abstract class DiscordCommandBase {
public abstract String getCommandName();
public abstract void run(IMessage message, String args);
public abstract String[] getHelpText();
static final HashMap<String, DiscordCommandBase> commands = new HashMap<String, DiscordCommandBase>();
@ -19,6 +19,7 @@ public abstract class DiscordCommandBase {
commands.put("connect", new ConnectCommand()); // TODO: API for adding commands?
commands.put("userinfo", new UserinfoCommand());
commands.put("help", new HelpCommand());
commands.put("role", new RoleCommand());
}
public static void runCommand(String cmd, String args, IMessage message) {

View file

@ -0,0 +1,44 @@
package buttondevteam.discordplugin.commands;
import buttondevteam.discordplugin.DiscordPlugin;
import sx.blah.discord.handle.obj.IMessage;
public class RoleCommand extends DiscordCommandBase {
@Override
public String getCommandName() {
return "role";
}
@Override
public void run(IMessage message, String args) {
final String usagemsg = "Subcommands: add, remove, list";
if (args.length() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), usagemsg);
return;
}
String[] argsa = args.split(" ");
if (argsa[0].equalsIgnoreCase("add")) {
if (argsa.length < 2) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"This command adds a game role to your account.\nUsage: add <rolename>");
return;
}
} else if (argsa[0].equalsIgnoreCase("remove")) {
if (argsa.length < 2) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"This command removes a game role from your account.\nUsage: remove <rolename>");
return;
}
} else if (argsa[0].equalsIgnoreCase("list")) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), "List of game roles:");
}
}
@Override
public String[] getHelpText() {
// TODO Auto-generated method stub
return null;
}
}