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) {
|
||||||
|
TBMCPlayer mcp = dp.getAs(TBMCPlayer.class);
|
||||||
|
if (mcp != null) { // If the accounts aren't connected, can't make a connected sender
|
||||||
|
val p = Bukkit.getPlayer(mcp.getUUID());
|
||||||
if (start) {
|
if (start) {
|
||||||
val sender = new DiscordConnectedPlayer(user, channel,
|
val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID());
|
||||||
UUID.fromString(dp.getConnectedID(TBMCPlayer.class)));
|
|
||||||
ConnectedSenders.put(user.getStringID(), sender);
|
ConnectedSenders.put(user.getStringID(), sender);
|
||||||
if (!OnlineSenders.containsKey(user.getStringID()))// If the player is online, that takes precedence
|
if (p == null)// If the player is online, that takes precedence
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(sender, ""));
|
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(sender, ""));
|
||||||
} else {
|
} else {
|
||||||
val sender = ConnectedSenders.remove(user.getStringID());
|
val sender = ConnectedSenders.remove(user.getStringID());
|
||||||
if (!OnlineSenders.containsKey(user.getStringID()))// If the player is online, that takes precedence
|
if (p == null)// If the player is online, that takes precedence
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(sender, ""));
|
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