Merge pull request #26 from TBMCPlugins/dev

Fixes, added game roles, commands in mcchat, smaller additions
This commit is contained in:
Norbi Peti 2017-04-15 14:02:56 +02:00 committed by GitHub
commit 17c98b6edd
15 changed files with 265 additions and 125 deletions

View file

@ -11,11 +11,8 @@ public class DiscordPlayer extends ChromaGamerBase {
}
public String getDiscordID() {
return did;
}
@Override
public String getFileName() {
if (did == null)
did = plugindata.getString(getFolder() + "_id");
return did;
}
}

View file

@ -1,9 +1,9 @@
package buttondevteam.discordplugin;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
@ -23,7 +23,9 @@ import sx.blah.discord.api.events.IListener;
import sx.blah.discord.api.internal.json.objects.EmbedObject;
import sx.blah.discord.handle.impl.events.ReadyEvent;
import sx.blah.discord.handle.obj.*;
import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.EmbedBuilder;
import sx.blah.discord.util.MissingPermissionsException;
import sx.blah.discord.util.RateLimitException;
public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
@ -32,24 +34,17 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
public static IDiscordClient dc;
public static DiscordPlugin plugin;
public static boolean SafeMode = true;
public static List<String> GameRoles;
@SuppressWarnings("unchecked")
@Override
public void onEnable() {
try {
Bukkit.getLogger().info("Initializing DiscordPlugin...");
plugin = this;
final File file = new File("TBMC", "DiscordRedditLastAnnouncement.txt");
if (file.exists()) {
BufferedReader reader = Files.newReader(file, StandardCharsets.UTF_8);
String line = reader.readLine();
lastannouncementtime = Long.parseLong(line);
reader.close();
file.delete();
} else {
lastannouncementtime = getConfig().getLong("lastannouncementtime");
lastseentime = getConfig().getLong("lastseentime");
saveConfig();
}
GameRoles = (List<String>) getConfig().getList("gameroles", new ArrayList<String>());
ClientBuilder cb = new ClientBuilder();
cb.withToken(Files.readFirstLine(new File("TBMC", "Token.txt"), StandardCharsets.UTF_8));
dc = cb.login();
@ -74,6 +69,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
public static IGuild devServer;
private static volatile BukkitTask task;
private static volatile boolean sent = false;
@Override
public void handle(ReadyEvent event) {
@ -110,6 +106,20 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
SafeMode = false;
if (task != null)
task.cancel();
if (!sent) {
sendMessageToChannel(chatchannel, "", new EmbedBuilder().withColor(Color.GREEN)
.withTitle("Server started - chat connected.").build());
try {
List<IMessage> msgs = genchannel.getPinnedMessages();
for (int i = msgs.size() - 1; i >= 10; i--) { // Unpin all pinned messages except the newest 10
genchannel.unpin(msgs.get(i));
Thread.sleep(10);
}
} catch (Exception e) {
TBMCCoreAPI.SendException("Error occured while unpinning messages!", e);
}
sent = true;
}
}, 0, 10);
for (IListener<?> listener : CommandListener.getListeners())
dc.getDispatcher().registerListener(listener);
@ -121,20 +131,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(), this);
TBMCChatAPI.AddCommands(this, DiscordMCCommandBase.class);
TBMCCoreAPI.RegisterUserClass(DiscordPlayer.class);
Bukkit.getScheduler().runTaskAsynchronously(this, () -> sendMessageToChannel(chatchannel, "",
new EmbedBuilder().withColor(Color.GREEN).withTitle("Server started - chat connected.").build()));
Runnable r = new Runnable() {
public void run() {
AnnouncementGetterThreadMethod();
}
};
Thread t = new Thread(r);
t.start();
List<IMessage> msgs = genchannel.getPinnedMessages();
for (int i = msgs.size() - 1; i >= 10; i--) { // Unpin all pinned messages except the newest 10
genchannel.unpin(msgs.get(i));
}
new Thread(() -> AnnouncementGetterThreadMethod()).start();
setupProviders();
TBMCCoreAPI.SendUnsentExceptions();
TBMCCoreAPI.SendUnsentDebugMessages();
@ -153,6 +150,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
stop = true;
getConfig().set("lastannouncementtime", lastannouncementtime);
getConfig().set("lastseentime", lastseentime);
getConfig().set("gameroles", GameRoles);
saveConfig();
sendMessageToChannel(chatchannel, "", new EmbedBuilder().withColor(Restart ? Color.ORANGE : Color.RED)
.withTitle(Restart ? "Server restarting" : "Server stopping").build());
@ -233,37 +231,19 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
Bukkit.getLogger()
.warning("Message was too long to send to discord and got truncated. In " + channel.getName());
}
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(i * 100);
} catch (InterruptedException e2) {
e2.printStackTrace();
}
try {
if (SafeMode)
return null;
if (channel == chatchannel)
MCChatListener.resetLastMessage(); // If this is a chat message, it'll be set again
final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel
? "*The following message is from a test server*\n" + message : message;
return embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false);
} catch (RateLimitException e) {
try {
Thread.sleep(e.getRetryDelay());
} catch (InterruptedException e1) {
e1.printStackTrace();
}
return perform(
() -> embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false));
} catch (Exception e) {
if (i == 9) {
Bukkit.getLogger().warning("Failed to deliver message to Discord! Channel: " + channel.getName()
+ " Message: " + message);
Bukkit.getLogger().warning(
"Failed to deliver message to Discord! Channel: " + channel.getName() + " Message: " + message);
throw new RuntimeException(e);
} else
continue;
}
}
return null;
}
public static Permission perms;
@ -299,4 +279,43 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
}
return sanitizedString;
}
/**
* Performs Discord actions, retrying when ratelimited. May return null if action fails too many times or in safe mode.
*/
public static <T extends IDiscordObject<T>> T perform(DiscordSupplier<T> action)
throws DiscordException, MissingPermissionsException {
for (int i = 0; i < 20; i++)
try {
if (SafeMode)
return null;
return action.get();
} catch (RateLimitException e) {
try {
Thread.sleep(e.getRetryDelay() > 0 ? e.getRetryDelay() : 10);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
return null;
}
/**
* Performs Discord actions, retrying when ratelimited.
*/
public static void perform(DiscordRunnable action) throws DiscordException, MissingPermissionsException {
for (int i = 0; i < 20; i++)
try {
if (SafeMode)
return;
action.run();
return; // Gotta escape that loop
} catch (RateLimitException e) {
try {
Thread.sleep(e.getRetryDelay() > 0 ? e.getRetryDelay() : 10);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

View file

@ -0,0 +1,10 @@
package buttondevteam.discordplugin;
import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.MissingPermissionsException;
import sx.blah.discord.util.RateLimitException;
@FunctionalInterface
public interface DiscordRunnable {
public abstract void run() throws DiscordException, RateLimitException, MissingPermissionsException;
}

View file

@ -13,10 +13,17 @@ import sx.blah.discord.handle.obj.IUser;
public class DiscordSender extends DiscordSenderBase implements CommandSender {
private PermissibleBase perm = new PermissibleBase(this);
private String name = null;
public DiscordSender(IUser user, IChannel channel) {
super(user, channel);
}
public DiscordSender(IUser user, IChannel channel, String name) {
super(user, channel);
this.name = name;
}
@Override
public boolean isPermissionSet(String name) {
return perm.isPermissionSet(name);
@ -92,7 +99,7 @@ public class DiscordSender extends DiscordSenderBase implements CommandSender {
public String getName() {
if (user == null)
return "Discord user";
return user.getDisplayName(DiscordPlugin.mainServer);
return name == null ? user.getDisplayName(DiscordPlugin.mainServer) : name;
}
}

View file

@ -0,0 +1,11 @@
package buttondevteam.discordplugin;
import sx.blah.discord.handle.obj.IDiscordObject;
import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.MissingPermissionsException;
import sx.blah.discord.util.RateLimitException;
@FunctionalInterface
public interface DiscordSupplier<T extends IDiscordObject<T>> {
public abstract T get() throws DiscordException, RateLimitException, MissingPermissionsException;
}

View file

@ -9,6 +9,7 @@ import com.google.common.collect.HashBiMap;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.player.ChromaGamerBase;
import buttondevteam.lib.player.TBMCPlayer;
import buttondevteam.lib.player.TBMCPlayerBase;
import sx.blah.discord.handle.obj.IMessage;

View file

@ -19,6 +19,7 @@ public abstract class DiscordCommandBase {
commands.put("connect", new ConnectCommand()); // TODO: API for adding commands?
commands.put("userinfo", new UserinfoCommand());
commands.put("help", new HelpCommand());
commands.put("role", new RoleCommand());
}
public static void runCommand(String cmd, String args, IMessage message) {

View file

@ -0,0 +1,103 @@
package buttondevteam.discordplugin.commands;
import java.util.List;
import java.util.stream.Collectors;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.lib.TBMCCoreAPI;
import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.IRole;
public class RoleCommand extends DiscordCommandBase {
@Override
public String getCommandName() {
return "role";
}
@Override
public void run(IMessage message, String args) {
final String usagemsg = "Subcommands: add, remove, list";
if (args.length() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), usagemsg);
return;
}
String[] argsa = args.split(" ");
if (argsa[0].equalsIgnoreCase("add")) {
final IRole role = checkAndGetRole(message, argsa, "This command adds a game role to your account.");
if (role == null)
return;
try {
DiscordPlugin.perform(() -> message.getAuthor().addRole(role));
DiscordPlugin.sendMessageToChannel(message.getChannel(), "Added game role.");
} catch (Exception e) {
TBMCCoreAPI.SendException("Error while adding role!", e);
DiscordPlugin.sendMessageToChannel(message.getChannel(), "An error occured while adding the role.");
}
} else if (argsa[0].equalsIgnoreCase("remove")) {
final IRole role = checkAndGetRole(message, argsa, "This command removes a game role from your account.");
if (role == null)
return;
try {
DiscordPlugin.perform(() -> message.getAuthor().removeRole(role));
DiscordPlugin.sendMessageToChannel(message.getChannel(), "Removed game role.");
} catch (Exception e) {
TBMCCoreAPI.SendException("Error while removing role!", e);
DiscordPlugin.sendMessageToChannel(message.getChannel(), "An error occured while removing the role.");
}
} else if (argsa[0].equalsIgnoreCase("list")) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"List of game roles:\n" + DiscordPlugin.GameRoles.stream().collect(Collectors.joining("\n")));
} else if (argsa[0].equalsIgnoreCase("addrole")) {
final List<IRole> roles = (TBMCCoreAPI.IsTestServer() ? DiscordPlugin.devServer : DiscordPlugin.mainServer)
.getRolesByName(argsa[1]);
if (roles.size() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), "That role cannot be found on Discord.");
return;
}
if (roles.size() > 1) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"There are more roles with this name. Why are there more roles with this name?");
return;
}
DiscordPlugin.GameRoles.add(roles.get(0).getName());
DiscordPlugin.sendMessageToChannel(message.getChannel(), "Game role added.");
}
}
private IRole checkAndGetRole(IMessage message, String[] argsa, String usage) {
if (argsa.length < 2) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), usage + "\nUsage: " + argsa[0] + " <rolename>");
return null;
}
if (!DiscordPlugin.GameRoles.contains(argsa[1])) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"That game role cannot be found.\nList of game roles:\n"
+ DiscordPlugin.GameRoles.stream().collect(Collectors.joining("\n")));
return null;
}
final List<IRole> roles = (TBMCCoreAPI.IsTestServer() ? DiscordPlugin.devServer : DiscordPlugin.mainServer)
.getRolesByName(argsa[1]);
if (roles.size() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"The specified role cannot be found on Discord! Removing from the list.");
DiscordPlugin.GameRoles.remove(argsa[1].toLowerCase());
return null;
}
if (roles.size() > 1) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"There are more roles with this name. Why are there more roles with this name?");
return null;
}
return roles.get(0);
}
@Override
public String[] getHelpText() {
return new String[] { //
"Add or remove game roles from yourself.", //
"Usage: role add|remove <name> or role list", //
"Mods can use role addrole <name> to add a role as a game role" };
}
}

View file

@ -31,7 +31,6 @@ public class UserinfoCommand extends DiscordCommandBase {
if (args.length() == 0)
target = message.getAuthor();
else {
final Optional<IUser> firstmention = message.getMentions().stream()
.filter(m -> !m.getID().equals(DiscordPlugin.dc.getOurUser().getID())).findFirst();
if (firstmention.isPresent())
@ -77,7 +76,7 @@ public class UserinfoCommand extends DiscordCommandBase {
DiscordPlugin.sendMessageToChannel(message.getChannel(), uinfo.toString());
} catch (Exception e) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), "An error occured while getting the user!");
TBMCCoreAPI.SendException("Error while getting DiscordPlayer info!", e);
TBMCCoreAPI.SendException("Error while getting info about " + target.getName() + "!", e);
}
}

View file

@ -10,7 +10,6 @@ import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
import sx.blah.discord.handle.obj.IEmbed;
import sx.blah.discord.util.EmbedBuilder;
import sx.blah.discord.util.RateLimitException;
public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
@Override
@ -34,7 +33,7 @@ public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
new DiscordSender(null,
TBMCCoreAPI.IsTestServer() //
? DiscordPlugin.chatchannel //
: DiscordPlugin.updatechannel),
: DiscordPlugin.botroomchannel),
branch)
&& ((Supplier<Boolean>) () -> { // Best looking code I've ever written
try {
@ -57,16 +56,8 @@ public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
}
return true;
}).get() && (!TBMCCoreAPI.IsTestServer() || !branch.equals("master")))
while (true)
try {
event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION);
break;
} catch (RateLimitException e) {
try {
if (e.getRetryDelay() > 0)
Thread.sleep(e.getRetryDelay());
} catch (InterruptedException ie) {
}
DiscordPlugin.perform(() -> event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION));
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while reacting to plugin update!", e);
}

View file

@ -21,6 +21,8 @@ public class CommandListener {
final IChannel channel = event.getMessage().getChannel();
if (!channel.getID().equals(DiscordPlugin.botchannel.getID()) && !channel.isPrivate())
return;
if (channel.getID().equals(DiscordPlugin.chatchannel.getID()))
return; // The chat code already handles this - Right now while testing botchannel is the same as chatchannel
runCommand(event.getMessage(), true);
}
}, new IListener<MessageReceivedEvent>() {

View file

@ -10,7 +10,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.TBMCExceptionEvent;
import sx.blah.discord.handle.obj.IRole;
public class ExceptionListener implements Listener {
private List<Throwable> lastthrown = new ArrayList<>();
@ -35,9 +37,14 @@ public class ExceptionListener implements Listener {
e.setHandled();
}
private static IRole coderRole;
private static void SendException(Throwable e, String sourcemessage) {
try {
StringBuilder sb = new StringBuilder();
if (coderRole == null)
coderRole = DiscordPlugin.devServer.getRolesByName("Coder").get(0);
StringBuilder sb = TBMCCoreAPI.IsTestServer() ? new StringBuilder()
: new StringBuilder(coderRole.mention()).append("\n");
sb.append(sourcemessage).append("\n");
sb.append("```").append("\n");
String stackTrace = Arrays.stream(ExceptionUtils.getStackTrace(e).split("\\n"))

View file

@ -13,6 +13,7 @@ import buttondevteam.discordplugin.*;
import buttondevteam.lib.*;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.player.ChromaGamerBase;
import buttondevteam.lib.player.TBMCPlayer;
import sx.blah.discord.api.events.IListener;
import sx.blah.discord.api.internal.json.objects.EmbedObject;
@ -46,8 +47,8 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
try {
embedObject.description = lastmessage.getEmbedded().get(0).getDescription() + "\n"
+ embedObject.description;
lastmessage.edit("", embedObject);
} catch (MissingPermissionsException | RateLimitException | DiscordException e1) {
DiscordPlugin.perform(() -> lastmessage.edit("", embedObject));
} catch (MissingPermissionsException | DiscordException e1) {
TBMCCoreAPI.SendException("An error occured while editing chat message!", e1);
}
} // TODO: Author URL
@ -83,20 +84,21 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
return;
String dmessage = event.getMessage().getContent();
try {
Optional<? extends Player> player = Bukkit.getOnlinePlayers().stream().filter(p -> { // TODO: Support offline players
DiscordPlayer dp = TBMCPlayer.getPlayer(p.getUniqueId(), TBMCPlayer.class).getAs(DiscordPlayer.class); // Not changing any data, don't need to save
return dp != null && author.getID().equals(dp.getDiscordID());
}).findAny();
DiscordPlayer dp = ChromaGamerBase.getUser(author.getID(), DiscordPlayer.class);
final DiscordSenderBase dsender;
if (player.isPresent()) // Connected?
{ // Execute as ingame player
Player mcp = null; // Offline players can't really run commands
final String cid;
if ((cid = dp.getConnectedID(TBMCPlayer.class)) != null // Connected?
&& (mcp = Bukkit.getPlayer(cid)) != null) { // Execute as ingame player, if online
if (!ConnectedSenders.containsKey(author.getID()))
ConnectedSenders.put(author.getID(),
new DiscordPlayerSender(author, event.getMessage().getChannel(), player.get()));
new DiscordPlayerSender(author, event.getMessage().getChannel(), mcp));
dsender = ConnectedSenders.get(author.getID());
} else {
TBMCPlayer p = dp.getAs(TBMCPlayer.class);
if (!UnconnectedSenders.containsKey(author.getID()))
UnconnectedSenders.put(author.getID(), new DiscordSender(author, event.getMessage().getChannel()));
UnconnectedSenders.put(author.getID(), new DiscordSender(author, event.getMessage().getChannel(),
p == null ? null : p.PlayerName().get())); // Display the playername, if found
dsender = UnconnectedSenders.get(author.getID());
}
@ -108,7 +110,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
if (dmessage.startsWith("/")) {
final String cmd = dmessage.substring(1).toLowerCase();
if (!player.isPresent()
if (mcp == null
&& !Arrays.stream(UnconnectedCmds).anyMatch(s -> cmd.equals(s) || cmd.startsWith(s + " "))) {
// Command not whitelisted
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), // TODO
@ -130,7 +132,9 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
} else
Bukkit.dispatchCommand(dsender, cmd);
lastlistp = (short) Bukkit.getOnlinePlayers().size();
} else
if (!event.getMessage().isDeleted())
event.getMessage().delete();
} else {
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, dsender,
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
@ -138,30 +142,13 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
event.getMessage().getChannel().getMessages().stream().forEach(m -> {
try {
final IReaction reaction = m.getReactionByName(DiscordPlugin.DELIVERED_REACTION);
if (reaction != null) {
while (true)
try {
m.removeReaction(reaction);
Thread.sleep(100);
break;
} catch (RateLimitException e) {
if (e.getRetryDelay() > 0)
Thread.sleep(e.getRetryDelay());
}
}
if (reaction != null)
DiscordPlugin.perform(() -> m.removeReaction(reaction));
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while removing reactions from chat!", e);
}
});
while (true)
try {
event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION);
break;
} catch (RateLimitException e) {
if (e.getRetryDelay() > 0)
Thread.sleep(e.getRetryDelay());
else
Thread.sleep(100);
DiscordPlugin.perform(() -> event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION));
}
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while handling message \"" + dmessage + "\"!", e);

View file

@ -11,10 +11,8 @@ import org.bukkit.event.server.ServerCommandEvent;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.player.TBMCPlayerGetInfoEvent;
import buttondevteam.lib.player.TBMCPlayerJoinEvent;
import buttondevteam.lib.player.TBMCPlayerQuitEvent;
import net.ess3.api.events.AfkStatusChangeEvent;
import buttondevteam.lib.player.*;
import net.ess3.api.events.*;
import sx.blah.discord.handle.obj.IUser;
import sx.blah.discord.handle.obj.Status.StatusType;
@ -45,6 +43,9 @@ public class MCListener implements Listener {
if (DiscordPlugin.SafeMode)
return;
DiscordPlayer dp = e.getPlayer().getAs(DiscordPlayer.class);
/*System.out.println("dp: " + dp);
if (dp != null)
System.out.println("dp.did: " + dp.getDiscordID());*/
if (dp == null || dp.getDiscordID() == null || dp.getDiscordID() == "")
return;
IUser user = DiscordPlugin.dc.getUserByID(dp.getDiscordID());
@ -74,4 +75,8 @@ public class MCListener implements Listener {
public void onServerCommand(ServerCommandEvent e) {
DiscordPlugin.Restart = !e.getCommand().equalsIgnoreCase("stop"); // The variable is always true except if stopped
}
/*
* @EventHandler public void onPlayerMute(MuteStatusChangeEvent e) { e.getAffected() }
*/
}

View file

@ -46,7 +46,7 @@ public class AcceptMCCommand extends DiscordMCCommandBase {
}
DiscordPlayer dp = ChromaGamerBase.getUser(did, DiscordPlayer.class);
TBMCPlayer mcp = TBMCPlayerBase.getPlayer(((Player) sender).getUniqueId(), TBMCPlayer.class);
dp.connectWith(mcp); // TODO: Fix null.yml and empty playerinfos
dp.connectWith(mcp);
dp.save();
mcp.save();
ConnectCommand.WaitingToConnect.remove(sender.getName());