Updated Discord4J stuff, getInfo shows more, etc.
This commit is contained in:
parent
c23d9aee09
commit
01db886917
9 changed files with 62 additions and 64 deletions
|
@ -76,29 +76,29 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
try {
|
try {
|
||||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
|
task = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
|
||||||
if (mainServer == null || devServer == null) {
|
if (mainServer == null || devServer == null) {
|
||||||
mainServer = event.getClient().getGuildByID("125813020357165056");
|
mainServer = event.getClient().getGuildByID(125813020357165056L);
|
||||||
devServer = event.getClient().getGuildByID("219529124321034241");
|
devServer = event.getClient().getGuildByID(219529124321034241L);
|
||||||
}
|
}
|
||||||
if (mainServer == null || devServer == null)
|
if (mainServer == null || devServer == null)
|
||||||
return; // Retry
|
return; // Retry
|
||||||
if (!TBMCCoreAPI.IsTestServer()) {
|
if (!TBMCCoreAPI.IsTestServer()) {
|
||||||
botchannel = mainServer.getChannelByID("209720707188260864"); // bot
|
botchannel = mainServer.getChannelByID(209720707188260864L); // bot
|
||||||
annchannel = mainServer.getChannelByID("126795071927353344"); // announcements
|
annchannel = mainServer.getChannelByID(126795071927353344L); // announcements
|
||||||
genchannel = mainServer.getChannelByID("125813020357165056"); // general
|
genchannel = mainServer.getChannelByID(125813020357165056L); // general
|
||||||
chatchannel = mainServer.getChannelByID("249663564057411596"); // minecraft_chat
|
chatchannel = mainServer.getChannelByID(249663564057411596L); // minecraft_chat
|
||||||
botroomchannel = devServer.getChannelByID("239519012529111040"); // bot-room
|
botroomchannel = devServer.getChannelByID(239519012529111040L); // bot-room
|
||||||
officechannel = devServer.getChannelByID("219626707458457603"); // developers-office
|
officechannel = devServer.getChannelByID(219626707458457603L); // developers-office
|
||||||
updatechannel = devServer.getChannelByID("233724163519414272"); // server-updates
|
updatechannel = devServer.getChannelByID(233724163519414272L); // server-updates
|
||||||
dc.changeStatus(Status.game("on TBMC"));
|
dc.online("on TBMC");
|
||||||
} else {
|
} else {
|
||||||
botchannel = devServer.getChannelByID("239519012529111040"); // bot-room
|
botchannel = devServer.getChannelByID(239519012529111040L); // bot-room
|
||||||
annchannel = botchannel; // bot-room
|
annchannel = botchannel; // bot-room
|
||||||
genchannel = botchannel; // bot-room
|
genchannel = botchannel; // bot-room
|
||||||
botroomchannel = botchannel;// bot-room
|
botroomchannel = botchannel;// bot-room
|
||||||
chatchannel = botchannel;// bot-room
|
chatchannel = botchannel;// bot-room
|
||||||
officechannel = devServer.getChannelByID("219626707458457603"); // developers-office
|
officechannel = devServer.getChannelByID(219626707458457603L); // developers-office
|
||||||
updatechannel = botchannel;
|
updatechannel = botchannel;
|
||||||
dc.changeStatus(Status.game("testing"));
|
dc.online("testing");
|
||||||
}
|
}
|
||||||
if (botchannel == null || annchannel == null || genchannel == null || botroomchannel == null
|
if (botchannel == null || annchannel == null || genchannel == null || botroomchannel == null
|
||||||
|| chatchannel == null || officechannel == null || updatechannel == null)
|
|| chatchannel == null || officechannel == null || updatechannel == null)
|
||||||
|
@ -155,7 +155,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
sendMessageToChannel(chatchannel, "", new EmbedBuilder().withColor(Restart ? Color.ORANGE : Color.RED)
|
sendMessageToChannel(chatchannel, "", new EmbedBuilder().withColor(Restart ? Color.ORANGE : Color.RED)
|
||||||
.withTitle(Restart ? "Server restarting" : "Server stopping").build());
|
.withTitle(Restart ? "Server restarting" : "Server stopping").build());
|
||||||
try {
|
try {
|
||||||
dc.changeStatus(Status.game("on TBMC"));
|
dc.online("on TBMC");
|
||||||
dc.logout();
|
dc.logout();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TBMCCoreAPI.SendException("An error occured while disabling DiscordPlugin!", e);
|
TBMCCoreAPI.SendException("An error occured while disabling DiscordPlugin!", e);
|
||||||
|
|
|
@ -37,10 +37,10 @@ public class ConnectCommand extends DiscordCommandBase {
|
||||||
"Too many arguments.\nUsage: connect <Minecraftname>");
|
"Too many arguments.\nUsage: connect <Minecraftname>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (WaitingToConnect.inverse().containsKey(message.getAuthor().getID())) {
|
if (WaitingToConnect.inverse().containsKey(message.getAuthor().getStringID())) {
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||||
"Replacing " + WaitingToConnect.inverse().get(message.getAuthor().getID()) + " with " + args);
|
"Replacing " + WaitingToConnect.inverse().get(message.getAuthor().getStringID()) + " with " + args);
|
||||||
WaitingToConnect.inverse().remove(message.getAuthor().getID());
|
WaitingToConnect.inverse().remove(message.getAuthor().getStringID());
|
||||||
}
|
}
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
OfflinePlayer p = Bukkit.getOfflinePlayer(args);
|
OfflinePlayer p = Bukkit.getOfflinePlayer(args);
|
||||||
|
@ -50,7 +50,7 @@ public class ConnectCommand extends DiscordCommandBase {
|
||||||
}
|
}
|
||||||
try (TBMCPlayer pl = TBMCPlayerBase.getPlayer(p.getUniqueId(), TBMCPlayer.class)) {
|
try (TBMCPlayer pl = TBMCPlayerBase.getPlayer(p.getUniqueId(), TBMCPlayer.class)) {
|
||||||
DiscordPlayer dp = pl.getAs(DiscordPlayer.class);
|
DiscordPlayer dp = pl.getAs(DiscordPlayer.class);
|
||||||
if (dp != null && message.getAuthor().getID().equals(dp.getDiscordID())) {
|
if (dp != null && message.getAuthor().getStringID().equals(dp.getDiscordID())) {
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(), "You already have this account connected.");
|
DiscordPlugin.sendMessageToChannel(message.getChannel(), "You already have this account connected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class ConnectCommand extends DiscordCommandBase {
|
||||||
TBMCCoreAPI.SendException("An error occured while connecting a Discord account!", e);
|
TBMCCoreAPI.SendException("An error occured while connecting a Discord account!", e);
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(), "An internal error occured!\n" + e);
|
DiscordPlugin.sendMessageToChannel(message.getChannel(), "An internal error occured!\n" + e);
|
||||||
}
|
}
|
||||||
WaitingToConnect.put(p.getName(), message.getAuthor().getID());
|
WaitingToConnect.put(p.getName(), message.getAuthor().getStringID());
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||||
"Pending connection - accept connection in Minecraft from the account " + args
|
"Pending connection - accept connection in Minecraft from the account " + args
|
||||||
+ " before the server gets restarted. You can also adjust the Minecraft name you want to connect to with the same command.");
|
+ " before the server gets restarted. You can also adjust the Minecraft name you want to connect to with the same command.");
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class RoleCommand extends DiscordCommandBase {
|
||||||
"List of game roles:\n" + DiscordPlugin.GameRoles.stream().collect(Collectors.joining("\n")));
|
"List of game roles:\n" + DiscordPlugin.GameRoles.stream().collect(Collectors.joining("\n")));
|
||||||
} else if (argsa[0].equalsIgnoreCase("addrole")) {
|
} else if (argsa[0].equalsIgnoreCase("addrole")) {
|
||||||
if (!message.getAuthor().getRolesForGuild(DiscordPlugin.mainServer).stream()
|
if (!message.getAuthor().getRolesForGuild(DiscordPlugin.mainServer).stream()
|
||||||
.anyMatch(r -> r.getID().equals("126030201472811008"))) {
|
.anyMatch(r -> r.getLongID() == 126030201472811008L)) {
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||||
"You need to be a moderator to use this command.");
|
"You need to be a moderator to use this command.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class UserinfoCommand extends DiscordCommandBase {
|
||||||
target = message.getAuthor();
|
target = message.getAuthor();
|
||||||
else {
|
else {
|
||||||
final Optional<IUser> firstmention = message.getMentions().stream()
|
final Optional<IUser> firstmention = message.getMentions().stream()
|
||||||
.filter(m -> !m.getID().equals(DiscordPlugin.dc.getOurUser().getID())).findFirst();
|
.filter(m -> !m.getStringID().equals(DiscordPlugin.dc.getOurUser().getStringID())).findFirst();
|
||||||
if (firstmention.isPresent())
|
if (firstmention.isPresent())
|
||||||
target = firstmention.get();
|
target = firstmention.get();
|
||||||
else if (args.contains("#")) {
|
else if (args.contains("#")) {
|
||||||
|
@ -68,7 +68,7 @@ public class UserinfoCommand extends DiscordCommandBase {
|
||||||
target = targets.get(0);
|
target = targets.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try (DiscordPlayer dp = ChromaGamerBase.getUser(target.getID(), DiscordPlayer.class)) {
|
try (DiscordPlayer dp = ChromaGamerBase.getUser(target.getStringID(), DiscordPlayer.class)) {
|
||||||
StringBuilder uinfo = new StringBuilder("User info for ").append(target.getName()).append(":\n");
|
StringBuilder uinfo = new StringBuilder("User info for ").append(target.getName()).append(":\n");
|
||||||
uinfo.append(dp.getInfo(InfoTarget.Discord));
|
uinfo.append(dp.getInfo(InfoTarget.Discord));
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(), uinfo.toString());
|
DiscordPlugin.sendMessageToChannel(message.getChannel(), uinfo.toString());
|
||||||
|
|
|
@ -7,7 +7,7 @@ import buttondevteam.discordplugin.DiscordPlugin;
|
||||||
import buttondevteam.discordplugin.DiscordSender;
|
import buttondevteam.discordplugin.DiscordSender;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import sx.blah.discord.api.events.IListener;
|
import sx.blah.discord.api.events.IListener;
|
||||||
import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
|
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
|
||||||
import sx.blah.discord.handle.obj.IEmbed;
|
import sx.blah.discord.handle.obj.IEmbed;
|
||||||
import sx.blah.discord.util.EmbedBuilder;
|
import sx.blah.discord.util.EmbedBuilder;
|
||||||
|
|
||||||
|
@ -16,13 +16,13 @@ public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
|
||||||
public void handle(MessageReceivedEvent event) {
|
public void handle(MessageReceivedEvent event) {
|
||||||
if (DiscordPlugin.SafeMode)
|
if (DiscordPlugin.SafeMode)
|
||||||
return;
|
return;
|
||||||
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.officechannel.getID()))
|
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.officechannel.getStringID()))
|
||||||
return;
|
return;
|
||||||
if (!"239123781401051138".equals(event.getMessage().getWebhookID()))
|
if (239123781401051138L != event.getMessage().getWebhookLongID())
|
||||||
return;
|
return;
|
||||||
if (event.getMessage().getEmbedded().size() == 0)
|
if (event.getMessage().getEmbeds().size() == 0)
|
||||||
return;
|
return;
|
||||||
final IEmbed embed = event.getMessage().getEmbedded().get(0);
|
final IEmbed embed = event.getMessage().getEmbeds().get(0);
|
||||||
final String title = embed.getTitle();
|
final String title = embed.getTitle();
|
||||||
if (!title.contains("new commit"))
|
if (!title.contains("new commit"))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,8 +3,8 @@ package buttondevteam.discordplugin.listeners;
|
||||||
import buttondevteam.discordplugin.DiscordPlugin;
|
import buttondevteam.discordplugin.DiscordPlugin;
|
||||||
import buttondevteam.discordplugin.commands.DiscordCommandBase;
|
import buttondevteam.discordplugin.commands.DiscordCommandBase;
|
||||||
import sx.blah.discord.api.events.IListener;
|
import sx.blah.discord.api.events.IListener;
|
||||||
import sx.blah.discord.handle.impl.events.MentionEvent;
|
import sx.blah.discord.handle.impl.events.guild.channel.message.MentionEvent;
|
||||||
import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
|
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
|
||||||
import sx.blah.discord.handle.obj.IChannel;
|
import sx.blah.discord.handle.obj.IChannel;
|
||||||
import sx.blah.discord.handle.obj.IMessage;
|
import sx.blah.discord.handle.obj.IMessage;
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ 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.getID().equals(DiscordPlugin.botchannel.getID()) && !channel.isPrivate())
|
if (!channel.getStringID().equals(DiscordPlugin.botchannel.getStringID()) && !channel.isPrivate())
|
||||||
return;
|
return;
|
||||||
if (channel.getID().equals(DiscordPlugin.chatchannel.getID()))
|
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
|
||||||
runCommand(event.getMessage(), true);
|
runCommand(event.getMessage(), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package buttondevteam.discordplugin.listeners;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Optional;
|
|
||||||
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;
|
||||||
|
@ -17,7 +16,7 @@ import buttondevteam.lib.player.ChromaGamerBase;
|
||||||
import buttondevteam.lib.player.TBMCPlayer;
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
import sx.blah.discord.api.events.IListener;
|
import sx.blah.discord.api.events.IListener;
|
||||||
import sx.blah.discord.api.internal.json.objects.EmbedObject;
|
import sx.blah.discord.api.internal.json.objects.EmbedObject;
|
||||||
import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
|
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
|
||||||
import sx.blah.discord.handle.obj.*;
|
import sx.blah.discord.handle.obj.*;
|
||||||
import sx.blah.discord.util.*;
|
import sx.blah.discord.util.*;
|
||||||
|
|
||||||
|
@ -41,13 +40,13 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
: embed.build();
|
: embed.build();
|
||||||
final long nanoTime = System.nanoTime();
|
final long nanoTime = System.nanoTime();
|
||||||
if (lastmessage == null || lastmessage.isDeleted()
|
if (lastmessage == null || lastmessage.isDeleted()
|
||||||
|| !authorPlayer.equals(lastmessage.getEmbedded().get(0).getAuthor().getName())
|
|| !authorPlayer.equals(lastmessage.getEmbeds().get(0).getAuthor().getName())
|
||||||
|| lastmsgtime / 1000000000f < nanoTime / 1000000000f - 120) {
|
|| lastmsgtime / 1000000000f < nanoTime / 1000000000f - 120) {
|
||||||
lastmessage = DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, "", embedObject);
|
lastmessage = DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, "", embedObject);
|
||||||
lastmsgtime = nanoTime;
|
lastmsgtime = nanoTime;
|
||||||
} else
|
} else
|
||||||
try {
|
try {
|
||||||
embedObject.description = lastmessage.getEmbedded().get(0).getDescription() + "\n"
|
embedObject.description = lastmessage.getEmbeds().get(0).getDescription() + "\n"
|
||||||
+ embedObject.description;
|
+ embedObject.description;
|
||||||
DiscordPlugin.perform(() -> lastmessage.edit("", embedObject));
|
DiscordPlugin.perform(() -> lastmessage.edit("", embedObject));
|
||||||
} catch (MissingPermissionsException | DiscordException e1) {
|
} catch (MissingPermissionsException | DiscordException e1) {
|
||||||
|
@ -73,9 +72,9 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Discord
|
@Override // Discord
|
||||||
public void handle(MessageReceivedEvent event) {
|
public void handle(sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent event) {
|
||||||
final IUser author = event.getMessage().getAuthor();
|
final IUser author = event.getMessage().getAuthor();
|
||||||
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())
|
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
|
||||||
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
||||||
return;
|
return;
|
||||||
lastmessage = null;
|
lastmessage = null;
|
||||||
|
@ -87,28 +86,28 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
String dmessage = event.getMessage().getContent();
|
String dmessage = event.getMessage().getContent();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
DiscordPlayer dp = ChromaGamerBase.getUser(author.getID(), 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
|
||||||
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(cid)) != null) { // Execute as ingame player, if online
|
||||||
if (!ConnectedSenders.containsKey(author.getID()))
|
if (!ConnectedSenders.containsKey(author.getStringID()))
|
||||||
ConnectedSenders.put(author.getID(),
|
ConnectedSenders.put(author.getStringID(),
|
||||||
new DiscordPlayerSender(author, event.getMessage().getChannel(), mcp));
|
new DiscordPlayerSender(author, event.getMessage().getChannel(), mcp));
|
||||||
dsender = ConnectedSenders.get(author.getID());
|
dsender = ConnectedSenders.get(author.getStringID());
|
||||||
} else {
|
} else {
|
||||||
TBMCPlayer p = dp.getAs(TBMCPlayer.class);
|
TBMCPlayer p = dp.getAs(TBMCPlayer.class);
|
||||||
if (!UnconnectedSenders.containsKey(author.getID()))
|
if (!UnconnectedSenders.containsKey(author.getStringID()))
|
||||||
UnconnectedSenders.put(author.getID(), new DiscordSender(author,
|
UnconnectedSenders.put(author.getStringID(), new DiscordSender(author,
|
||||||
event.getMessage().getChannel(), p == null ? null : p.PlayerName().get())); // Display the playername, if found
|
event.getMessage().getChannel(), p == null ? null : p.PlayerName().get())); // Display the playername, if found
|
||||||
dsender = UnconnectedSenders.get(author.getID());
|
dsender = UnconnectedSenders.get(author.getStringID());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IUser u : event.getMessage().getMentions()) {
|
for (IUser u : event.getMessage().getMentions()) {
|
||||||
dmessage = dmessage.replace(u.mention(false), "@" + u.getName()); // TODO: IG Formatting
|
dmessage = dmessage.replace(u.mention(false), "@" + u.getName()); // TODO: IG Formatting
|
||||||
final Optional<String> nick = u.getNicknameForGuild(DiscordPlugin.mainServer);
|
final String nick = u.getNicknameForGuild(DiscordPlugin.mainServer);
|
||||||
dmessage = dmessage.replace(u.mention(true), "@" + (nick.isPresent() ? nick.get() : u.getName()));
|
dmessage = dmessage.replace(u.mention(true), "@" + (nick != null ? nick : u.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmessage.startsWith("/")) {
|
if (dmessage.startsWith("/")) {
|
||||||
|
@ -142,9 +141,9 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
|
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
|
||||||
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
|
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
|
||||||
: ""));
|
: ""));
|
||||||
event.getMessage().getChannel().getMessages().stream().forEach(m -> {
|
event.getMessage().getChannel().getMessageHistory().stream().forEach(m -> {
|
||||||
try {
|
try {
|
||||||
final IReaction reaction = m.getReactionByName(DiscordPlugin.DELIVERED_REACTION);
|
final IReaction reaction = m.getReactionByUnicode(DiscordPlugin.DELIVERED_REACTION);
|
||||||
if (reaction != null)
|
if (reaction != null)
|
||||||
DiscordPlugin.perform(() -> m.removeReaction(reaction));
|
DiscordPlugin.perform(() -> m.removeReaction(reaction));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import buttondevteam.lib.player.*;
|
||||||
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;
|
||||||
import sx.blah.discord.handle.obj.Status.StatusType;
|
|
||||||
import sx.blah.discord.util.DiscordException;
|
import sx.blah.discord.util.DiscordException;
|
||||||
import sx.blah.discord.util.MissingPermissionsException;
|
import sx.blah.discord.util.MissingPermissionsException;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ public class MCListener implements Listener {
|
||||||
final Player p = Bukkit.getPlayer(e.GetPlayer().getUUID());
|
final Player p = Bukkit.getPlayer(e.GetPlayer().getUUID());
|
||||||
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(ConnectCommand.WaitingToConnect.get(e.GetPlayer().PlayerName().get()));
|
.getUserByID(Long.parseLong(ConnectCommand.WaitingToConnect.get(e.GetPlayer().PlayerName().get())));
|
||||||
p.sendMessage("§bTo connect with the Discord account @" + user.getName() + "#" + user.getDiscriminator()
|
p.sendMessage("§bTo connect with the Discord account @" + user.getName() + "#" + user.getDiscriminator()
|
||||||
+ " 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");
|
||||||
|
@ -51,15 +50,13 @@ public class MCListener implements Listener {
|
||||||
DiscordPlayer dp = e.getPlayer().getAs(DiscordPlayer.class);
|
DiscordPlayer dp = e.getPlayer().getAs(DiscordPlayer.class);
|
||||||
if (dp == null || dp.getDiscordID() == null || dp.getDiscordID() == "")
|
if (dp == null || dp.getDiscordID() == null || dp.getDiscordID() == "")
|
||||||
return;
|
return;
|
||||||
IUser user = DiscordPlugin.dc.getUserByID(dp.getDiscordID());
|
IUser user = DiscordPlugin.dc.getUserByID(Long.parseLong(dp.getDiscordID()));
|
||||||
e.addInfo("Discord tag: " + user.getName() + "#" + user.getDiscriminator());
|
e.addInfo("Discord tag: " + user.getName() + "#" + user.getDiscriminator());
|
||||||
if (!user.getStatus().getType().equals(StatusType.NONE)) {
|
e.addInfo(user.getPresence().getStatus().toString());
|
||||||
if (user.getStatus().getType().equals(StatusType.GAME))
|
if (user.getPresence().getPlayingText().isPresent())
|
||||||
e.addInfo("Discord status: Playing " + user.getStatus().getStatusMessage());
|
e.addInfo("Playing " + user.getPresence().getPlayingText().get());
|
||||||
else if (user.getStatus().getType().equals(StatusType.STREAM))
|
else if (user.getPresence().getStreamingUrl().isPresent())
|
||||||
e.addInfo("Discord status: Streaming " + user.getStatus().getStatusMessage() + " - "
|
e.addInfo("Streaming " + user.getPresence().getStreamingUrl().get());
|
||||||
+ user.getStatus().getUrl());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
@ -85,13 +82,13 @@ public class MCListener implements Listener {
|
||||||
public void onPlayerMute(MuteStatusChangeEvent e) {
|
public void onPlayerMute(MuteStatusChangeEvent e) {
|
||||||
try {
|
try {
|
||||||
DiscordPlugin.perform(() -> {
|
DiscordPlugin.perform(() -> {
|
||||||
final IRole role = DiscordPlugin.dc.getRoleByID("164090010461667328");
|
final IRole role = DiscordPlugin.dc.getRoleByID(164090010461667328L);
|
||||||
final CommandSource source = e.getAffected().getSource();
|
final CommandSource source = e.getAffected().getSource();
|
||||||
if (!source.isPlayer())
|
if (!source.isPlayer())
|
||||||
return;
|
return;
|
||||||
final IUser user = DiscordPlugin.dc
|
final IUser user = DiscordPlugin.dc.getUserByID(
|
||||||
.getUserByID(TBMCPlayerBase.getPlayer(source.getPlayer().getUniqueId(), TBMCPlayer.class)
|
Long.parseLong(TBMCPlayerBase.getPlayer(source.getPlayer().getUniqueId(), TBMCPlayer.class)
|
||||||
.getAs(DiscordPlayer.class).getDiscordID());
|
.getAs(DiscordPlayer.class).getDiscordID())); // TODO: Use long
|
||||||
if (e.getValue())
|
if (e.getValue())
|
||||||
user.addRole(role);
|
user.addRole(role);
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class AppTest extends TestCase {
|
||||||
public void testApp() {
|
public void testApp() {
|
||||||
/*String sourcemessage = "Test message";
|
/*String sourcemessage = "Test message";
|
||||||
Exception e = new Exception("Test exception");
|
Exception e = new Exception("Test exception");
|
||||||
StringBuilder sb = TBMCCoreAPI.IsTestServer() ? new StringBuilder() : new StringBuilder("").append("\n");
|
StringBuilder sb = TBMCCoreAPI.IsTestServer() ? new StringBuilder()
|
||||||
|
: new StringBuilder("Coder role").append("\n");
|
||||||
sb.append(sourcemessage).append("\n");
|
sb.append(sourcemessage).append("\n");
|
||||||
sb.append("```").append("\n");
|
sb.append("```").append("\n");
|
||||||
String stackTrace = Arrays.stream(ExceptionUtils.getStackTrace(e).split("\\n"))
|
String stackTrace = Arrays.stream(ExceptionUtils.getStackTrace(e).split("\\n"))
|
||||||
|
@ -52,7 +53,8 @@ public class AppTest extends TestCase {
|
||||||
stackTrace = stackTrace.substring(0, 1800);
|
stackTrace = stackTrace.substring(0, 1800);
|
||||||
sb.append(stackTrace).append("\n");
|
sb.append(stackTrace).append("\n");
|
||||||
sb.append("```");
|
sb.append("```");
|
||||||
System.out.println(sb.toString()); */
|
System.out.println(sb.toString());
|
||||||
|
assertTrue(sb.toString().contains("Coder role"));*/
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue