Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #36 from BtoBastian/development
Browse files Browse the repository at this point in the history
Merge development branch
  • Loading branch information
Bastian authored Jan 16, 2018
2 parents 6d6c421 + 8f569ee commit 9534b3a
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 23 deletions.
35 changes: 34 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j</artifactId>
<packaging>pom</packaging>
<version>1.0.8</version>
<version>1.0.9</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -32,6 +32,39 @@
<target>1.8</target>
</configuration>
</plugin>

<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>

<extensions>
Expand Down
35 changes: 34 additions & 1 deletion sdcf4j-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.8</version>
<version>1.0.9</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -23,6 +23,39 @@
<target>1.7</target>
</configuration>
</plugin>

<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
38 changes: 36 additions & 2 deletions sdcf4j-discord4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.8</version>
<version>1.0.9</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -23,6 +23,39 @@
<target>1.8</target>
</configuration>
</plugin>

<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -45,7 +78,8 @@
<dependency>
<groupId>com.github.austinv11</groupId>
<artifactId>Discord4j</artifactId>
<version>2.9.2</version>
<version>2.9.3</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean hasPermission(IUser user, String permission) {
* @param event The MessageReceivedEvent.
*/
private void handleMessageCreate(final MessageReceivedEvent event) {
String[] splitMessage = event.getMessage().getContent().split(" ");
String[] splitMessage = event.getMessage().getContent().split("[\\s&&[^\\n]]++");
String commandString = splitMessage[0];
SimpleCommand command = commands.get(commandString.toLowerCase());
if (command == null) {
Expand Down Expand Up @@ -121,11 +121,8 @@ private void handleMessageCreate(final MessageReceivedEvent event) {
final Object[] parameters = getParameters(splitMessage, command, event);
if (commandAnnotation.async()) {
final SimpleCommand commandFinal = command;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
invokeMethod(commandFinal, event, parameters);
}
Thread t = new Thread(() -> {
invokeMethod(commandFinal, event, parameters);
});
t.setDaemon(true);
t.start();
Expand Down
38 changes: 36 additions & 2 deletions sdcf4j-javacord/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.8</version>
<version>1.0.9</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -23,6 +23,39 @@
<target>1.8</target>
</configuration>
</plugin>

<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -44,7 +77,8 @@
<dependency>
<groupId>de.btobastian</groupId>
<artifactId>Javacord</artifactId>
<version>6f357bc</version>
<version>8ded4aa</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void handleMessageCreate(DiscordApi api, final Message message) {
if (message.getUserAuthor().map(User::isYourself).orElse(false)) {
return;
}
String[] splitMessage = message.getContent().split(" ");
String[] splitMessage = message.getContent().split("[\\s&&[^\\n]]++");
String commandString = splitMessage[0];
SimpleCommand command = commands.get(commandString.toLowerCase());
if (command == null) {
Expand Down Expand Up @@ -118,12 +118,7 @@ private void handleMessageCreate(DiscordApi api, final Message message) {
final Object[] parameters = getParameters(splitMessage, command, message, api);
if (commandAnnotation.async()) {
final SimpleCommand commandFinal = command;
api.getThreadPool().getExecutorService().submit(new Runnable() {
@Override
public void run() {
invokeMethod(commandFinal, message, parameters);
}
});
api.getThreadPool().getExecutorService().submit(() -> invokeMethod(commandFinal, message, parameters));
} else {
invokeMethod(command, message, parameters);
}
Expand Down
38 changes: 36 additions & 2 deletions sdcf4j-jda3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.8</version>
<version>1.0.9</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -23,6 +23,39 @@
<target>1.8</target>
</configuration>
</plugin>

<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -46,7 +79,8 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.3.1_304</version>
<version>3.5.0_327</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;

/**
* A command handler for the JDA library.
Expand Down Expand Up @@ -88,7 +89,7 @@ private void handleMessageCreate(final MessageReceivedEvent event) {
if (event.getAuthor() == jda.getSelfUser()) {
return;
}
String[] splitMessage = event.getMessage().getRawContent().split(" ");
String[] splitMessage = event.getMessage().getContentRaw().split("[\\s&&[^\\n]]++");
String commandString = splitMessage[0];
SimpleCommand command = commands.get(commandString.toLowerCase());
if (command == null) {
Expand Down Expand Up @@ -116,7 +117,7 @@ private void handleMessageCreate(final MessageReceivedEvent event) {
}
if (!hasPermission(event.getAuthor(), commandAnnotation.requiredPermissions())) {
if (Sdcf4jMessage.MISSING_PERMISSIONS.getMessage() != null) {
event.getChannel().sendMessage(Sdcf4jMessage.MISSING_PERMISSIONS.getMessage());
event.getChannel().sendMessage(Sdcf4jMessage.MISSING_PERMISSIONS.getMessage()).queue();
}
return;
}
Expand Down

0 comments on commit 9534b3a

Please sign in to comment.