-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c2f46f3
Showing
44 changed files
with
1,330 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>me.Joshb</groupId> | ||
<artifactId>DiscordBotAPI</artifactId> | ||
<version>1.0.0</version> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<targetPath>.</targetPath> | ||
<filtering>true</filtering> | ||
<directory>${basedir}/src/main/resources/</directory> | ||
<includes> | ||
<include>plugin.yml</include> | ||
<include>Config.yml</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.4.3</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>jcenter</id> | ||
<name>jcenter-bintray</name> | ||
<url>https://jcenter.bintray.com</url> | ||
</repository> | ||
<repository> | ||
<id>bukkit-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
<repository> | ||
<id>bungeecord-repo</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.16.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>commons-lang</artifactId> | ||
<groupId>commons-lang</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>guava</artifactId> | ||
<groupId>com.google.guava</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>gson</artifactId> | ||
<groupId>com.google.code.gson</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>bungeecord-chat</artifactId> | ||
<groupId>net.md-5</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>snakeyaml</artifactId> | ||
<groupId>org.yaml</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.md-5</groupId> | ||
<artifactId>bungeecord-api</artifactId> | ||
<version>1.15-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>bungeecord-config</artifactId> | ||
<groupId>net.md-5</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>bungeecord-event</artifactId> | ||
<groupId>net.md-5</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>bungeecord-protocol</artifactId> | ||
<groupId>net.md-5</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>netty-transport-native-unix-common</artifactId> | ||
<groupId>io.netty</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>bungeecord-chat</artifactId> | ||
<groupId>net.md-5</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>snakeyaml</artifactId> | ||
<groupId>org.yaml</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>guava</artifactId> | ||
<groupId>com.google.guava</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>me.Joshb</groupId> | ||
<artifactId>DiscordBotAPI</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<targetPath>.</targetPath> | ||
<filtering>true</filtering> | ||
<directory>${basedir}/src/main/resources/</directory> | ||
<includes> | ||
<include>plugin.yml</include> | ||
<include>Config.yml</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.4.3</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jcenter</id> | ||
<name>jcenter-bintray</name> | ||
<url>https://jcenter.bintray.com</url> | ||
</repository> | ||
<repository> | ||
<id>bukkit-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
<repository> | ||
<id>bungeecord-repo</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</repository> | ||
</repositories> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.16.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.md-5</groupId> | ||
<artifactId>bungeecord-api</artifactId> | ||
<version>1.15-SNAPSHOT</version> | ||
<type>jar</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.dv8tion</groupId> | ||
<artifactId>JDA</artifactId> | ||
<version>4.2.0_217</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>club.minnced</groupId> | ||
<artifactId>opus-java</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package me.joshb.bungee; | ||
|
||
import net.md_5.bungee.config.Configuration; | ||
import net.md_5.bungee.config.ConfigurationProvider; | ||
import net.md_5.bungee.config.YamlConfiguration; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class Config { | ||
|
||
private String fileName = "Config"; | ||
|
||
Configuration config; | ||
ConfigurationProvider configp; | ||
|
||
File file; | ||
|
||
public Config(){ } | ||
private static Config instance = new Config(); | ||
public static Config getInstance(){ | ||
return instance; | ||
} | ||
|
||
public Configuration getConfig(){ | ||
return config; | ||
} | ||
|
||
|
||
public void initialize(){ | ||
if (!DiscordBotAPI.plugin.getDataFolder().exists()) { | ||
DiscordBotAPI.plugin.getDataFolder().mkdir(); | ||
} | ||
|
||
file = new File(DiscordBotAPI.plugin.getDataFolder(), fileName + ".yml"); | ||
|
||
try{ | ||
if(!file.exists()){ | ||
file.createNewFile(); | ||
} | ||
} catch (IOException e){ | ||
e.printStackTrace(); | ||
} | ||
|
||
configp = ConfigurationProvider.getProvider(YamlConfiguration.class); | ||
try{ | ||
config = configp.load(file); | ||
} catch (IOException e){ | ||
e.printStackTrace(); | ||
} | ||
initSections(); | ||
save(); | ||
} | ||
|
||
public void initSections(){ | ||
if(!config.contains("Bot.Token")){ | ||
config.set("Bot.Token", "token_here"); | ||
} | ||
} | ||
|
||
public void save() { | ||
try { | ||
configp = ConfigurationProvider.getProvider(YamlConfiguration.class); | ||
configp.save(config, file); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void reload(){ | ||
try { | ||
configp = ConfigurationProvider.getProvider(YamlConfiguration.class); | ||
} catch (Exception e){ | ||
System.out.println("COULD NOT RELOAD FILE: " + fileName); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.joshb.bungee; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.JDABuilder; | ||
import net.md_5.bungee.api.plugin.Plugin; | ||
|
||
import javax.security.auth.login.LoginException; | ||
|
||
public class DiscordBotAPI extends Plugin { | ||
|
||
public static JDA jda; | ||
|
||
public static DiscordBotAPI plugin; | ||
|
||
public void onEnable(){ | ||
plugin = this; | ||
|
||
Config.getInstance().initialize(); | ||
|
||
if(Config.getInstance().getConfig().getString("Bot.Token").equals("token_here")){ | ||
getLogger().severe("Plugin Disabled. The bot token is invalid."); | ||
return; | ||
} | ||
|
||
JDABuilder builder = JDABuilder.createDefault(Config.getInstance().getConfig().getString("Bot.Token")); | ||
|
||
try { | ||
jda = builder.build(); | ||
} catch (LoginException e) { | ||
getLogger().severe("Plugin Disabled. The bot token is invalid. Reason: " + e.getMessage()); | ||
} | ||
} | ||
|
||
public void onDisable(){ | ||
if(jda != null){ | ||
jda.shutdown(); | ||
} | ||
} | ||
|
||
public static JDA getJDA(){ | ||
return jda; | ||
} | ||
} |
Oops, something went wrong.