Added private Minecraft chat, Discord login, show message pinning, Maven project check, some of #12 #39

Merged
NorbiPeti merged 21 commits from dev into master 2017-07-04 16:14:01 +00:00
5 changed files with 1246 additions and 52 deletions
Showing only changes of commit cf5aaa53fb - Show all commits

43
pom.xml
View file

@ -11,8 +11,9 @@
<url>http://maven.apache.org</url>
<build>
<sourceDirectory>target/generated-sources/delombok</sourceDirectory>
<testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory>
<!-- <sourceDirectory>target/generated-sources/delombok</sourceDirectory>
<testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory> -->
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
@ -90,36 +91,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.16.0</version>
<executions>
<execution>
<id>delombok</id>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<verbose>true</verbose>
</configuration>
</execution>
<execution>
<id>test-delombok</id>
<phase>generate-test-sources</phase>
<goals>
<goal>testDelombok</goal>
</goals>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/test/java</sourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin> <groupId>org.projectlombok</groupId> <artifactId>lombok-maven-plugin</artifactId>
<version>1.16.16.0</version> <executions> <execution> <id>delombok</id> <phase>generate-sources</phase>
<goals> <goal>delombok</goal> </goals> <configuration> <addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory> <verbose>true</verbose>
</configuration> </execution> <execution> <id>test-delombok</id> <phase>generate-test-sources</phase>
<goals> <goal>testDelombok</goal> </goals> <configuration> <addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/test/java</sourceDirectory> </configuration> </execution>
</executions> </plugin> -->
</plugins>
</build>

View file

@ -318,4 +318,9 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
return null;
return RequestBuffer.request(action).get(); // Let the pros handle this
}
public static boolean checkIfSomeoneIsTestingWhileWeArent() {
return !TBMCCoreAPI.IsTestServer()
&& dc.getOurUser().getPresence().getPlayingText().orElse("").equals("testing");
}
}

View file

@ -59,7 +59,8 @@ public class CommandListener {
if (event.getMessage().getAuthor().isBot())
return;
final IChannel channel = event.getMessage().getChannel();
if (!channel.getStringID().equals(DiscordPlugin.botchannel.getStringID()) && !channel.isPrivate())
if (!channel.getStringID().equals(DiscordPlugin.botchannel.getStringID())
&& (!channel.isPrivate() || DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()))
return;
if (channel.getStringID().equals(DiscordPlugin.chatchannel.getStringID()))
return; // The chat code already handles this - Right now while testing botchannel is the same as chatchannel
@ -82,8 +83,10 @@ public class CommandListener {
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), serverReadyStrings[next]);
}
if (!event.getMessage().getChannel().isPrivate() || DiscordPlayer
.getUser(event.getAuthor().getStringID(), DiscordPlayer.class).minecraftChat().get())
if (!event.getMessage().getChannel().isPrivate() //
|| DiscordPlayer.getUser(event.getAuthor().getStringID(), DiscordPlayer.class).minecraftChat()
.get()
|| DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent())
return;
if (event.getMessage().getAuthor().isBot())
return;

View file

@ -17,6 +17,7 @@ import buttondevteam.lib.*;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.player.TBMCPlayer;
import lombok.val;
import sx.blah.discord.api.events.IListener;
import sx.blah.discord.api.internal.json.objects.EmbedObject;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
@ -62,7 +63,8 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
}
};
if (e.getChannel().equals(Channel.GlobalChat))
doit.accept(lastmsgdata);
doit.accept(
lastmsgdata == null ? lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel) : lastmsgdata);
for (LastMsgData data : lastmsgPerUser) {
final IUser iUser = data.channel.getUsersHere().stream()
@ -110,7 +112,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
private static final String[] UnconnectedCmds = new String[] { "list", "u", "shrug", "tableflip", "unflip", "mwiki",
"yeehaw" };
private static LastMsgData lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel);
private static LastMsgData lastmsgdata;
private static short lastlist = 0;
private static short lastlistp = 0;
/**
@ -128,15 +130,16 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
public static short ListC = 0;
public static void resetLastMessage() {
lastmsgdata.message = null; // Don't set the whole object to null, the player and channel information should be preserved
}
(lastmsgdata == null ? lastmsgdata = new LastMsgData(DiscordPlugin.chatchannel) : lastmsgdata).message = null; // Don't set the whole object to null, the player and channel information should
} // be preserved
@Override // Discord
public void handle(MessageReceivedEvent event) {
final IUser author = event.getMessage().getAuthor();
final DiscordPlayer user = DiscordPlayer.getUser(author.getStringID(), DiscordPlayer.class);
val author = event.getMessage().getAuthor();
val user = DiscordPlayer.getUser(author.getStringID(), DiscordPlayer.class);
if (!event.getMessage().getChannel().getStringID().equals(DiscordPlugin.chatchannel.getStringID())
&& !(event.getMessage().getChannel().isPrivate() && user.minecraftChat().get()))
&& !(event.getMessage().getChannel().isPrivate() && user.minecraftChat().get()
&& !DiscordPlugin.checkIfSomeoneIsTestingWhileWeArent()))
return;
resetLastMessage();
lastlist++;