Fixed player getting in chat

This commit is contained in:
Norbi Peti 2017-05-22 21:33:12 +02:00
parent 7a3e4d8c30
commit adb0144f91

View file

@ -2,6 +2,7 @@ package buttondevteam.discordplugin.listeners;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -116,10 +117,10 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
try { try {
DiscordPlayer dp = ChromaGamerBase.getUser(author.getStringID(), DiscordPlayer.class); DiscordPlayer dp = ChromaGamerBase.getUser(author.getStringID(), DiscordPlayer.class);
final DiscordSenderBase dsender; final DiscordSenderBase dsender;
Player mcp = null; // Offline players can't really run commands Player mcp = null; // Offline players can't really run commands, or can they?
final String cid; final String cid;
if ((cid = dp.getConnectedID(TBMCPlayer.class)) != null // Connected? if ((cid = dp.getConnectedID(TBMCPlayer.class)) != null // Connected?
&& (mcp = Bukkit.getPlayer(cid)) != null) { // Execute as ingame player, if online && (mcp = Bukkit.getPlayer(UUID.fromString(cid))) != null) { // Execute as ingame player
if (!ConnectedSenders.containsKey(author.getStringID())) if (!ConnectedSenders.containsKey(author.getStringID()))
ConnectedSenders.put(author.getStringID(), ConnectedSenders.put(author.getStringID(),
new DiscordPlayerSender(author, event.getMessage().getChannel(), mcp)); new DiscordPlayerSender(author, event.getMessage().getChannel(), mcp));