MCChat fixes

This commit is contained in:
Norbi Peti 2017-10-28 00:27:00 +02:00
parent 2308ef4195
commit 1244b50560
3 changed files with 20 additions and 16 deletions

View file

@ -87,11 +87,14 @@ public class CommandListener {
createUsableServerReadyStrings(usableServerReadyStrings);
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]);
}
if (!event.getMessage().getChannel().isPrivate() //
|| DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class)
.isMinecraftChatEnabled())
return;
}
if (!event.getMessage().getChannel().isPrivate()) //
return;
if (DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class)
.isMinecraftChatEnabled())
if (!event.getMessage().getContent().equalsIgnoreCase("mcchat"))
return;
if (event.getMessage().getAuthor().isBot())
return;
runCommand(event.getMessage(), false);

View file

@ -207,17 +207,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
* This overload sends it to the global chat.
*/
public static void sendSystemMessageToChat(String msg) {
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, msg);
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, DiscordPlugin.sanitizeString(msg));
for (LastMsgData data : lastmsgPerUser)
DiscordPlugin.sendMessageToChannel(data.channel, msg);
DiscordPlugin.sendMessageToChannel(data.channel, DiscordPlugin.sanitizeString(msg));
}
public static void sendSystemMessageToChat(TBMCSystemChatEvent event) {
if (Channel.GlobalChat.ID.equals(event.getChannel().ID))
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, event.getMessage());
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel,
DiscordPlugin.sanitizeString(event.getMessage()));
for (LastMsgData data : lastmsgPerUser)
if (event.shouldSendTo(getSender(data.channel, data.user, data.dp)))
DiscordPlugin.sendMessageToChannel(data.channel, event.getMessage());
DiscordPlugin.sendMessageToChannel(data.channel, DiscordPlugin.sanitizeString(event.getMessage()));
}
@Override // Discord
@ -229,15 +230,17 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
&& !(event.getMessage().getChannel().isPrivate() && user.isMinecraftChatEnabled()))
return;
if (author.isBot())
return;
if (event.getMessage().getContent().equalsIgnoreCase("mcchat"))
return; // Race condition: If it gets here after it enabled mcchat it says it - I might as well allow disabling with this (CommandListener)
if (CommandListener.runCommand(event.getMessage(), true))
return;
if (!event.getMessage().getChannel().isPrivate())
resetLastMessage();
else
resetLastMessage(event.getMessage().getChannel());
lastlist++;
if (author.isBot())
return;
if (CommandListener.runCommand(event.getMessage(), true))
return;
String dmessage = event.getMessage().getContent();
synchronized (this) {
try {

View file

@ -44,10 +44,8 @@ public class MCListener implements Listener {
if (e.getResult() != Result.ALLOWED)
return;
MCChatListener.ConnectedSenders.values().stream()
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny().ifPresent(dcp -> {
callEventExcludingSome(new PlayerQuitEvent(dcp, ""));
//dcp.sendMessage("Real login detected, logged fake player out.");
});
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
.ifPresent(dcp -> callEventExcludingSome(new PlayerQuitEvent(dcp, "")));
}
@EventHandler(priority = EventPriority.LOWEST)