Supporting clean installs, broadcast toggles, command improvements #92

Merged
NorbiPeti merged 14 commits from dev into master 2019-03-17 01:31:41 +00:00
5 changed files with 17 additions and 15 deletions
Showing only changes of commit 9ba57fd989 - Show all commits

View file

@ -59,7 +59,7 @@ public final class DPUtils {
return null;
if (Bukkit.isPrimaryThread()) // TODO: Ignore shutdown message <--
// throw new RuntimeException("Tried to wait for a Discord request on the main thread. This could cause lag.");
Bukkit.getLogger().warning("Waiting for a Discord request on the main thread!");
getLogger().warning("Waiting for a Discord request on the main thread!");
return RequestBuffer.request(action).get(timeout, unit); // Let the pros handle this
}
@ -72,7 +72,7 @@ public final class DPUtils {
return null;
if (Bukkit.isPrimaryThread()) // TODO: Ignore shutdown message <--
// throw new RuntimeException("Tried to wait for a Discord request on the main thread. This could cause lag.");
Bukkit.getLogger().warning("Waiting for a Discord request on the main thread!");
getLogger().warning("Waiting for a Discord request on the main thread!");
return RequestBuffer.request(action).get(); // Let the pros handle this
}

View file

@ -76,7 +76,7 @@ public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent>
@Override
public void pluginEnable() {
try {
Bukkit.getLogger().info("Initializing DiscordPlugin...");
getLogger().info("Initializing...");
plugin = this;
manager = new Command2DC();
ClientBuilder cb = new ClientBuilder();
@ -284,7 +284,7 @@ public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent>
private static IMessage sendMessageToChannel(IChannel channel, String message, EmbedObject embed, boolean wait, long timeout, TimeUnit unit) throws TimeoutException, InterruptedException {
if (message.length() > 1980) {
message = message.substring(0, 1980);
Bukkit.getLogger()
DPUtils.getLogger()
.warning("Message was too long to send to discord and got truncated. In " + channel.getName());
}
try {
@ -307,7 +307,7 @@ public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent>
} catch (TimeoutException | InterruptedException e) {
throw e;
} catch (Exception e) {
Bukkit.getLogger().warning(
DPUtils.getLogger().warning(
"Failed to deliver message to Discord! Channel: " + channel.getName() + " Message: " + message);
throw new RuntimeException(e);
}

View file

@ -4,7 +4,6 @@ import buttondevteam.discordplugin.DPUtils;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.architecture.Component;
import lombok.Getter;
import org.bukkit.Bukkit;
public class GeneralEventBroadcasterModule extends Component {
private static @Getter boolean hooked = false;
@ -13,7 +12,7 @@ public class GeneralEventBroadcasterModule extends Component {
protected void enable() {
try {
PlayerListWatcher.hookUp();
Bukkit.getLogger().info("Finished hooking into the player list");
DPUtils.getLogger().info("Finished hooking into the player list");
hooked = true;
} catch (Exception e) {
TBMCCoreAPI.SendException("Error while hacking the player list!", e);

View file

@ -1,7 +1,8 @@
package buttondevteam.discordplugin.listeners;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.commands.DiscordCommandBase;
import buttondevteam.discordplugin.commands.Command2DCSender;
import buttondevteam.lib.TBMCCoreAPI;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.IRole;
@ -38,7 +39,12 @@ public class CommandListener {
}
message.getChannel().setTypingStatus(true);
String cmdwithargsString = cmdwithargs.toString().trim(); //Remove spaces between mention and command
int index = cmdwithargsString.indexOf(" ");
try {
DiscordPlugin.plugin.getManager().handleCommand(new Command2DCSender(message), cmdwithargsString);
} catch (Exception e) {
TBMCCoreAPI.SendException("Failed to process Discord command: " + cmdwithargsString, e);
}
/*int index = cmdwithargsString.indexOf(" ");
String cmd;
String args;
if (index == -1) {
@ -48,7 +54,7 @@ public class CommandListener {
cmd = cmdwithargsString.substring(0, index);
args = cmdwithargsString.substring(index + 1).trim(); //In case there are multiple spaces
}
DiscordCommandBase.runCommand(cmd.toLowerCase(), args, message);
DiscordCommandBase.runCommand(cmd.toLowerCase(), args, message);*/
message.getChannel().setTypingStatus(false);
return true;
}

View file

@ -9,10 +9,7 @@ import buttondevteam.discordplugin.DiscordSender;
import buttondevteam.discordplugin.DiscordSenderBase;
import buttondevteam.discordplugin.listeners.CommandListener;
import buttondevteam.discordplugin.playerfaker.VanillaCommandListener;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCChatPreprocessEvent;
import buttondevteam.lib.TBMCCommandPreprocessEvent;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.*;
import buttondevteam.lib.chat.ChatMessage;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.player.TBMCPlayer;
@ -377,7 +374,7 @@ public class MCChatListener implements Listener {
: dsender.getChromaUser().channel().get().getRTR(dsender);
TBMCChatAPI.SendSystemMessage(clmd != null ? clmd.mcchannel : dsender.getChromaUser().channel().get(), rtr,
(dsender instanceof Player ? ((Player) dsender).getDisplayName()
: dsender.getName()) + " pinned a message on Discord.");
: dsender.getName()) + " pinned a message on Discord.", TBMCSystemChatEvent.BroadcastTarget.ALL);
}
else {
val cmb = ChatMessage.builder(dsender, user, getChatMessage.apply(dmessage)).fromCommand(false);