Why haven't I commited this

Only the plugin.yml and registering /discord is the current change.
This commit is contained in:
Norbi Peti 2016-10-30 23:10:02 +01:00
parent c6b831e035
commit cacb14a307
4 changed files with 14 additions and 6 deletions

View file

@ -2,9 +2,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.github.tbmcplugins</groupId> <groupId>com.github.TBMCPlugins</groupId>
<artifactId>DiscordPlugin</artifactId> <artifactId>DiscordPlugin</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>master-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>DiscordPlugin</name> <name>DiscordPlugin</name>

View file

@ -34,9 +34,12 @@ public class CommandListener {
private static void runCommand(IMessage message) { private static void runCommand(IMessage message) {
String cmdwithargs = message.getContent(); String cmdwithargs = message.getContent();
final String mention = DiscordPlugin.dc.getOurUser().mention(); final String mention = DiscordPlugin.dc.getOurUser().mention(false);
if (message.getContent().startsWith(mention)) // TODO: Resolve mentions: Compound arguments, either a mention or text final String mentionNick = DiscordPlugin.dc.getOurUser().mention(true);
cmdwithargs = cmdwithargs.substring(mention.length()); if (message.getContent().startsWith(mention) && cmdwithargs.length() > mention.length() + 1) // TODO: Resolve mentions: Compound arguments, either a mention or text
cmdwithargs = cmdwithargs.substring(mention.length() + 1);
if (message.getContent().startsWith(mentionNick) && cmdwithargs.length() > mentionNick.length() + 1)
cmdwithargs = cmdwithargs.substring(mentionNick.length() + 1);
int index = cmdwithargs.indexOf(' '); int index = cmdwithargs.indexOf(' ');
String cmd; String cmd;
String args; String args;
@ -45,7 +48,7 @@ public class CommandListener {
args = ""; args = "";
} else { } else {
cmd = cmdwithargs.substring(0, index); cmd = cmdwithargs.substring(0, index);
args = cmdwithargs.substring(index); args = cmdwithargs.substring(index + 1);
} }
DiscordCommandBase.runCommand(cmd, args, message); DiscordCommandBase.runCommand(cmd, args, message);
} }

View file

@ -14,7 +14,9 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import buttondevteam.discordplugin.mccommands.DiscordMCCommandBase;
import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.TBMCChatAPI;
import sx.blah.discord.api.*; import sx.blah.discord.api.*;
import sx.blah.discord.api.events.IListener; import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.ReadyEvent; import sx.blah.discord.handle.impl.events.ReadyEvent;
@ -54,6 +56,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
for (IListener<?> listener : CommandListener.getListeners()) for (IListener<?> listener : CommandListener.getListeners())
dc.getDispatcher().registerListener(listener); dc.getDispatcher().registerListener(listener);
Bukkit.getPluginManager().registerEvents(new MCListener(), this); Bukkit.getPluginManager().registerEvents(new MCListener(), this);
TBMCChatAPI.AddCommands(this, DiscordMCCommandBase.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);

View file

@ -3,3 +3,5 @@ main: buttondevteam.discordplugin.DiscordPlugin
version: 1.0 version: 1.0
author: TBMCPlugins author: TBMCPlugins
depend: [] depend: []
commands:
discord: