Finished player info things

This commit is contained in:
Norbi Peti 2016-11-01 21:30:52 +01:00
parent f60a5205de
commit 754ed869f1
2 changed files with 19 additions and 8 deletions

View file

@ -7,7 +7,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerCommandEvent;
import buttondevteam.discordplugin.commands.ConnectCommand; import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.TBMCPlayerGetInfoEvent;
import buttondevteam.lib.TBMCPlayerJoinEvent; import buttondevteam.lib.TBMCPlayerJoinEvent;
import sx.blah.discord.handle.obj.IUser;
public class MCListener implements Listener { public class MCListener implements Listener {
@EventHandler @EventHandler
@ -31,4 +33,14 @@ public class MCListener implements Listener {
+ ConnectCommand.WaitingToConnect.get(e.GetPlayer().getPlayerName()) + " do /discord accept"); + ConnectCommand.WaitingToConnect.get(e.GetPlayer().getPlayerName()) + " do /discord accept");
p.sendMessage("§bIf it wasn't you, do /discord decline"); p.sendMessage("§bIf it wasn't you, do /discord decline");
} }
@EventHandler
public void onGetInfo(TBMCPlayerGetInfoEvent e) {
DiscordPlayer dp = e.getPlayer().asPluginPlayer(DiscordPlayer.class);
if (dp.getDiscordID() == null || dp.getDiscordID() == "")
return;
IUser user = DiscordPlugin.dc.getUserByID(dp.getDiscordID());
e.addInfo("Discord tag: " + user.getName() + "#" + user.getDiscriminator());
e.addInfo("Discord status: " + user.getStatus());
}
} }

View file

@ -2,13 +2,10 @@ package buttondevteam.discordplugin.commands;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import buttondevteam.discordplugin.DiscordPlayer; import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin; import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.lib.TBMCPlayer; import buttondevteam.lib.TBMCPlayer;
import sx.blah.discord.handle.impl.obj.Guild; import buttondevteam.lib.TBMCPlayer.InfoTarget;
import sx.blah.discord.handle.obj.IMessage; import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.IUser; import sx.blah.discord.handle.obj.IUser;
@ -63,11 +60,13 @@ public class UserinfoCommand extends DiscordCommandBase {
} }
target = targets.get(0); target = targets.get(0);
} }
for (Player p : Bukkit.getOnlinePlayers()) { for (TBMCPlayer player : TBMCPlayer.getLoadedPlayers().values()) {
DiscordPlayer dp = TBMCPlayer.getPlayer(p).asPluginPlayer(DiscordPlayer.class); DiscordPlayer dp = player.asPluginPlayer(DiscordPlayer.class);
if (target.getID().equals(dp.getDiscordID())) { if (target.getID().equals(dp.getDiscordID())) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), "User info for " + target.getName()); StringBuilder uinfo = new StringBuilder("User info for ").append(target.getName()).append(":");
break; // TODO: Get user data uinfo.append(player.getInfo(InfoTarget.Discord));
DiscordPlugin.sendMessageToChannel(message.getChannel(), uinfo.toString());
break;
} }
} }
} }