Skip to content

Commit c2f46f3

Browse files
committed
test
0 parents  commit c2f46f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1330
-0
lines changed

DiscordBotAPI.iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4" />

dependency-reduced-pom.xml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>me.Joshb</groupId>
5+
<artifactId>DiscordBotAPI</artifactId>
6+
<version>1.0.0</version>
7+
<build>
8+
<sourceDirectory>src/main/java</sourceDirectory>
9+
<resources>
10+
<resource>
11+
<targetPath>.</targetPath>
12+
<filtering>true</filtering>
13+
<directory>${basedir}/src/main/resources/</directory>
14+
<includes>
15+
<include>plugin.yml</include>
16+
<include>Config.yml</include>
17+
</includes>
18+
</resource>
19+
</resources>
20+
<plugins>
21+
<plugin>
22+
<artifactId>maven-compiler-plugin</artifactId>
23+
<version>3.5.1</version>
24+
<configuration>
25+
<source>1.8</source>
26+
<target>1.8</target>
27+
</configuration>
28+
</plugin>
29+
<plugin>
30+
<artifactId>maven-shade-plugin</artifactId>
31+
<version>2.4.3</version>
32+
<executions>
33+
<execution>
34+
<phase>package</phase>
35+
<goals>
36+
<goal>shade</goal>
37+
</goals>
38+
</execution>
39+
</executions>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
<repositories>
44+
<repository>
45+
<id>jcenter</id>
46+
<name>jcenter-bintray</name>
47+
<url>https://jcenter.bintray.com</url>
48+
</repository>
49+
<repository>
50+
<id>bukkit-repo</id>
51+
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
52+
</repository>
53+
<repository>
54+
<id>bungeecord-repo</id>
55+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
56+
</repository>
57+
</repositories>
58+
<dependencies>
59+
<dependency>
60+
<groupId>org.spigotmc</groupId>
61+
<artifactId>spigot-api</artifactId>
62+
<version>1.16.1-R0.1-SNAPSHOT</version>
63+
<scope>provided</scope>
64+
<exclusions>
65+
<exclusion>
66+
<artifactId>commons-lang</artifactId>
67+
<groupId>commons-lang</groupId>
68+
</exclusion>
69+
<exclusion>
70+
<artifactId>guava</artifactId>
71+
<groupId>com.google.guava</groupId>
72+
</exclusion>
73+
<exclusion>
74+
<artifactId>gson</artifactId>
75+
<groupId>com.google.code.gson</groupId>
76+
</exclusion>
77+
<exclusion>
78+
<artifactId>bungeecord-chat</artifactId>
79+
<groupId>net.md-5</groupId>
80+
</exclusion>
81+
<exclusion>
82+
<artifactId>snakeyaml</artifactId>
83+
<groupId>org.yaml</groupId>
84+
</exclusion>
85+
</exclusions>
86+
</dependency>
87+
<dependency>
88+
<groupId>net.md-5</groupId>
89+
<artifactId>bungeecord-api</artifactId>
90+
<version>1.15-SNAPSHOT</version>
91+
<scope>provided</scope>
92+
<exclusions>
93+
<exclusion>
94+
<artifactId>bungeecord-config</artifactId>
95+
<groupId>net.md-5</groupId>
96+
</exclusion>
97+
<exclusion>
98+
<artifactId>bungeecord-event</artifactId>
99+
<groupId>net.md-5</groupId>
100+
</exclusion>
101+
<exclusion>
102+
<artifactId>bungeecord-protocol</artifactId>
103+
<groupId>net.md-5</groupId>
104+
</exclusion>
105+
<exclusion>
106+
<artifactId>netty-transport-native-unix-common</artifactId>
107+
<groupId>io.netty</groupId>
108+
</exclusion>
109+
<exclusion>
110+
<artifactId>bungeecord-chat</artifactId>
111+
<groupId>net.md-5</groupId>
112+
</exclusion>
113+
<exclusion>
114+
<artifactId>snakeyaml</artifactId>
115+
<groupId>org.yaml</groupId>
116+
</exclusion>
117+
<exclusion>
118+
<artifactId>guava</artifactId>
119+
<groupId>com.google.guava</groupId>
120+
</exclusion>
121+
</exclusions>
122+
</dependency>
123+
</dependencies>
124+
</project>
125+

pom.xml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>me.Joshb</groupId>
8+
<artifactId>DiscordBotAPI</artifactId>
9+
<version>1.0.0</version>
10+
11+
<build>
12+
<sourceDirectory>src/main/java</sourceDirectory>
13+
<resources>
14+
<resource>
15+
<targetPath>.</targetPath>
16+
<filtering>true</filtering>
17+
<directory>${basedir}/src/main/resources/</directory>
18+
<includes>
19+
<include>plugin.yml</include>
20+
<include>Config.yml</include>
21+
</includes>
22+
</resource>
23+
</resources>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.apache.maven.plugins</groupId>
27+
<artifactId>maven-compiler-plugin</artifactId>
28+
<version>3.5.1</version>
29+
<configuration>
30+
<source>1.8</source>
31+
<target>1.8</target>
32+
</configuration>
33+
</plugin>
34+
<plugin>
35+
<groupId>org.apache.maven.plugins</groupId>
36+
<artifactId>maven-shade-plugin</artifactId>
37+
<version>2.4.3</version>
38+
<executions>
39+
<execution>
40+
<phase>package</phase>
41+
<goals>
42+
<goal>shade</goal>
43+
</goals>
44+
</execution>
45+
</executions>
46+
</plugin>
47+
</plugins>
48+
</build>
49+
50+
<repositories>
51+
<repository>
52+
<id>jcenter</id>
53+
<name>jcenter-bintray</name>
54+
<url>https://jcenter.bintray.com</url>
55+
</repository>
56+
<repository>
57+
<id>bukkit-repo</id>
58+
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
59+
</repository>
60+
<repository>
61+
<id>bungeecord-repo</id>
62+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
63+
</repository>
64+
</repositories>
65+
66+
67+
<dependencies>
68+
<dependency>
69+
<groupId>org.spigotmc</groupId>
70+
<artifactId>spigot-api</artifactId>
71+
<version>1.16.1-R0.1-SNAPSHOT</version>
72+
<scope>provided</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>net.md-5</groupId>
76+
<artifactId>bungeecord-api</artifactId>
77+
<version>1.15-SNAPSHOT</version>
78+
<type>jar</type>
79+
<scope>provided</scope>
80+
</dependency>
81+
<dependency>
82+
<groupId>net.dv8tion</groupId>
83+
<artifactId>JDA</artifactId>
84+
<version>4.2.0_217</version>
85+
<exclusions>
86+
<exclusion>
87+
<groupId>club.minnced</groupId>
88+
<artifactId>opus-java</artifactId>
89+
</exclusion>
90+
</exclusions>
91+
<scope>compile</scope>
92+
</dependency>
93+
</dependencies>
94+
</project>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package me.joshb.bungee;
2+
3+
import net.md_5.bungee.config.Configuration;
4+
import net.md_5.bungee.config.ConfigurationProvider;
5+
import net.md_5.bungee.config.YamlConfiguration;
6+
7+
import java.io.File;
8+
import java.io.IOException;
9+
10+
public class Config {
11+
12+
private String fileName = "Config";
13+
14+
Configuration config;
15+
ConfigurationProvider configp;
16+
17+
File file;
18+
19+
public Config(){ }
20+
private static Config instance = new Config();
21+
public static Config getInstance(){
22+
return instance;
23+
}
24+
25+
public Configuration getConfig(){
26+
return config;
27+
}
28+
29+
30+
public void initialize(){
31+
if (!DiscordBotAPI.plugin.getDataFolder().exists()) {
32+
DiscordBotAPI.plugin.getDataFolder().mkdir();
33+
}
34+
35+
file = new File(DiscordBotAPI.plugin.getDataFolder(), fileName + ".yml");
36+
37+
try{
38+
if(!file.exists()){
39+
file.createNewFile();
40+
}
41+
} catch (IOException e){
42+
e.printStackTrace();
43+
}
44+
45+
configp = ConfigurationProvider.getProvider(YamlConfiguration.class);
46+
try{
47+
config = configp.load(file);
48+
} catch (IOException e){
49+
e.printStackTrace();
50+
}
51+
initSections();
52+
save();
53+
}
54+
55+
public void initSections(){
56+
if(!config.contains("Bot.Token")){
57+
config.set("Bot.Token", "token_here");
58+
}
59+
}
60+
61+
public void save() {
62+
try {
63+
configp = ConfigurationProvider.getProvider(YamlConfiguration.class);
64+
configp.save(config, file);
65+
} catch (IOException e) {
66+
e.printStackTrace();
67+
}
68+
}
69+
70+
public void reload(){
71+
try {
72+
configp = ConfigurationProvider.getProvider(YamlConfiguration.class);
73+
} catch (Exception e){
74+
System.out.println("COULD NOT RELOAD FILE: " + fileName);
75+
e.printStackTrace();
76+
}
77+
}
78+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package me.joshb.bungee;
2+
3+
import net.dv8tion.jda.api.JDA;
4+
import net.dv8tion.jda.api.JDABuilder;
5+
import net.md_5.bungee.api.plugin.Plugin;
6+
7+
import javax.security.auth.login.LoginException;
8+
9+
public class DiscordBotAPI extends Plugin {
10+
11+
public static JDA jda;
12+
13+
public static DiscordBotAPI plugin;
14+
15+
public void onEnable(){
16+
plugin = this;
17+
18+
Config.getInstance().initialize();
19+
20+
if(Config.getInstance().getConfig().getString("Bot.Token").equals("token_here")){
21+
getLogger().severe("Plugin Disabled. The bot token is invalid.");
22+
return;
23+
}
24+
25+
JDABuilder builder = JDABuilder.createDefault(Config.getInstance().getConfig().getString("Bot.Token"));
26+
27+
try {
28+
jda = builder.build();
29+
} catch (LoginException e) {
30+
getLogger().severe("Plugin Disabled. The bot token is invalid. Reason: " + e.getMessage());
31+
}
32+
}
33+
34+
public void onDisable(){
35+
if(jda != null){
36+
jda.shutdown();
37+
}
38+
}
39+
40+
public static JDA getJDA(){
41+
return jda;
42+
}
43+
}

0 commit comments

Comments
 (0)