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 org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
import sx.blah.discord.handle.obj.IChannel;
|
||||||
import sx.blah.discord.handle.obj.IUser;
|
import sx.blah.discord.handle.obj.IUser;
|
||||||
|
|
||||||
public class DiscordSender implements CommandSender {
|
public class DiscordSender implements CommandSender {
|
||||||
private PermissibleBase perm = new PermissibleBase(this);
|
private PermissibleBase perm = new PermissibleBase(this);
|
||||||
private IUser user;
|
private IUser user;
|
||||||
|
private IChannel channel;
|
||||||
|
|
||||||
public DiscordSender(IUser user) {
|
public DiscordSender(IUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IChannel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannel(IChannel channel) {
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPermissionSet(String name) {
|
public boolean isPermissionSet(String name) {
|
||||||
return perm.isPermissionSet(name);
|
return perm.isPermissionSet(name);
|
||||||
|
@ -89,7 +99,7 @@ public class DiscordSender implements CommandSender {
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
try {
|
try {
|
||||||
DiscordPlugin.sendMessageToChannel(user.getOrCreatePMChannel(), message);
|
DiscordPlugin.sendMessageToChannel(channel, message);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", 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) {
|
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())
|
||||||
|
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
||||||
return;
|
return;
|
||||||
final DiscordSender dsender = new DiscordSender(event.getMessage().getAuthor());
|
final DiscordSender dsender = new DiscordSender(event.getMessage().getAuthor());
|
||||||
|
dsender.setChannel(event.getMessage().getChannel());
|
||||||
if (event.getMessage().getContent().startsWith("/")) {
|
if (event.getMessage().getContent().startsWith("/")) {
|
||||||
final String cmd = event.getMessage().getContent().substring(1);
|
final String cmd = event.getMessage().getContent().substring(1);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue