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:
parent
baa9cb65c8
commit
5c7100bb69
4 changed files with 5 additions and 4 deletions
|
@ -156,7 +156,7 @@ public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent>
|
||||||
val chconkeys = chcons.getKeys(false);
|
val chconkeys = chcons.getKeys(false);
|
||||||
for (val chconkey : chconkeys) {
|
for (val chconkey : chconkeys) {
|
||||||
val chcon = chcons.getConfigurationSection(chconkey);
|
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 ch = dc.getChannelByID(chcon.getLong("chid"));
|
||||||
val did = chcon.getLong("did");
|
val did = chcon.getLong("did");
|
||||||
val user = dc.fetchUser(did);
|
val user = dc.fetchUser(did);
|
||||||
|
|
|
@ -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.");
|
message.reply("this channel is already connected to a Minecraft channel. Use `@ChromaBot channelcon remove` to remove it.");
|
||||||
return true;
|
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)
|
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 /.");
|
message.reply("MC channel with ID '" + args + "' not found! The ID is the command for it without the /.");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -331,7 +331,7 @@ public class MCChatListener implements Listener {
|
||||||
} else {
|
} else {
|
||||||
int spi = cmdlowercased.indexOf(' ');
|
int spi = cmdlowercased.indexOf(' ');
|
||||||
final String topcmd = spi == -1 ? cmdlowercased : cmdlowercased.substring(0, spi);
|
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)
|
.filter(c -> c.ID.equalsIgnoreCase(topcmd)
|
||||||
|| (c.IDs().get().length > 0
|
|| (c.IDs().get().length > 0
|
||||||
&& Arrays.stream(c.IDs().get()).anyMatch(id -> id.equalsIgnoreCase(topcmd)))).findAny();
|
&& Arrays.stream(c.IDs().get()).anyMatch(id -> id.equalsIgnoreCase(topcmd)))).findAny();
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class MCChatPrivate {
|
||||||
public static void logoutAll() {
|
public static void logoutAll() {
|
||||||
for (val entry : MCChatUtils.ConnectedSenders.entrySet())
|
for (val entry : MCChatUtils.ConnectedSenders.entrySet())
|
||||||
for (val valueEntry : entry.getValue().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();
|
MCChatUtils.ConnectedSenders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue