Lot of bugfixes and improvements for mcchat

#12 (PM support should be finished)
#13 works
In no particular order:
Fixed duplicate responses, messages, wrong quit/join event calls, made
the private chat enabled state only persist until the server is
restarted, testing message always appears in PMs, added separate senders
for public and private chat, sending all kinds of messages to private
chat as well, adjusted message for non-whitelisted cmds, changed a lot
on sender getting etc.

1-2 hours of sleep, then work, then programming in the morning, more
sleep, more programming throughout the day.
This commit is contained in:
Norbi Peti 2017-07-12 00:00:19 +02:00
parent abe8af501e
commit a501d9d457
7 changed files with 97 additions and 75 deletions

View file

@ -1,12 +1,13 @@
package buttondevteam.discordplugin; package buttondevteam.discordplugin;
import buttondevteam.discordplugin.listeners.MCChatListener;
import buttondevteam.lib.player.ChromaGamerBase; import buttondevteam.lib.player.ChromaGamerBase;
import buttondevteam.lib.player.PlayerData;
import buttondevteam.lib.player.UserClass; import buttondevteam.lib.player.UserClass;
@UserClass(foldername = "discord") @UserClass(foldername = "discord")
public class DiscordPlayer extends ChromaGamerBase { public class DiscordPlayer extends ChromaGamerBase {
private String did; private String did;
// private @Getter @Setter boolean minecraftChatEnabled;
public DiscordPlayer() { public DiscordPlayer() {
} }
@ -17,7 +18,11 @@ public class DiscordPlayer extends ChromaGamerBase {
return did; return did;
} }
public PlayerData<Boolean> minecraftChat() { /**
return data(false); * Returns true if player has the private Minecraft chat enabled. For setting the value, see
* {@link MCChatListener#privateMCChat(sx.blah.discord.handle.obj.IChannel, boolean, sx.blah.discord.handle.obj.IUser, DiscordPlayer)}
*/
public boolean isMinecraftChatEnabled() {
return MCChatListener.isMinecraftChatEnabled(this);
} }
} }

View file

@ -256,6 +256,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
if (channel == chatchannel) if (channel == chatchannel)
MCChatListener.resetLastMessage(); // If this is a chat message, it'll be set again MCChatListener.resetLastMessage(); // If this is a chat message, it'll be set again
final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel || channel == botroomchannel // Both are the same for testing final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel || channel == botroomchannel // Both are the same for testing
|| channel.isPrivate() //
? "*The following message is from a test server*\n" + message : message; ? "*The following message is from a test server*\n" + message : message;
return perform( return perform(
() -> embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false)); () -> embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false));

View file

@ -1,9 +1,9 @@
package buttondevteam.discordplugin.commands; package buttondevteam.discordplugin.commands;
import buttondevteam.discordplugin.DiscordPlayer; import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.listeners.MCChatListener; import buttondevteam.discordplugin.listeners.MCChatListener;
import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.player.PlayerData;
import sx.blah.discord.handle.obj.IMessage; import sx.blah.discord.handle.obj.IMessage;
public class MCChatCommand extends DiscordCommandBase { public class MCChatCommand extends DiscordCommandBase {
@ -16,14 +16,15 @@ public class MCChatCommand extends DiscordCommandBase {
@Override @Override
public void run(IMessage message, String args) { public void run(IMessage message, String args) {
if (!message.getChannel().isPrivate()) { if (!message.getChannel().isPrivate()) {
message.reply("This command can only be issued in a direct message with the bot."); DiscordPlugin.sendMessageToChannel(message.getChannel(),
"This command can only be issued in a direct message with the bot.");
return; return;
} }
try (final DiscordPlayer user = DiscordPlayer.getUser(message.getAuthor().getStringID(), DiscordPlayer.class)) { try (final DiscordPlayer user = DiscordPlayer.getUser(message.getAuthor().getStringID(), DiscordPlayer.class)) {
PlayerData<Boolean> mcchat = user.minecraftChat(); boolean mcchat = !user.isMinecraftChatEnabled();
mcchat.set(!mcchat.get()); MCChatListener.privateMCChat(message.getChannel(), mcchat, message.getAuthor(), user);
MCChatListener.privateMCChat(message.getChannel(), mcchat.get(), message.getAuthor(), user); DiscordPlugin.sendMessageToChannel(message.getChannel(),
message.reply("Minecraft chat " + (mcchat.get() // "Minecraft chat " + (mcchat //
? "enabled. Use '" + message.getClient().getOurUser().mention() ? "enabled. Use '" + message.getClient().getOurUser().mention()
+ " mcchat' (with the mention) to disable." // + " mcchat' (with the mention) to disable." //
: "disabled.")); : "disabled."));

View file

@ -59,13 +59,10 @@ public class CommandListener {
if (event.getMessage().getAuthor().isBot()) if (event.getMessage().getAuthor().isBot())
return; return;
final IChannel channel = event.getMessage().getChannel(); final IChannel channel = event.getMessage().getChannel();
if (!channel.getStringID().equals(DiscordPlugin.botchannel.getStringID()) if (!channel.getStringID().equals(DiscordPlugin.botchannel.getStringID()))
&& (!channel.isPrivate() || DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()))
return; return;
if (channel.getStringID().equals(DiscordPlugin.chatchannel.getStringID())) if (channel.getStringID().equals(DiscordPlugin.chatchannel.getStringID()))
return; // The chat code already handles this - Right now while testing botchannel is the same as chatchannel return; // The chat code already handles this - Right now while testing botchannel is the same as chatchannel
if (DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class).minecraftChat().get()) // Let the MCChatListener handle it
return;
event.getMessage().getChannel().setTypingStatus(true); // Fun event.getMessage().getChannel().setTypingStatus(true); // Fun
runCommand(event.getMessage(), true); runCommand(event.getMessage(), true);
} }
@ -84,8 +81,8 @@ public class CommandListener {
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]); DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]);
} }
if (!event.getMessage().getChannel().isPrivate() // if (!event.getMessage().getChannel().isPrivate() //
|| DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class).minecraftChat() || DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class)
.get() .isMinecraftChatEnabled()
|| DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()) || DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent())
return; return;
if (event.getMessage().getAuthor().isBot()) if (event.getMessage().getAuthor().isBot())

View file

@ -4,11 +4,12 @@ import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -75,7 +76,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
final IUser iUser = data.channel.getUsersHere().stream() final IUser iUser = data.channel.getUsersHere().stream()
.filter(u -> u.getLongID() != u.getClient().getOurUser().getLongID()).findFirst().get(); // Doesn't support group DMs .filter(u -> u.getLongID() != u.getClient().getOurUser().getLongID()).findFirst().get(); // Doesn't support group DMs
final DiscordPlayer user = DiscordPlayer.getUser(iUser.getStringID(), DiscordPlayer.class); final DiscordPlayer user = DiscordPlayer.getUser(iUser.getStringID(), DiscordPlayer.class);
if (user.minecraftChat().get() && e.shouldSendTo(getSender(data.channel, iUser, user))) if (user.isMinecraftChatEnabled() && e.shouldSendTo(getSender(data.channel, iUser, user)))
doit.accept(data); doit.accept(data);
} }
} // TODO: Author URL } // TODO: Author URL
@ -132,11 +133,11 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
if (start) { if (start) {
val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID()); val sender = new DiscordConnectedPlayer(user, channel, mcp.getUUID());
ConnectedSenders.put(user.getStringID(), sender); ConnectedSenders.put(user.getStringID(), sender);
if (p == null)// If the player is online, that takes precedence if (p == null)// Player is offline - 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 (p == null)// If the player is online, that takes precedence if (p == null)// Player is offline - If the player is online, that takes precedence
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(sender, "")); Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(sender, ""));
} }
} }
@ -145,7 +146,6 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
: lastmsgPerUser.removeIf(lmd -> lmd.channel.getLongID() == channel.getLongID()); : lastmsgPerUser.removeIf(lmd -> lmd.channel.getLongID() == channel.getLongID());
} }
//
// ......................DiscordSender....DiscordConnectedPlayer.DiscordPlayerSender // ......................DiscordSender....DiscordConnectedPlayer.DiscordPlayerSender
// Offline public chat......x............................................ // Offline public chat......x............................................
// Online public chat.......x...........................................x // Online public chat.......x...........................................x
@ -155,10 +155,21 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
// If leaving the server and private chat is enabled (has ConnectedPlayer), call login in a task on lowest priority // 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 private chat is enabled and joining the server, logout the fake player on highest priority
// If online and disabling private chat, don't logout // If online and disabling private chat, don't logout
// The maps may not contain the senders except for DiscordPlayerSender // The maps may not contain the senders for UnconnectedSenders
public static boolean isMinecraftChatEnabled(DiscordPlayer dp) {
return lastmsgPerUser.stream().anyMatch(
lmd -> ((IPrivateChannel) lmd.channel).getRecipient().getStringID().equals(dp.getDiscordID()));
}
/**
* May contain P&lt;DiscordID&gt; as key for public chat
*/
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<>();
/**
* May contain P&lt;DiscordID&gt; as key for public chat
*/
public static final HashMap<String, DiscordPlayerSender> OnlineSenders = new HashMap<>(); public static final HashMap<String, DiscordPlayerSender> OnlineSenders = new HashMap<>();
public static short ListC = 0; public static short ListC = 0;
@ -166,12 +177,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
(lastmsgdata == null ? lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel) : lastmsgdata).message = null; // Don't set the whole object to null, the player and channel information should (lastmsgdata == null ? lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel) : lastmsgdata).message = null; // Don't set the whole object to null, the player and channel information should
} // be preserved } // be preserved
public static void sendSystemMessageToChat(String msg) {
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, msg);
for (LastMsgData data : lastmsgPerUser)
DiscordPlugin.sendMessageToChannel(data.channel, msg);
}
@Override // Discord @Override // Discord
public void handle(MessageReceivedEvent event) { public void handle(MessageReceivedEvent event) {
val author = event.getMessage().getAuthor(); val author = event.getMessage().getAuthor();
val user = DiscordPlayer.getUser(author.getStringID(), DiscordPlayer.class); val user = DiscordPlayer.getUser(author.getStringID(), DiscordPlayer.class);
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID()) if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
&& !(event.getMessage().getChannel().isPrivate() && user.minecraftChat().get() && !(event.getMessage().getChannel().isPrivate() && user.isMinecraftChatEnabled()
&& !DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent())) && !DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()))
return; return;
resetLastMessage(); resetLastMessage();
@ -200,12 +217,13 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
if (dsender instanceof DiscordSender && !Arrays.stream(UnconnectedCmds) if (dsender instanceof DiscordSender && !Arrays.stream(UnconnectedCmds)
.anyMatch(s -> cmd.equals(s) || cmd.startsWith(s + " "))) { .anyMatch(s -> cmd.equals(s) || cmd.startsWith(s + " "))) {
// Command not whitelisted // Command not whitelisted
dsender.sendMessage( // TODO dsender.sendMessage("Sorry, you can only access these commands:\n"
"Sorry, you need to be online on the server and have your accounts connected, you can only access these commands:\n" + Arrays.stream(UnconnectedCmds).map(uc -> "/" + uc).collect(Collectors.joining(", "))
+ Arrays.stream(UnconnectedCmds).map(uc -> "/" + uc) + (user.getConnectedID(TBMCPlayer.class) == null
.collect(Collectors.joining(", ")) ? "\nTo access your commands, first please connect your accounts, using @ChromaBot connect in "
+ "\nTo connect your accounts, use @ChromaBot connect in " + DiscordPlugin.botchannel.mention()
+ DiscordPlugin.botchannel.mention()); + "\nThen you can access all of your regular commands (even offline) in private chat: DM me `mcchat`!"
: "\nYou can access all of your regular commands (even offline) in private chat: DM me `mcchat`!"));
return; return;
} }
if (lastlist > 5) { if (lastlist > 5) {
@ -248,29 +266,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
} }
} }
@SuppressWarnings("unchecked") /**
private <T extends DiscordSenderBase> DiscordSenderBase getSender(IChannel channel, final IUser author, * This method will find the best sender to use: if the player is online, use that, if not but connected then use that etc.
DiscordPlayer dp) { */
final DiscordSenderBase dsender; private DiscordSenderBase getSender(IChannel channel, final IUser author, DiscordPlayer dp) {
final Player mcp; val key = (channel.isPrivate() ? "" : "P") + author.getStringID();
final String cid; return Stream.<Supplier<Optional<DiscordSenderBase>>>of( // https://stackoverflow.com/a/28833677/2703239
BiFunction<HashMap<String, T>, Supplier<T>, DiscordSenderBase> getsender = (senders, maker) -> { () -> Optional.ofNullable(OnlineSenders.get(key)), // Find first non-null
if (!senders.containsKey(author.getStringID())) () -> Optional.ofNullable(ConnectedSenders.get(author.getStringID())), // This doesn't support it
senders.put(author.getStringID(), maker.get()); () -> Optional.ofNullable(UnconnectedSenders.get(key)), () -> {
return senders.get(author.getStringID()); val dsender = new DiscordSender(author, channel);
}; UnconnectedSenders.put(key, dsender);
if ((cid = dp.getConnectedID(TBMCPlayer.class)) != null) { // Connected? return Optional.of(dsender);
if ((mcp = Bukkit.getPlayer(UUID.fromString(cid))) != null) // Online? - Execute as ingame player }).map(Supplier::get).filter(Optional::isPresent).map(Optional::get).findFirst().get();
dsender = getsender.apply((HashMap<String, T>) OnlineSenders,
() -> (T) new DiscordPlayerSender(author, channel, mcp));
else // Offline
dsender = getsender.apply((HashMap<String, T>) ConnectedSenders,
() -> (T) new DiscordConnectedPlayer(author, channel, UUID.fromString(cid)));
} else { // Not connected
TBMCPlayer p = dp.getAs(TBMCPlayer.class);
dsender = getsender.apply((HashMap<String, T>) UnconnectedSenders,
() -> (T) new DiscordSender(author, channel, p == null ? null : p.PlayerName().get())); // Display the playername, if found
}
return dsender;
} }
} }

View file

@ -1,10 +1,13 @@
package buttondevteam.discordplugin.listeners; package buttondevteam.discordplugin.listeners;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerCommandEvent;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
@ -16,6 +19,7 @@ import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.commands.ConnectCommand; import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.player.*; import buttondevteam.lib.player.*;
import lombok.val;
import net.ess3.api.events.*; import net.ess3.api.events.*;
import sx.blah.discord.handle.obj.IRole; import sx.blah.discord.handle.obj.IRole;
import sx.blah.discord.handle.obj.IUser; import sx.blah.discord.handle.obj.IUser;
@ -23,14 +27,22 @@ import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.MissingPermissionsException; import sx.blah.discord.util.MissingPermissionsException;
public class MCListener implements Listener { public class MCListener implements Listener {
@EventHandler @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(TBMCPlayerJoinEvent e) { public void onPlayerJoin(TBMCPlayerJoinEvent e) {
if (e.getPlayer() instanceof DiscordConnectedPlayer) if (e.getPlayer() instanceof DiscordConnectedPlayer)
return; // Don't show the joined message for the fake player return; // Don't show the joined message for the fake player
final Player p = e.getPlayer(); final Player p = e.getPlayer();
DiscordPlayer dp = e.GetPlayer().getAs(DiscordPlayer.class); DiscordPlayer dp = e.GetPlayer().getAs(DiscordPlayer.class);
// if(dp!=null) //TODO if (dp != null) {
// MCChatListener.OnlineSenders.put(dp.getDiscordID(), new DiscordPlayerSender(DiscordPlugin.dc.getUserByID(Long.parseLong(dp.getDiscordID()), channel, player)) val user = DiscordPlugin.dc.getUserByID(Long.parseLong(dp.getDiscordID()));
MCChatListener.OnlineSenders.put(dp.getDiscordID(),
new DiscordPlayerSender(user, user.getOrCreatePMChannel(), p));
MCChatListener.OnlineSenders.put("P" + dp.getDiscordID(),
new DiscordPlayerSender(user, DiscordPlugin.chatchannel, p));
MCChatListener.ConnectedSenders.values().stream()
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
.ifPresent(dcp -> Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(dcp, "")));
}
if (ConnectCommand.WaitingToConnect.containsKey(e.GetPlayer().PlayerName().get())) { if (ConnectCommand.WaitingToConnect.containsKey(e.GetPlayer().PlayerName().get())) {
IUser user = DiscordPlugin.dc IUser user = DiscordPlugin.dc
.getUserByID(Long.parseLong(ConnectCommand.WaitingToConnect.get(e.GetPlayer().PlayerName().get()))); .getUserByID(Long.parseLong(ConnectCommand.WaitingToConnect.get(e.GetPlayer().PlayerName().get())));
@ -38,18 +50,20 @@ public class MCListener implements Listener {
+ " do /discord accept"); + " do /discord accept");
p.sendMessage("§bIf it wasn't you, do /discord decline"); p.sendMessage("§bIf it wasn't you, do /discord decline");
} }
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " joined the game");
e.GetPlayer().PlayerName().get() + " joined the game");
MCChatListener.ListC = 0; MCChatListener.ListC = 0;
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLeave(TBMCPlayerQuitEvent e) { public void onPlayerLeave(TBMCPlayerQuitEvent e) {
if (MCChatListener.OnlineSenders.entrySet() if (e.getPlayer() instanceof DiscordConnectedPlayer)
.removeIf(entry -> entry.getValue().getUniqueId().equals(e.getPlayer().getUniqueId()))) return; // Only care about real users
; // TODO MCChatListener.OnlineSenders.entrySet()
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, .removeIf(entry -> entry.getValue().getUniqueId().equals(e.getPlayer().getUniqueId()));
e.GetPlayer().PlayerName().get() + " left the game"); MCChatListener.ConnectedSenders.values().stream()
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
.ifPresent(dcp -> Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(dcp, "")));
MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " left the game");
} }
@EventHandler @EventHandler
@ -70,16 +84,15 @@ public class MCListener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onPlayerDeath(PlayerDeathEvent e) { public void onPlayerDeath(PlayerDeathEvent e) {
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, e.getDeathMessage()); MCChatListener.sendSystemMessageToChat(e.getDeathMessage());
} }
@EventHandler @EventHandler
public void onPlayerAFK(AfkStatusChangeEvent e) { public void onPlayerAFK(AfkStatusChangeEvent e) {
if (e.isCancelled()) if (e.isCancelled() || !e.getAffected().getBase().isOnline())
return; return;
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, MCChatListener.sendSystemMessageToChat(DiscordPlugin.sanitizeString(e.getAffected().getBase().getDisplayName())
DiscordPlugin.sanitizeString(e.getAffected().getBase().getDisplayName()) + " is " + " is " + (e.getValue() ? "now" : "no longer") + " AFK.");
+ (e.getValue() ? "now" : "no longer") + " AFK.");
} }
@EventHandler @EventHandler

View file

@ -9,7 +9,6 @@ import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
import org.bukkit.permissions.PermissibleBase; import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.ServerOperator; import org.bukkit.permissions.ServerOperator;
@ -29,7 +28,6 @@ public class DiscordFakePlayer extends DiscordHumanEntity implements Player {
perm = new PermissibleBase(new ServerOperator() { perm = new PermissibleBase(new ServerOperator() {
private @Getter @Setter boolean op; private @Getter @Setter boolean op;
}); });
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(this, "Discord fake player joined"));
} }
@Delegate @Delegate