Added check for mcchat on shutdown

It'll only log fake players out that aren't actually on the server
This commit is contained in:
Norbi Peti 2019-01-20 00:43:47 +01:00
parent baa9cb65c8
commit 5c7100bb69
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 5 additions and 4 deletions

View file

@ -156,7 +156,7 @@ public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent>
val chconkeys = chcons.getKeys(false);
for (val chconkey : chconkeys) {
val chcon = chcons.getConfigurationSection(chconkey);
val mcch = Channel.getChannels().stream().filter(ch -> ch.ID.equals(chcon.getString("mcchid"))).findAny();
val mcch = Channel.getChannels().filter(ch -> ch.ID.equals(chcon.getString("mcchid"))).findAny();
val ch = dc.getChannelByID(chcon.getLong("chid"));
val did = chcon.getLong("did");
val user = dc.fetchUser(did);

View file

@ -64,7 +64,7 @@ public class ChannelconCommand extends DiscordCommandBase {
message.reply("this channel is already connected to a Minecraft channel. Use `@ChromaBot channelcon remove` to remove it.");
return true;
}
val chan = Channel.getChannels().stream().filter(ch -> ch.ID.equalsIgnoreCase(args) || (Arrays.stream(ch.IDs().get()).anyMatch(cid -> cid.equalsIgnoreCase(args)))).findAny();
val chan = Channel.getChannels().filter(ch -> ch.ID.equalsIgnoreCase(args) || (Arrays.stream(ch.IDs().get()).anyMatch(cid -> cid.equalsIgnoreCase(args)))).findAny();
if (!chan.isPresent()) { //TODO: Red embed that disappears over time (kinda like the highlight messages in OW)
message.reply("MC channel with ID '" + args + "' not found! The ID is the command for it without the /.");
return true;

View file

@ -331,7 +331,7 @@ public class MCChatListener implements Listener {
} else {
int spi = cmdlowercased.indexOf(' ');
final String topcmd = spi == -1 ? cmdlowercased : cmdlowercased.substring(0, spi);
Optional<Channel> ch = Channel.getChannels().stream()
Optional<Channel> ch = Channel.getChannels()
.filter(c -> c.ID.equalsIgnoreCase(topcmd)
|| (c.IDs().get().length > 0
&& Arrays.stream(c.IDs().get()).anyMatch(id -> id.equalsIgnoreCase(topcmd)))).findAny();

View file

@ -59,7 +59,8 @@ public class MCChatPrivate {
public static void logoutAll() {
for (val entry : MCChatUtils.ConnectedSenders.entrySet())
for (val valueEntry : entry.getValue().entrySet())
callEventExcludingSome(new PlayerQuitEvent(valueEntry.getValue(), "")); //This is sync
if (MCChatUtils.getSender(MCChatUtils.OnlineSenders, valueEntry.getKey(), valueEntry.getValue().getUser()) == null) //If the player is online then the fake player was already logged out
callEventExcludingSome(new PlayerQuitEvent(valueEntry.getValue(), "")); //This is sync
MCChatUtils.ConnectedSenders.clear();
}