Added partial support for private channels and fixed response location
This commit is contained in:
parent
f338c815f1
commit
276ab40760
2 changed files with 16 additions and 4 deletions
|
@ -12,16 +12,26 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
|
|||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import sx.blah.discord.handle.obj.IChannel;
|
||||
import sx.blah.discord.handle.obj.IUser;
|
||||
|
||||
public class DiscordSender implements CommandSender {
|
||||
private PermissibleBase perm = new PermissibleBase(this);
|
||||
private IUser user;
|
||||
private IChannel channel;
|
||||
|
||||
public DiscordSender(IUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public IChannel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(IChannel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String name) {
|
||||
return perm.isPermissionSet(name);
|
||||
|
@ -78,18 +88,18 @@ public class DiscordSender implements CommandSender {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() { //TODO: Connect with TBMC acc
|
||||
public boolean isOp() { // TODO: Connect with TBMC acc
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) { //TODO: Connect with TBMC acc
|
||||
public void setOp(boolean value) { // TODO: Connect with TBMC acc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
try {
|
||||
DiscordPlugin.sendMessageToChannel(user.getOrCreatePMChannel(), message);
|
||||
DiscordPlugin.sendMessageToChannel(channel, message);
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", e);
|
||||
}
|
||||
|
|
|
@ -27,9 +27,11 @@ 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()))
|
||||
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())
|
||||
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
||||
return;
|
||||
final DiscordSender dsender = new DiscordSender(event.getMessage().getAuthor());
|
||||
dsender.setChannel(event.getMessage().getChannel());
|
||||
if (event.getMessage().getContent().startsWith("/")) {
|
||||
final String cmd = event.getMessage().getContent().substring(1);
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue