Added command support and fixed isOp

This commit is contained in:
Norbi Peti 2016-11-28 18:18:37 +01:00
parent ec5265f054
commit f338c815f1
2 changed files with 17 additions and 7 deletions

View file

@ -78,13 +78,12 @@ public class DiscordSender implements CommandSender {
} }
@Override @Override
public boolean isOp() { public boolean isOp() { //TODO: Connect with TBMC acc
return perm.isOp(); return false;
} }
@Override @Override
public void setOp(boolean value) { public void setOp(boolean value) { //TODO: Connect with TBMC acc
perm.setOp(value);
} }
@Override @Override

View file

@ -7,6 +7,7 @@ import org.bukkit.event.Listener;
import buttondevteam.discordplugin.DiscordPlugin; import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.DiscordSender; import buttondevteam.discordplugin.DiscordSender;
import buttondevteam.lib.TBMCChatEvent; import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.Channel; import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.TBMCChatAPI; import buttondevteam.lib.chat.TBMCChatAPI;
import sx.blah.discord.api.events.IListener; import sx.blah.discord.api.events.IListener;
@ -26,8 +27,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
public void handle(MessageReceivedEvent event) { public void handle(MessageReceivedEvent event) {
if (event.getMessage().getAuthor().isBot()) if (event.getMessage().getAuthor().isBot())
return; return;
if (event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())) if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID()))
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, new DiscordSender(event.getMessage().getAuthor()), return;
event.getMessage().getContent()); final DiscordSender dsender = new DiscordSender(event.getMessage().getAuthor());
if (event.getMessage().getContent().startsWith("/")) {
final String cmd = event.getMessage().getContent().substring(1);
try {
Bukkit.dispatchCommand(dsender, cmd);
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while executing command " + cmd + "!", e);
return;
}
} else
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, dsender, event.getMessage().getContent());
} }
} }