I HAVE A MORE WORKED OUT PLAN
This commit is contained in:
parent
a85b7f9a2d
commit
abe8af501e
1 changed files with 25 additions and 10 deletions
|
@ -126,22 +126,37 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
private static ArrayList<LastMsgData> lastmsgPerUser = new ArrayList<LastMsgData>();
|
private static ArrayList<LastMsgData> lastmsgPerUser = new ArrayList<LastMsgData>();
|
||||||
|
|
||||||
public static boolean privateMCChat(IChannel channel, boolean start, IUser user, DiscordPlayer dp) {
|
public static boolean privateMCChat(IChannel channel, boolean start, IUser user, DiscordPlayer dp) {
|
||||||
if (start) {
|
TBMCPlayer mcp = dp.getAs(TBMCPlayer.class);
|
||||||
val sender = new DiscordConnectedPlayer(user, channel,
|
if (mcp != null) { // If the accounts aren't connected, can't make a connected sender
|
||||||
UUID.fromString(dp.getConnectedID(TBMCPlayer.class)));
|
val p = Bukkit.getPlayer(mcp.getUUID());
|
||||||
ConnectedSenders.put(user.getStringID(), sender);
|
if (start) {
|
||||||
if (!OnlineSenders.containsKey(user.getStringID()))// If the player is online, that takes precedence
|
val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID());
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(sender, ""));
|
ConnectedSenders.put(user.getStringID(), sender);
|
||||||
} else {
|
if (p == null)// If the player is online, that takes precedence
|
||||||
val sender = ConnectedSenders.remove(user.getStringID());
|
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(sender, ""));
|
||||||
if (!OnlineSenders.containsKey(user.getStringID()))// If the player is online, that takes precedence
|
} else {
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(sender, ""));
|
val sender = ConnectedSenders.remove(user.getStringID());
|
||||||
|
if (p == null)// If the player is online, that takes precedence
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(sender, ""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return start //
|
return start //
|
||||||
? lastmsgPerUser.add(new LastMsgData(channel)) //
|
? lastmsgPerUser.add(new LastMsgData(channel)) //
|
||||||
: lastmsgPerUser.removeIf(lmd -> lmd.channel.getLongID() == channel.getLongID());
|
: lastmsgPerUser.removeIf(lmd -> lmd.channel.getLongID() == channel.getLongID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// ......................DiscordSender....DiscordConnectedPlayer.DiscordPlayerSender
|
||||||
|
// Offline public chat......x............................................
|
||||||
|
// Online public chat.......x...........................................x
|
||||||
|
// Offline private chat.....x.......................x....................
|
||||||
|
// Online private chat......x.......................x...................x
|
||||||
|
// If online and enabling private chat, don't login
|
||||||
|
// If leaving the server and private chat is enabled (has ConnectedPlayer), call login in a task on lowest priority
|
||||||
|
// If private chat is enabled and joining the server, logout the fake player on highest priority
|
||||||
|
// If online and disabling private chat, don't logout
|
||||||
|
// The maps may not contain the senders except for DiscordPlayerSender
|
||||||
|
|
||||||
public static final HashMap<String, DiscordSender> UnconnectedSenders = new HashMap<>();
|
public static final HashMap<String, DiscordSender> UnconnectedSenders = new HashMap<>();
|
||||||
public static final HashMap<String, DiscordConnectedPlayer> ConnectedSenders = new HashMap<>();
|
public static final HashMap<String, DiscordConnectedPlayer> ConnectedSenders = new HashMap<>();
|
||||||
public static final HashMap<String, DiscordPlayerSender> OnlineSenders = new HashMap<>();
|
public static final HashMap<String, DiscordPlayerSender> OnlineSenders = new HashMap<>();
|
||||||
|
|
Loading…
Reference in a new issue