IT WORKS! Chat works! With some bugs ofc

This commit is contained in:
Norbi Peti 2016-11-25 21:05:35 +01:00
parent df75adb67a
commit 20d6cd7313
3 changed files with 11 additions and 27 deletions

View file

@ -14,9 +14,9 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import buttondevteam.discordplugin.listeners.ChatListener;
import buttondevteam.discordplugin.listeners.CommandListener;
import buttondevteam.discordplugin.listeners.ExceptionListener;
import buttondevteam.discordplugin.listeners.MCChatListener;
import buttondevteam.discordplugin.listeners.MCListener;
import buttondevteam.discordplugin.mccommands.DiscordMCCommandBase;
import buttondevteam.lib.TBMCCoreAPI;
@ -61,7 +61,9 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
dc.getDispatcher().registerListener(this);
for (IListener<?> listener : CommandListener.getListeners())
dc.getDispatcher().registerListener(listener);
dc.getDispatcher().registerListener(new ChatListener());
MCChatListener mcchat = new MCChatListener();
dc.getDispatcher().registerListener(mcchat);
TBMCCoreAPI.RegisterEventsForExceptions(mcchat, this);
Bukkit.getPluginManager().registerEvents(new ExceptionListener(), this);
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(), this);
TBMCChatAPI.AddCommands(this, DiscordMCCommandBase.class);

View file

@ -1,19 +0,0 @@
package buttondevteam.discordplugin.listeners;
import buttondevteam.discordplugin.DiscordPlugin;
import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
public class ChatListener implements IListener<MessageReceivedEvent> {
@Override
public void handle(MessageReceivedEvent event) {
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID()))
return;
if (event.getMessage().getContent().startsWith("/"))
; // Call API method
else
;
}
}

View file

@ -20,6 +20,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
@Override
public void handle(MessageReceivedEvent event) {
if (event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID()))
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, Bukkit.getConsoleSender(), event.getMessage().getContent());
}
}