Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

Commit 1de0ff9

Browse files
committed
Version 1.0
1 parent e88e1b6 commit 1de0ff9

23 files changed

+1330
-0
lines changed

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

pom.xml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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>com.samifying</groupId>
8+
<artifactId>main-plugin</artifactId>
9+
<version>1.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>MainPlugin</name>
13+
14+
<description>The main server plugin hadling the Discord bot and balance api</description>
15+
<properties>
16+
<java.version>1.8</java.version>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
<url>https://samifying.com/</url>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-compiler-plugin</artifactId>
26+
<version>3.8.1</version>
27+
<configuration>
28+
<source>${java.version}</source>
29+
<target>${java.version}</target>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-shade-plugin</artifactId>
35+
<version>3.2.4</version>
36+
<executions>
37+
<execution>
38+
<phase>package</phase>
39+
<goals>
40+
<goal>shade</goal>
41+
</goals>
42+
<configuration>
43+
<createDependencyReducedPom>false</createDependencyReducedPom>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
<resources>
50+
<resource>
51+
<directory>src/main/resources</directory>
52+
<filtering>true</filtering>
53+
</resource>
54+
</resources>
55+
</build>
56+
57+
<repositories>
58+
<repository>
59+
<id>spigotmc-repo</id>
60+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
61+
</repository>
62+
<repository>
63+
<id>sonatype</id>
64+
<url>https://oss.sonatype.org/content/groups/public/</url>
65+
</repository>
66+
<repository>
67+
<id>dv8tion</id>
68+
<name>m2-dv8tion</name>
69+
<url>https://m2.dv8tion.net/releases</url>
70+
</repository>
71+
<repository>
72+
<id>jitpack.io</id>
73+
<url>https://jitpack.io</url>
74+
</repository>
75+
</repositories>
76+
77+
<dependencies>
78+
<dependency>
79+
<groupId>org.spigotmc</groupId>
80+
<artifactId>spigot-api</artifactId>
81+
<version>1.16.5-R0.1-SNAPSHOT</version>
82+
<scope>provided</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>mysql</groupId>
86+
<artifactId>mysql-connector-java</artifactId>
87+
<version>8.0.23</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>com.sparkjava</groupId>
91+
<artifactId>spark-core</artifactId>
92+
<version>2.9.3</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>com.google.code.gson</groupId>
96+
<artifactId>gson</artifactId>
97+
<version>2.8.6</version>
98+
</dependency>
99+
<dependency>
100+
<groupId>net.dv8tion</groupId>
101+
<artifactId>JDA</artifactId>
102+
<version>4.2.1_256</version>
103+
</dependency>
104+
<dependency>
105+
<groupId>com.github.MilkBowl</groupId>
106+
<artifactId>VaultAPI</artifactId>
107+
<version>1.7</version>
108+
<scope>provided</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>ch.qos.logback</groupId>
112+
<artifactId>logback-classic</artifactId>
113+
<version>1.2.3</version>
114+
</dependency>
115+
</dependencies>
116+
</project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.samifying.plugin;
2+
3+
import java.io.IOException;
4+
import java.sql.*;
5+
import java.time.Instant;
6+
7+
public class DatabaseAccess {
8+
9+
private final Connection connection;
10+
11+
public DatabaseAccess() throws SQLException, IOException {
12+
String url = PluginData.getInstance().getMysqlConnectionUrl();
13+
this.connection = DriverManager.getConnection(url);
14+
}
15+
16+
public void insertData(String uuid, String discordId) throws SQLException {
17+
String sql = "INSERT INTO `twitch_link`.`data` (`uuid`, `discord_id`, `time`) VALUES (?, ?, ?);";
18+
PreparedStatement ps = connection.prepareStatement(sql);
19+
ps.setString(1, uuid);
20+
ps.setString(2, discordId);
21+
ps.setString(3, String.valueOf(Instant.now().toEpochMilli()));
22+
ps.executeUpdate();
23+
ps.close();
24+
}
25+
26+
public String retrieveDiscordId(String uuid) throws SQLException {
27+
String sql = "SELECT `discord_id` FROM `twitch_link`.`data` WHERE uuid=?;";
28+
PreparedStatement ps = connection.prepareStatement(sql);
29+
ps.setString(1, uuid);
30+
ResultSet resultSet = ps.executeQuery();
31+
while (resultSet.next()) {
32+
return resultSet.getString("discord_id");
33+
}
34+
return null;
35+
}
36+
37+
public String retrieveUUID(String discordId) throws SQLException {
38+
String sql = "SELECT `uuid` FROM `twitch_link`.`data` WHERE discord_id=?;";
39+
PreparedStatement ps = connection.prepareStatement(sql);
40+
ps.setString(1, discordId);
41+
ResultSet resultSet = ps.executeQuery();
42+
while (resultSet.next()) {
43+
return resultSet.getString("uuid");
44+
}
45+
return null;
46+
}
47+
48+
public String retrieveVerificationTimestamp(String discordId) throws SQLException {
49+
String sql = "SELECT `discord_id` FROM `twitch_link`.`data` WHERE discord_id=?;";
50+
PreparedStatement ps = connection.prepareStatement(sql);
51+
ps.setString(1, discordId);
52+
ResultSet resultSet = ps.executeQuery();
53+
while (resultSet.next()) {
54+
return resultSet.getString("timestamp");
55+
}
56+
return null;
57+
}
58+
59+
public void close() throws SQLException {
60+
connection.close();
61+
}
62+
63+
}

0 commit comments

Comments
 (0)