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
public boolean isOp() {
return perm.isOp();
public boolean isOp() { //TODO: Connect with TBMC acc
return false;
}
@Override
public void setOp(boolean value) {
perm.setOp(value);
public void setOp(boolean value) { //TODO: Connect with TBMC acc
}
@Override

View file

@ -7,6 +7,7 @@ import org.bukkit.event.Listener;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.DiscordSender;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.TBMCChatAPI;
import sx.blah.discord.api.events.IListener;
@ -26,8 +27,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
public void handle(MessageReceivedEvent event) {
if (event.getMessage().getAuthor().isBot())
return;
if (event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID()))
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, new DiscordSender(event.getMessage().getAuthor()),
event.getMessage().getContent());
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID()))
return;
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());
}
}