Fixes for mcchat

This commit is contained in:
Norbi Peti 2017-05-28 11:56:47 +02:00
parent 173bc40a1d
commit 9abb342aa9
3 changed files with 5 additions and 4 deletions

View file

@ -20,6 +20,7 @@ public abstract class DiscordCommandBase {
commands.put("userinfo", new UserinfoCommand()); commands.put("userinfo", new UserinfoCommand());
commands.put("help", new HelpCommand()); commands.put("help", new HelpCommand());
commands.put("role", new RoleCommand()); commands.put("role", new RoleCommand());
commands.put("mcchat", new MCChatCommand());
} }
public static void runCommand(String cmd, String args, IMessage message) { public static void runCommand(String cmd, String args, IMessage message) {

View file

@ -19,7 +19,7 @@ public class MCChatCommand extends DiscordCommandBase {
} }
PlayerData<Boolean> mcchat = DiscordPlayer.getUser(message.getAuthor().getStringID(), DiscordPlayer.class) PlayerData<Boolean> mcchat = DiscordPlayer.getUser(message.getAuthor().getStringID(), DiscordPlayer.class)
.minecraftChat(); .minecraftChat();
mcchat.set(!mcchat.get()); mcchat.set(!mcchat.getOrDefault(false));
message.reply("Minecraft chat " + (mcchat.get() ? "enabled." : "disabled.")); message.reply("Minecraft chat " + (mcchat.get() ? "enabled." : "disabled."));
} }

View file

@ -64,7 +64,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
final IUser iUser = data.channel.getUsersHere().stream() final IUser iUser = data.channel.getUsersHere().stream()
.filter(u -> u.getLongID() != u.getClient().getOurUser().getLongID()).findFirst().get(); // Doesn't support group DMs .filter(u -> u.getLongID() != u.getClient().getOurUser().getLongID()).findFirst().get(); // Doesn't support group DMs
final DiscordPlayer user = DiscordPlayer.getUser(iUser.getStringID(), DiscordPlayer.class); final DiscordPlayer user = DiscordPlayer.getUser(iUser.getStringID(), DiscordPlayer.class);
if (user.minecraftChat().get() && e.shouldSendTo(getSender(data.channel, iUser, user))) if (user.minecraftChat().getOrDefault(false) && e.shouldSendTo(getSender(data.channel, iUser, user)))
doit.accept(data); doit.accept(data);
} }
} // TODO: Author URL } // TODO: Author URL
@ -125,8 +125,8 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
public void handle(MessageReceivedEvent event) { public void handle(MessageReceivedEvent event) {
final IUser author = event.getMessage().getAuthor(); final IUser author = event.getMessage().getAuthor();
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID()) if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
&& !(event.getMessage().getChannel().isPrivate() && !(event.getMessage().getChannel().isPrivate() && DiscordPlayer
&& DiscordPlayer.getUser(author.getStringID(), DiscordPlayer.class).minecraftChat().get())) .getUser(author.getStringID(), DiscordPlayer.class).minecraftChat().getOrDefault(false)))
return; return;
resetLastMessage(); resetLastMessage();
lastlist++; lastlist++;