MCChat fixes
This commit is contained in:
parent
2308ef4195
commit
1244b50560
3 changed files with 20 additions and 16 deletions
|
@ -87,11 +87,14 @@ public class CommandListener {
|
||||||
createUsableServerReadyStrings(usableServerReadyStrings);
|
createUsableServerReadyStrings(usableServerReadyStrings);
|
||||||
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
||||||
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]);
|
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]);
|
||||||
}
|
|
||||||
if (!event.getMessage().getChannel().isPrivate() //
|
|
||||||
|| DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class)
|
|
||||||
.isMinecraftChatEnabled())
|
|
||||||
return;
|
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())
|
if (event.getMessage().getAuthor().isBot())
|
||||||
return;
|
return;
|
||||||
runCommand(event.getMessage(), false);
|
runCommand(event.getMessage(), false);
|
||||||
|
|
|
@ -207,17 +207,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
* This overload sends it to the global chat.
|
* This overload sends it to the global chat.
|
||||||
*/
|
*/
|
||||||
public static void sendSystemMessageToChat(String msg) {
|
public static void sendSystemMessageToChat(String msg) {
|
||||||
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, msg);
|
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, DiscordPlugin.sanitizeString(msg));
|
||||||
for (LastMsgData data : lastmsgPerUser)
|
for (LastMsgData data : lastmsgPerUser)
|
||||||
DiscordPlugin.sendMessageToChannel(data.channel, msg);
|
DiscordPlugin.sendMessageToChannel(data.channel, DiscordPlugin.sanitizeString(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendSystemMessageToChat(TBMCSystemChatEvent event) {
|
public static void sendSystemMessageToChat(TBMCSystemChatEvent event) {
|
||||||
if (Channel.GlobalChat.ID.equals(event.getChannel().ID))
|
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)
|
for (LastMsgData data : lastmsgPerUser)
|
||||||
if (event.shouldSendTo(getSender(data.channel, data.user, data.dp)))
|
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
|
@Override // Discord
|
||||||
|
@ -229,15 +230,17 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
|
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
|
||||||
&& !(event.getMessage().getChannel().isPrivate() && user.isMinecraftChatEnabled()))
|
&& !(event.getMessage().getChannel().isPrivate() && user.isMinecraftChatEnabled()))
|
||||||
return;
|
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())
|
if (!event.getMessage().getChannel().isPrivate())
|
||||||
resetLastMessage();
|
resetLastMessage();
|
||||||
else
|
else
|
||||||
resetLastMessage(event.getMessage().getChannel());
|
resetLastMessage(event.getMessage().getChannel());
|
||||||
lastlist++;
|
lastlist++;
|
||||||
if (author.isBot())
|
|
||||||
return;
|
|
||||||
if (CommandListener.runCommand(event.getMessage(), true))
|
|
||||||
return;
|
|
||||||
String dmessage = event.getMessage().getContent();
|
String dmessage = event.getMessage().getContent();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -44,10 +44,8 @@ public class MCListener implements Listener {
|
||||||
if (e.getResult() != Result.ALLOWED)
|
if (e.getResult() != Result.ALLOWED)
|
||||||
return;
|
return;
|
||||||
MCChatListener.ConnectedSenders.values().stream()
|
MCChatListener.ConnectedSenders.values().stream()
|
||||||
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny().ifPresent(dcp -> {
|
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
|
||||||
callEventExcludingSome(new PlayerQuitEvent(dcp, ""));
|
.ifPresent(dcp -> callEventExcludingSome(new PlayerQuitEvent(dcp, "")));
|
||||||
//dcp.sendMessage("Real login detected, logged fake player out.");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
|
Loading…
Reference in a new issue